MCPcopy Create free account
hub / github.com/PX4/eigen / zeroSizedMatrix

Function zeroSizedMatrix

test/zerosized.cpp:25–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24
25template<typename MatrixType> void zeroSizedMatrix()
26{
27 MatrixType t1;
28 typedef typename MatrixType::Scalar Scalar;
29
30 if (MatrixType::SizeAtCompileTime == Dynamic || MatrixType::SizeAtCompileTime == 0)
31 {
32 zeroReduction(t1);
33 if (MatrixType::RowsAtCompileTime == Dynamic)
34 VERIFY(t1.rows() == 0);
35 if (MatrixType::ColsAtCompileTime == Dynamic)
36 VERIFY(t1.cols() == 0);
37
38 if (MatrixType::RowsAtCompileTime == Dynamic && MatrixType::ColsAtCompileTime == Dynamic)
39 {
40
41 MatrixType t2(0, 0), t3(t1);
42 VERIFY(t2.rows() == 0);
43 VERIFY(t2.cols() == 0);
44
45 zeroReduction(t2);
46 VERIFY(t1==t2);
47 }
48 }
49
50 if(MatrixType::MaxColsAtCompileTime!=0 && MatrixType::MaxRowsAtCompileTime!=0)
51 {
52 Index rows = MatrixType::RowsAtCompileTime==Dynamic ? internal::random<Index>(1,10) : Index(MatrixType::RowsAtCompileTime);
53 Index cols = MatrixType::ColsAtCompileTime==Dynamic ? internal::random<Index>(1,10) : Index(MatrixType::ColsAtCompileTime);
54 MatrixType m(rows,cols);
55 zeroReduction(m.template block<0,MatrixType::ColsAtCompileTime>(0,0,0,cols));
56 zeroReduction(m.template block<MatrixType::RowsAtCompileTime,0>(0,0,rows,0));
57 zeroReduction(m.template block<0,1>(0,0));
58 zeroReduction(m.template block<1,0>(0,0));
59 Matrix<Scalar,Dynamic,Dynamic> prod = m.template block<MatrixType::RowsAtCompileTime,0>(0,0,rows,0) * m.template block<0,MatrixType::ColsAtCompileTime>(0,0,0,cols);
60 VERIFY(prod.rows()==rows && prod.cols()==cols);
61 VERIFY(prod.isZero());
62 prod = m.template block<1,0>(0,0) * m.template block<0,1>(0,0);
63 VERIFY(prod.size()==1);
64 VERIFY(prod.isZero());
65 }
66}
67
68template<typename VectorType> void zeroSizedVector()
69{

Callers

nothing calls this directly

Calls 5

zeroReductionFunction · 0.85
isZeroMethod · 0.80
rowsMethod · 0.45
colsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected