inline
 int posv (SymmA& a, MatrB& b) {
   int ierr = potrf (a); 
   if (ierr == 0)
     ierr = potrs (a, b);
   return ierr; 
 }
 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; 
 }
示例#3
0
inline MKL_INT cholesky_solve_factored(MKL_INT n, MKL_INT nrhs, T a[], T b[],
                                       void (*potrs)(const char*, const MKL_INT*, const MKL_INT*, const T*, const MKL_INT*, T*, const MKL_INT*, MKL_INT*))
{
    char uplo = 'L';
    MKL_INT info = 0;
    potrs(&uplo, &n, &nrhs, a, &n, b, &n, &info);
    return info;
}
示例#4
0
文件: newton.hpp 项目: hrhill/ook
/// \brief Solve the system Ax = b where A is a
/// symmetric positive definite matrix.
vector
solve(matrix A, vector b)
{
    gmw81(A);
    convert_to_cholesky(A);
    potrs(A, b, 'L');

    return b;
}
示例#5
0
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 cholesky_substitute (SymmA const& a, MatrB& b) { return potrs (a, b); }
      inline
      int potrs (CBLAS_UPLO const uplo, SymmA const& a, MatrB& b) {
#ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK 
        BOOST_STATIC_ASSERT((boost::is_same<
          typename traits::matrix_traits<SymmA>::ordering_type,
          typename traits::matrix_traits<MatrB>::ordering_type
        >::value)); 
#endif 

        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);
        int const nrhs = stor_ord == CblasColMajor
          ? traits::matrix_size2 (b)
          : traits::matrix_size1 (b); 
        assert (n == traits::matrix_size2 (a)); 
        assert (n == (stor_ord == CblasColMajor
                      ? traits::matrix_size1 (b)
                      : traits::matrix_size2 (b))); 

#ifndef BOOST_NUMERIC_BINDINGS_ATLAS_POTRF_BUG
        return potrs (stor_ord, uplo, n, nrhs, 
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
                      traits::matrix_storage (a), 
#else
                      traits::matrix_storage_const (a), 
#endif 
                      traits::leading_dimension (a),
                      traits::matrix_storage (b),
                      traits::leading_dimension (b));
#else // BOOST_NUMERIC_BINDINGS_ATLAS_POTRF_BUG
        int ierr; 
        if (stor_ord == CblasColMajor)
          ierr = potrs (stor_ord, uplo, n, nrhs, 
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
                        traits::matrix_storage (a), 
#else
                        traits::matrix_storage_const (a), 
#endif 
                        traits::leading_dimension (a),
                        traits::matrix_storage (b),
                        traits::leading_dimension (b));
        else // ATLAS bug with CblasRowMajor 
          ierr = potrs_bug (stor_ord, uplo, n, nrhs, 
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
                            traits::matrix_storage (a), 
#else
                            traits::matrix_storage_const (a), 
#endif 
                            traits::leading_dimension (a),
                            traits::matrix_storage (b),
                            traits::leading_dimension (b));
        return ierr; 
#endif // BOOST_NUMERIC_BINDINGS_ATLAS_POTRF_BUG
      }