本文整理汇总了C++中matrix_t::data方法的典型用法代码示例。如果您正苦于以下问题:C++ matrix_t::data方法的具体用法?C++ matrix_t::data怎么用?C++ matrix_t::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matrix_t
的用法示例。
在下文中一共展示了matrix_t::data方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyGaussian
static void applyGaussian(matrix_t& m) {
matrix_t::array_type& arr = m.data();
double sig = *std::max_element(arr.begin(), arr.end());
BOOST_FOREACH(double& v, arr) {
v = std::exp(-v * v / (2 * sig * sig));
}
示例2: getrf
// LU factorization of a general matrix A.
// Computes an LU factorization of a general M-by-N matrix A using
// partial pivoting with row interchanges. Factorization has the form
// A = P*L*U.
// a (IN/OUT - matrix(M,N)) On entry, the coefficient matrix A to be factored. On exit, the factors L and U from the factorization A = P*L*U.
// ipivot (OUT - vector(min(M,N))) Integer vector. The row i of A was interchanged with row IPIV(i).
// info (OUT - int)
// 0 : successful exit
// < 0 : If INFO = -i, then the i-th argument had an illegal value.
// > 0 : If INFO = i, then U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.
int getrf (matrix_t& a, pivot_t& ipivot)
{
matrix_t::value_type* _a = a.data().begin();
int _m = int(a.size1());
int _n = int(a.size2());
int _lda = _m; // minor size
int _info;
rawLAPACK::getrf (_m, _n, _a, _lda, ipivot.data().begin(), _info);
return _info;
}
示例3: getrs
// Solution to a system using LU factorization
// Solves a system of linear equations A*X = B with a general NxN
// matrix A using the LU factorization computed by GETRF.
// transa (IN - char) 'T' for the transpose of A, 'N' otherwise.
// a (IN - matrix(M,N)) The factors L and U from the factorization A = P*L*U as computed by GETRF.
// ipivot (IN - vector(min(M,N))) Integer vector. The pivot indices from GETRF; row i of A was interchanged with row IPIV(i).
// b (IN/OUT - matrix(ldb,NRHS)) Matrix of same numerical type as A. On entry, the right hand side matrix B. On exit, the solution matrix X.
//
// info (OUT - int)
// 0 : function completed normally
// < 0 : The ith argument, where i = abs(return value) had an illegal value.
// > 0 : if INFO = i, U(i,i) is exactly zero; the matrix is singular and its inverse could not be computed.
int getrs (char transa, matrix_t& a,
pivot_t& ipivot, matrix_t& b)
{
matrix_t::value_type* _a = a.data().begin();
int a_n = int(a.size1());
int _lda = a_n;
int p_n = int(ipivot.size());
matrix_t::value_type* _b = b.data().begin();
int b_n = int(b.size1());
int _ldb = b_n;
int _nrhs = int(b.size2()); /* B's size2 is the # of vectors on rhs */
if (a_n != b_n) /*Test to see if AX=B has correct dimensions */
return -101;
if (p_n < a_n) /*Check to see if ipivot is big enough */
return -102;
int _info;
rawLAPACK::getrs (transa, a_n, _nrhs, _a, _lda, ipivot.data().begin(),
_b, _ldb, _info);
return _info;
}
示例4: geqrf
// QR Factorization of a MxN General Matrix A.
// a (IN/OUT - matrix(M,N)) On entry, the coefficient matrix A. On exit , the upper triangle and diagonal is the min(M,N) by N upper triangular matrix R. The lower triangle, together with the tau vector, is the orthogonal matrix Q as a product of min(M,N) elementary reflectors.
// tau (OUT - vector (min(M,N))) Vector of the same numerical type as A. The scalar factors of the elementary reflectors.
// info (OUT - int)
// 0 : function completed normally
// < 0 : The ith argument, where i = abs(return value) had an illegal value.
int geqrf (matrix_t& a, vector_t& tau)
{
int _m = int(a.size1());
int _n = int(a.size2());
int _lda = int(a.size1());
int _info;
// make_sure tau's size is greater than or equal to min(m,n)
if (int(tau.size()) < (_n<_m ? _n : _m) )
return -104;
int ldwork = _n*_n;
vector_t dwork(ldwork);
rawLAPACK::geqrf (_m, _n, a.data().begin(), _lda, tau.data().begin(), dwork.data().begin(), ldwork, _info);
return _info;
}