本文整理汇总了C++中mat::_data方法的典型用法代码示例。如果您正苦于以下问题:C++ mat::_data方法的具体用法?C++ mat::_data怎么用?C++ mat::_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat
的用法示例。
在下文中一共展示了mat::_data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qr
bool qr(const mat &A, mat &R)
{
int info;
int m = A.rows();
int n = A.cols();
int lwork = n;
int k = std::min(m, n);
vec tau(k);
vec work(lwork);
R = A;
// perform workspace query for optimum lwork value
int lwork_tmp = -1;
dgeqrf_(&m, &n, R._data(), &m, tau._data(), work._data(), &lwork_tmp,
&info);
if (info == 0) {
lwork = static_cast<int>(work(0));
work.set_size(lwork, false);
}
dgeqrf_(&m, &n, R._data(), &m, tau._data(), work._data(), &lwork, &info);
// construct R
for (int i = 0; i < m; i++)
for (int j = 0; j < std::min(i, n); j++)
R(i, j) = 0;
return (info == 0);
}
示例2: schur
bool schur(const mat &A, mat &U, mat &T)
{
it_assert_debug(A.rows() == A.cols(), "schur(): Matrix is not square");
char jobvs = 'V';
char sort = 'N';
int info;
int n = A.rows();
int lda = n;
int ldvs = n;
int lwork = 3 * n; // This may be choosen better!
int sdim = 0;
vec wr(n);
vec wi(n);
vec work(lwork);
T.set_size(lda, n, false);
U.set_size(ldvs, n, false);
T = A; // The routine overwrites input matrix with eigenvectors
dgees_(&jobvs, &sort, 0, &n, T._data(), &lda, &sdim, wr._data(), wi._data(),
U._data(), &ldvs, work._data(), &lwork, 0, &info);
return (info == 0);
}
示例3: inv
bool inv(const mat &X, mat &Y)
{
// it_assert1(X.rows() == X.cols(), "inv: matrix is not square");
int m = X.rows(), info, lwork;
lwork = m; // may be choosen better
ivec p(m);
Y = X;
vec work(lwork);
dgetrf_(&m, &m, Y._data(), &m, p._data(), &info); // LU-factorization
if (info!=0)
return false;
dgetri_(&m, Y._data(), &m, p._data(), work._data(), &lwork, &info);
return (info==0);
}
示例4: temp
cmat operator*(const std::complex<double> &s, const mat &m)
{
it_assert_debug(m.rows() > 0 && m.cols() > 0, "operator*(): Matrix of zero length");
cmat temp(m.rows(), m.cols());
for (int i = 0;i < m._datasize();i++) {
temp._data()[i] = s * m._data()[i];
}
return temp;
}
示例5: svd
bool svd(const mat &A, mat &U, vec &S, mat &V)
{
char jobu='A', jobvt='A';
int m, n, lda, ldu, ldvt, lwork, info;
m = lda = ldu = A.rows();
n = ldvt = A.cols();
lwork = max(3*min(m,n)+max(m,n), 5*min(m,n));
U.set_size(m,m, false);
V.set_size(n,n, false);
S.set_size(min(m,n), false);
vec work(lwork);
mat B(A);
dgesvd_(&jobu, &jobvt, &m, &n, B._data(), &lda, S._data(), U._data(), &ldu, V._data(), &ldvt, work._data(), &lwork, &info);
V = transpose(V); // This is probably slow!!!
return (info==0);
}