45 SG_REF(m_computation_engine);
56 eig_solver,linear_solver,accuracy);
60 m_trace_sampler=
new CProbingSampler(op,1,NATURAL,DISTANCE_TWO);
67 SG_INFO(
"LogDetEstimator:Using %s, %s with 1E-5 accuracy, %s as default\n",
79 m_trace_sampler=trace_sampler;
82 m_operator_log=operator_log;
85 m_computation_engine=computation_engine;
86 SG_REF(m_computation_engine);
89 void CLogDetEstimator::init()
93 m_computation_engine=NULL;
115 return m_trace_sampler;
120 SG_REF(m_computation_engine);
121 return m_computation_engine;
127 return m_operator_log;
133 SG_INFO(
"Computing %d log-det estimates\n", num_estimates);
135 REQUIRE(m_operator_log,
"Operator function is NULL\n");
139 REQUIRE(m_trace_sampler,
"Trace sampler is NULL\n");
145 "Mismatch in dimensions of the operator and trace-sampler, %d vs %d!\n",
153 for (
index_t i=0; i<num_estimates; ++i)
155 for (
index_t j=0; j<num_trace_samples; ++j)
157 SG_INFO(
"Computing log-determinant trace sample %d/%d\n", j,
160 SG_DEBUG(
"Creating job for estimate %d, trace sample %d/%d\n", i, j,
166 aggregators->append_element(agg);
171 REQUIRE(m_computation_engine,
"Computation engine is NULL\n");
174 SG_INFO(
"Waiting for jobs to finish\n");
176 SG_INFO(
"All jobs finished, aggregating results\n");
184 int32_t num_aggregates=aggregators->get_num_elements();
187 for (int32_t i=0; i<num_aggregates; ++i)
191 (aggregators->get_element(i));
203 if (idx_row>=num_trace_samples)
215 SG_INFO(
"Finished computing %d log-det estimates\n", num_estimates);
226 REQUIRE(m_operator_log,
"Operator function is NULL\n");
230 REQUIRE(m_trace_sampler,
"Trace sampler is NULL\n");
238 for (
index_t i=0; i<num_estimates; ++i)
240 for (
index_t j=0; j<num_trace_samples; ++j)
251 REQUIRE(m_computation_engine,
"Computation engine is NULL\n");
261 for (int32_t i=0; i<num_aggregates; ++i)
266 SG_ERROR(
"Element is not CJobResultAggregator type!\n");
273 SG_ERROR(
"Result is not CScalarResult type!\n");
276 index_t idx_row=i%num_trace_samples;
277 index_t idx_col=i/num_trace_samples;
Base class that stores the result of an independent job when the result is a scalar.
template class SGSparseMatrix
virtual const index_t get_dimension() const
CTraceSampler * get_trace_sampler(void) const
CLinearOperator< T > * get_operator() 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 ~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)
virtual const char * get_name() const
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
CIndependentComputationEngine * get_computation_engine(void) const
virtual CJobResultAggregator * submit_jobs(SGVector< T > sample)=0
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...
virtual void precompute()=0
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
const index_t get_dimension() const
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...
bool append_element(CSGObject *e)