46 SG_REF(m_computation_engine);
57 eig_solver,linear_solver,accuracy);
61 m_trace_sampler=
new CProbingSampler(op,1,NATURAL,DISTANCE_TWO);
68 SG_INFO(
"LogDetEstimator:Using %s, %s with 1E-5 accuracy, %s as default\n",
81 m_trace_sampler=trace_sampler;
84 m_operator_log=operator_log;
87 m_computation_engine=computation_engine;
88 SG_REF(m_computation_engine);
91 void CLogDetEstimator::init()
95 m_computation_engine=NULL;
117 return m_trace_sampler;
122 SG_REF(m_computation_engine);
123 return m_computation_engine;
129 return m_operator_log;
135 SG_INFO(
"Computing %d log-det estimates\n", num_estimates);
137 REQUIRE(m_operator_log,
"Operator function is NULL\n");
141 REQUIRE(m_trace_sampler,
"Trace sampler is NULL\n");
147 "Mismatch in dimensions of the operator and trace-sampler, %d vs %d!\n",
155 for (
index_t i=0; i<num_estimates; ++i)
157 for (
index_t j=0; j<num_trace_samples; ++j)
159 SG_INFO(
"Computing log-determinant trace sample %d/%d\n", j,
162 SG_DEBUG(
"Creating job for estimate %d, trace sample %d/%d\n", i, j,
168 aggregators->append_element(agg);
173 REQUIRE(m_computation_engine,
"Computation engine is NULL\n");
176 SG_INFO(
"Waiting for jobs to finish\n");
178 SG_INFO(
"All jobs finished, aggregating results\n");
186 int32_t num_aggregates=aggregators->get_num_elements();
189 for (int32_t i=0; i<num_aggregates; ++i)
193 (aggregators->get_element(i));
205 if (idx_row>=num_trace_samples)
217 SG_INFO(
"Finished computing %d log-det estimates\n", num_estimates);
228 REQUIRE(m_operator_log,
"Operator function is NULL\n");
232 REQUIRE(m_trace_sampler,
"Trace sampler is NULL\n");
240 for (
index_t i=0; i<num_estimates; ++i)
242 for (
index_t j=0; j<num_trace_samples; ++j)
253 REQUIRE(m_computation_engine,
"Computation engine is NULL\n");
263 for (int32_t i=0; i<num_aggregates; ++i)
268 SG_ERROR(
"Element is not CJobResultAggregator type!\n");
275 SG_ERROR(
"Result is not CScalarResult type!\n");
278 index_t idx_row=i%num_trace_samples;
279 index_t idx_col=i/num_trace_samples;
Base class that stores the result of an independent job when the result is a scalar.
virtual const index_t get_dimension() const
CTraceSampler * get_trace_sampler(void) const
const index_t get_dimension() const
SGVector< float64_t > sample(index_t num_estimates)
Class that computes multiple independent instances of computation jobs sequentially.
Implementaion of rational approximation of a operator-function times vector where the operator functi...
virtual void wait_for_all()=0
class that uses conjugate gradient method for solving a shifted linear system family where the linear...
virtual void finalize()=0
virtual SGVector< float64_t > sample(index_t idx) const =0
virtual void precompute()=0
virtual ~CLogDetEstimator()
virtual const index_t get_num_samples() const
int32_t get_num_elements() const
SGMatrix< float64_t > sample_without_averaging(index_t num_estimates)
CJobResult * get_final_result() const
virtual void precompute()=0
Class SGObject is the base class of all shogun objects.
Class that computes eigenvalues of a real valued, self-adjoint linear operator using Lanczos algorith...
virtual const char * get_name() const
CLinearOperator< T > * get_operator() const
CIndependentComputationEngine * get_computation_engine(void) const
virtual const char * get_name() const
virtual const char * get_name() const
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
Abstract base class that provides an interface for computing an aggeregation of the job results of in...
COperatorFunction< float64_t > * get_operator_function(void) const
all of classes and functions are contained in the shogun namespace
Class that represents a sparse-matrix linear operator. It computes matrix-vector product in its appl...
Class that provides a sample method for Gaussian samples.
Abstract base class for solving multiple independent instances of CIndependentJob. It has one method, submit_job, which may add the job to an internal queue and might block if there is yet not space in the queue. After jobs are submitted, it might not yet be ready. wait_for_all waits until all jobs are completed, which must be called to guarantee that all jobs are finished.
const T get_result() const
CSGObject * get_element(int32_t index) const
Abstract template base class that provides an interface for sampling the trace of a linear operator u...
virtual CJobResultAggregator * submit_jobs(SGVector< T > sample)=0
bool append_element(CSGObject *e)