本文整理汇总了C++中math::Matrix::cols方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::cols方法的具体用法?C++ Matrix::cols怎么用?C++ Matrix::cols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math::Matrix
的用法示例。
在下文中一共展示了Matrix::cols方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeAsciiMatrix
void writeAsciiMatrix(const std::string& fname, const Math::Matrix<T,P,S>& M,
const std::string& meta, const bool trans = false) {
Math::Range start(0,0);
Math::Range end(M.rows(), M.cols());
std::ofstream ofs(fname.c_str());
if (!ofs.is_open())
throw(std::runtime_error("Cannot open " + fname + " for writing."));
MatrixWriteImpl<T,P,S,internal::BasicMatrixFormatter<T> >::write(ofs, M, meta, start, end, trans);
}
示例2: mat
void
TestMatrix::runSubTest8(double& res, double& expected, std::string& subTestName)
{
expected = 1;
subTestName = "simple_invert";
#ifdef COSMO_LAPACK
Math::Matrix<double> mat(2, 2);
mat(0, 0) = 1;
mat(0, 1) = 2;
mat(1, 0) = 3;
mat(1, 1) = 4;
mat.writeIntoTextFile("test_files/matrix_test_8_original.txt");
Math::Matrix<double> invMat;
mat.getInverse(&invMat);
invMat.writeIntoTextFile("test_files/matrix_test_8_inverse.txt");
Math::Matrix<double> prod = invMat * mat;
prod.writeIntoTextFile("test_files/matrix_test_8_product.txt");
res = 1;
for(int i = 0; i < prod.rows(); ++i)
{
for(int j = 0; j < prod.cols(); ++j)
{
if(i == j)
{
if(!Math::areEqual(prod(i, j), 1.0, 1e-5))
{
output_screen("FAIL! Diagonal element " << i << " must be 1 but it is " << prod(i, j) << std::endl);
res = 0;
}
}
else
{
if(!Math::areEqual(prod(i, j), 0.0, 1e-5))
{
output_screen("FAIL! Non-diagonal element " << i << " " << j << " must be 0 but it is " << prod(i, j) << std::endl);
res = 0;
}
}
}
}
#else
output_screen_clean("This test (below) is skipped because Cosmo++ has not been linked to lapack" << std::endl);
res = 1;
#endif
}