37 m_trace_sampler=trace_sampler;
40 m_operator_log=operator_log;
43 m_computation_engine=computation_engine;
44 SG_REF(m_computation_engine);
47 void CLogDetEstimator::init()
51 m_computation_engine=NULL;
73 SG_INFO(
"Computing %d log-det estimates\n", num_estimates);
75 REQUIRE(m_operator_log,
"Operator function is NULL\n");
79 REQUIRE(m_trace_sampler,
"Trace sampler is NULL\n");
85 "Mismatch in dimensions of the operator and trace-sampler, %d vs %d!\n",
93 for (
index_t i=0; i<num_estimates; ++i)
95 for (
index_t j=0; j<num_trace_samples; ++j)
97 SG_INFO(
"Computing log-determinant trace sample %d/%d\n", j,
100 SG_DEBUG(
"Creating job for estimate %d, trace sample %d/%d\n", i, j,
106 aggregators->append_element(agg);
111 REQUIRE(m_computation_engine,
"Computation engine is NULL\n");
114 SG_INFO(
"Waiting for jobs to finish\n");
116 SG_INFO(
"All jobs finished, aggregating results\n");
124 int32_t num_aggregates=aggregators->get_num_elements();
127 for (int32_t i=0; i<num_aggregates; ++i)
131 (aggregators->get_element(i));
143 if (idx_row>=num_trace_samples)
155 SG_INFO(
"Finished computing %d log-det estimates\n", num_estimates);
166 REQUIRE(m_operator_log,
"Operator function is NULL\n");
170 REQUIRE(m_trace_sampler,
"Trace sampler is NULL\n");
178 for (
index_t i=0; i<num_estimates; ++i)
180 for (
index_t j=0; j<num_trace_samples; ++j)
191 REQUIRE(m_computation_engine,
"Computation engine is NULL\n");
201 for (int32_t i=0; i<num_aggregates; ++i)
206 SG_ERROR(
"Element is not CJobResultAggregator type!\n");
213 SG_ERROR(
"Result is not CScalarResult type!\n");
216 index_t idx_row=i%num_trace_samples;
217 index_t idx_col=i/num_trace_samples;
Base class that stores the result of an independent job when the result is a scalar.
SGVector< float64_t > sample(index_t num_estimates)
const T get_result() const
virtual void wait_for_all()=0
virtual void finalize()=0
virtual SGVector< float64_t > sample(index_t idx) const =0
CSGObject * get_element(int32_t index) const
virtual ~CLogDetEstimator()
SGMatrix< float64_t > sample_without_averaging(index_t num_estimates)
CLinearOperator< T > * get_operator() const
virtual void precompute()=0
Class SGObject is the base class of all shogun objects.
const index_t get_dimension() const
virtual const index_t get_dimension() const
virtual CJobResultAggregator * submit_jobs(SGVector< T > sample)=0
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
int32_t get_num_elements() const
virtual void precompute()=0
Abstract base class that provides an interface for computing an aggeregation of the job results of in...
CJobResult * get_final_result() const
all of classes and functions are contained in the shogun namespace
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.
Abstract template base class that provides an interface for sampling the trace of a linear operator u...
virtual const index_t get_num_samples() const
bool append_element(CSGObject *e)