本文整理汇总了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;
}
示例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);
}
示例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;
}
示例4:
BOOST_UBLAS_INLINE
typename ublas::matrix<T,F,A>::pointer
matrix_storage (ublas::matrix<T,F,A> &m) {
return &m.data().begin()[0];
}
示例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()]
);
}