CDenseMatrixOperator<T>::CDenseMatrixOperator( const CDenseMatrixOperator<T>& orig) : CMatrixOperator<T>(orig.get_dimension()) { init(); m_operator=SGMatrix<T>(orig.m_operator.num_rows, orig.m_operator.num_cols); for (index_t i=0; i<m_operator.num_cols; ++i) { for (index_t j=0; j<m_operator.num_rows; ++j) m_operator(j,i)=orig.m_operator(j,i); } SG_SGCDEBUG("%s deep copy created (%p)\n", this->get_name(), this); }
void CDirectEigenSolver::compute() { if (m_is_computed_min && m_is_computed_max) { SG_DEBUG("Minimum/maximum eigenvalues are already computed, exiting\n"); return; } CDenseMatrixOperator<float64_t>* op =dynamic_cast<CDenseMatrixOperator<float64_t>*>(m_linear_operator); REQUIRE(op, "Linear operator is not of CDenseMatrixOperator type!\n"); SGMatrix<float64_t> m=op->get_matrix_operator(); Map<MatrixXd> map_m(m.matrix, m.num_rows, m.num_cols); // compute the eigenvalues with Eigen3 SelfAdjointEigenSolver<MatrixXd> eig_solver(map_m); m_min_eigenvalue=eig_solver.eigenvalues()[0]; m_max_eigenvalue=eig_solver.eigenvalues()[op->get_dimension()-1]; m_is_computed_min=true; m_is_computed_max=false; }