MCPcopy Create free account
hub / github.com/Derious/cuMPC / miscMatrices

Function miscMatrices

dependence/eigen-3.4.0/test/miscmatrices.cpp:12–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "main.h"
11
12template<typename MatrixType> void miscMatrices(const MatrixType& m)
13{
14 /* this test covers the following files:
15 DiagonalMatrix.h Ones.h
16 */
17 typedef typename MatrixType::Scalar Scalar;
18 typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
19 Index rows = m.rows();
20 Index cols = m.cols();
21
22 Index r = internal::random<Index>(0, rows-1), r2 = internal::random<Index>(0, rows-1), c = internal::random<Index>(0, cols-1);
23 VERIFY_IS_APPROX(MatrixType::Ones(rows,cols)(r,c), static_cast<Scalar>(1));
24 MatrixType m1 = MatrixType::Ones(rows,cols);
25 VERIFY_IS_APPROX(m1(r,c), static_cast<Scalar>(1));
26 VectorType v1 = VectorType::Random(rows);
27 v1[0];
28 Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
29 square(v1.asDiagonal());
30 if(r==r2) VERIFY_IS_APPROX(square(r,r2), v1[r]);
31 else VERIFY_IS_MUCH_SMALLER_THAN(square(r,r2), static_cast<Scalar>(1));
32 square = MatrixType::Zero(rows, rows);
33 square.diagonal() = VectorType::Ones(rows);
34 VERIFY_IS_APPROX(square, MatrixType::Identity(rows, rows));
35}
36
37EIGEN_DECLARE_TEST(miscmatrices)
38{

Callers 1

EIGEN_DECLARE_TESTFunction · 0.85

Calls 5

squareFunction · 0.85
asDiagonalMethod · 0.80
rowsMethod · 0.45
colsMethod · 0.45
diagonalMethod · 0.45

Tested by

no test coverage detected