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;