inline int posv (CBLAS_UPLO const uplo, SymmA& a, MatrB& b) { int ierr = potrf (uplo, a); if (ierr == 0) ierr = potrs (uplo, a, b); return ierr; }
inline int posv (SymmA& a, MatrB& b) { int ierr = potrf (a); if (ierr == 0) ierr = potrs (a, b); return ierr; }
double log_cholesky_determinant(MatrixType a) { // factorize int info = potrf(a); if (info) throw std::runtime_error("potrf failed in log_cholesky_determinant" + std::to_string(info)); return log(potrfdet(a)); }
inline int potrf(CBLAS_UPLO const uplo, matrix_container<SymmA>& a) { CBLAS_ORDER const stor_ord= (CBLAS_ORDER)storage_order<typename SymmA::orientation>::value; std::size_t n = a().size1(); SIZE_CHECK(n == a().size2()); return potrf(stor_ord, uplo, (int)n, traits::storage(a()), traits::leading_dimension(a())); }
MatrixType cholesky_invert(MatrixType a) { // factorize int info = potrf(a); if (info != 0) { throw std::runtime_error("potrf failed in cholesky_invert " + std::to_string(info)); } potri(a); return make_symmetric(a); }
inline int potrf( matrix_container<SymmA>& A, boost::mpl::true_ ) { CBLAS_UPLO const uplo = Triangular::is_upper ? CblasUpper : CblasLower; CBLAS_ORDER const stor_ord = (CBLAS_ORDER)storage_order<typename SymmA::orientation>::value; std::size_t n = A().size1(); SIZE_CHECK(n == A().size2()); return potrf( stor_ord, uplo, (int)n, traits::storage(A()), traits::leading_dimension(A()) ); }
inline MKL_INT cholesky_solve(MKL_INT n, MKL_INT nrhs, T a[], T b[], void (*potrf)(const char*, const MKL_INT*, T*, const MKL_INT*, MKL_INT*), void (*potrs)(const char*, const MKL_INT*, const MKL_INT*, const T*, const MKL_INT*, T*, const MKL_INT*, MKL_INT*)) { T* clone = Clone(n, n, a); char uplo = 'L'; MKL_INT info = 0; potrf(&uplo, &n, clone, &n, &info); if (info != 0) { delete[] clone; return info; } potrs(&uplo, &n, &nrhs, clone, &n, b, &n, &info); delete[] clone; return info; }
inline int potrf (CBLAS_UPLO const uplo, SymmA& a) { CBLAS_ORDER const stor_ord = enum_cast<CBLAS_ORDER const> (storage_order< #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS typename traits::matrix_traits<SymmA>::ordering_type #else typename SymmA::orientation_category #endif >::value); int const n = traits::matrix_size1 (a); assert (n == traits::matrix_size2 (a)); return potrf (stor_ord, uplo, n, traits::matrix_storage (a), traits::leading_dimension (a)); }
inline MKL_INT cholesky_factor(MKL_INT n, T* a, void (*potrf)(const char*, const MKL_INT*, T*, const MKL_INT*, MKL_INT*)) { char uplo = 'L'; MKL_INT info = 0; potrf(&uplo, &n, a, &n, &info); T zero = T(); for (MKL_INT i = 0; i < n; ++i) { MKL_INT index = i * n; for (MKL_INT j = 0; j < n && i > j; ++j) { a[index + j] = zero; } } return info; }
inline int cholesky_factor (SymmA& a) { return potrf (a); }
/* Function: reduce * * Reduces a symmetric or Hermitian definite generalized eigenvalue problem to a standard problem after factorizing the right-hand side matrix. * * Parameters: * A - Left-hand side matrix. * B - Right-hand side matrix. */ void reduce(K* const& A, K* const& B) const { int info; potrf("L", &(Eigensolver<K>::_n), B, &(Eigensolver<K>::_n), &info); gst(&i__1, "L", &(Eigensolver<K>::_n), A, &(Eigensolver<K>::_n), B, &(Eigensolver<K>::_n), &info); }