当前位置: 首页>>代码示例>>C++>>正文


C++ matrix::data方法代码示例

本文整理汇总了C++中boost::numeric::ublas::matrix::data方法的典型用法代码示例。如果您正苦于以下问题:C++ matrix::data方法的具体用法?C++ matrix::data怎么用?C++ matrix::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::numeric::ublas::matrix的用法示例。


在下文中一共展示了matrix::data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cholesky_basic_checked

        int cholesky_basic_checked(ublas::matrix<double,F,A> &m, const bool upper)
            // Perform Cholesky decomposition, but do not zero out other-triangular part.
            // Returns 0 if matrix was actual positive-definite, otherwise it returns a
            // LAPACK info value.
        {
            if (m.size1() != m.size2())
                throw LogicalError(ERROR_INFO("Matrix is not square"));
            assert(is_symmetric(m)); 

            // Call LAPACK routine
            int info;
            char uplo = detail::uplo_flag(m, upper);
            int size = static_cast<int>(m.size1());
            detail::dpotrf_( &uplo, &size, &m.data()[0], &size, &info );

            // Check validity of result
            if (info < 0) 
                throw LogicalError(ERROR_INFO("Invalid argument"), info);

            return info;
        }
开发者ID:Aaaaaaare,项目名称:beliefbox,代码行数:21,代码来源:cholesky.hpp

示例2: inv_chol_inplace

    void inv_chol_inplace(ublas::matrix<double,F,A> &m, const bool upper=true)
	// Compute inverse (in-place) of a pos. def. matrix that has previously been 
	// Cholesky decomposed (ie, "m" is already a Cholesky matrix). 
	// WARNINGS: 
	//	(1) The value of "upper" must match the actual form of "m". This function does not check.
	//	(2) This function does *not* return the inverse of a Cholesky matrix.
    {
        // Call LAPACK routine
        int info;
        char uplo = detail::uplo_flag(m, upper);
        int size = static_cast<int>(m.size1());
        detail::dpotri_( &uplo, &size, m.data().begin(), &size, &info );

        // Check validity of result
        if (info < 0) 
            throw LogicalError(ERROR_INFO("Invalid argument"), info);
        else if (info > 0) 
            throw NumericalError(ERROR_INFO("Inverse does not exist"), info);

        // Copy result to other triangular part (ie, make a symmetric inverse matrix)
        force_symmetry(m, upper);
    }
开发者ID:Aaaaaaare,项目名称:beliefbox,代码行数:22,代码来源:cholesky.hpp

示例3: read_matrix

bool read_matrix(FILE* file, boost::numeric::ublas::matrix<T, boost::numeric::ublas::column_major>& m) {
  unsigned magic, rowCount, columnCount;
  if (fread(&magic, sizeof(unsigned), 1, file) != 1)
    return false;
  if (!check_magic<T>(magic))
    return false;

  if (fread(&rowCount, sizeof(unsigned), 1, file) != 1)
    return false;
  if (fread(&columnCount, sizeof(unsigned), 1, file) != 1)
    return false;

  const unsigned count = rowCount * columnCount;
  if (rowCount != m.size1() || columnCount != m.size2())
    m.resize(rowCount, columnCount, false);
  T* buffer = new T[count];
  if (fread(buffer, sizeof(T), count, file) != count)
    return false;

  std::copy(buffer, buffer + count, m.data().begin());

  return true;
}
开发者ID:e-thereal,项目名称:gapputils,代码行数:23,代码来源:ublas_io.hpp

示例4:

 BOOST_UBLAS_INLINE
 typename ublas::matrix<T,F,A>::pointer 
 matrix_storage (ublas::matrix<T,F,A> &m) {
   return &m.data().begin()[0];
 }
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:5,代码来源:matrix_raw.hpp

示例5:

template <typename T> boost::const_multi_array_ref<T, 2> make_view(boost::numeric::ublas::matrix<T> const& m) {
    return  boost::const_multi_array_ref<T,2> (
            &*m.data().begin(),
            boost::extents[m.size1()][m.size2()]
        );
}
开发者ID:CCJY,项目名称:coliru,代码行数:6,代码来源:main.cpp


注:本文中的boost::numeric::ublas::matrix::data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。