本文整理汇总了C++中matrix_t::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ matrix_t::clone方法的具体用法?C++ matrix_t::clone怎么用?C++ matrix_t::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matrix_t
的用法示例。
在下文中一共展示了matrix_t::clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
matrix_t matrix_t::solve(matrix_t const &rhs) const
{
stack::fe_asserter dummy{};
// it appears as if dgesv works only for square matrices Oo
// --> if the matrix was rectangular, then they system would be over/under determined
// and we would need least squares instead (LAPACKE_dgels)
stack_assert(get_rows() == get_cols());
stack_assert(this->get_rows() == rhs.get_rows());
// TODO assert that this matrix is not singular
matrix_t A = this->clone(); // will be overwritten by LU factorization
matrix_t b = rhs.clone();
// thes solution is overwritten in b
vector_ll_t ipiv{A.get_rows()};
stack_assert(0 == LAPACKE_dgesv(LAPACK_COL_MAJOR,
A.get_rows(), rhs.get_cols()/*nrhs*/,
A.get_data(), A.ld(),
ipiv.get_data(),
b.get_data(), b.ld()));
return b;
}
示例2:
matrix_t operator+(matrix_t const & X, diag_t const & D)
{
stack::fe_asserter fe{};
stack_assert(X.get_rows() == D.get_rows());
stack_assert(X.get_cols() == D.get_cols());
matrix_t ret = X.clone();
vector_t Xdiag = vector_t{
ret.get_data(),
ret.get_rows()/*it's a square matrix*/,
ret.get_rows() + 1, // diagonal entries of a square matrix
};
Xdiag += diag_clone(D);
return ret;
}
示例3: left_mult
// mult X * D
matrix_t diag_t::left_mult(matrix_t const &X) const
{
stack::fe_asserter fe{};
stack_assert(diagonal.get_len() == X.get_cols());
matrix_t ret = X.clone();
if(ret.get_rows() < ret.get_cols())
for(size_t r = 0; r < ret.get_rows(); r++)
ret[r] *= diagonal;
else
for(size_t c = 0; c < ret.get_cols(); c++)
ret.get_col(c) *= diagonal[c];
return ret;
}