MCPcopy Create free account
hub / github.com/avaxman/Directional / zeroSizedMatrix

Function zeroSizedMatrix

external/eigen/test/zerosized.cpp:34–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33
34template<typename MatrixType> void zeroSizedMatrix()
35{
36 MatrixType t1;
37 typedef typename MatrixType::Scalar Scalar;
38
39 if (MatrixType::SizeAtCompileTime == Dynamic || MatrixType::SizeAtCompileTime == 0)
40 {
41 zeroReduction(t1);
42 if (MatrixType::RowsAtCompileTime == Dynamic)
43 VERIFY(t1.rows() == 0);
44 if (MatrixType::ColsAtCompileTime == Dynamic)
45 VERIFY(t1.cols() == 0);
46
47 if (MatrixType::RowsAtCompileTime == Dynamic && MatrixType::ColsAtCompileTime == Dynamic)
48 {
49
50 MatrixType t2(0, 0);
51 VERIFY(t2.rows() == 0);
52 VERIFY(t2.cols() == 0);
53
54 zeroReduction(t2);
55 VERIFY(t1==t2);
56 }
57 }
58
59 if(MatrixType::MaxColsAtCompileTime!=0 && MatrixType::MaxRowsAtCompileTime!=0)
60 {
61 Index rows = MatrixType::RowsAtCompileTime==Dynamic ? internal::random<Index>(1,10) : Index(MatrixType::RowsAtCompileTime);
62 Index cols = MatrixType::ColsAtCompileTime==Dynamic ? internal::random<Index>(1,10) : Index(MatrixType::ColsAtCompileTime);
63 MatrixType m(rows,cols);
64 zeroReduction(m.template block<0,MatrixType::ColsAtCompileTime>(0,0,0,cols));
65 zeroReduction(m.template block<MatrixType::RowsAtCompileTime,0>(0,0,rows,0));
66 zeroReduction(m.template block<0,1>(0,0));
67 zeroReduction(m.template block<1,0>(0,0));
68 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);
69 VERIFY(prod.rows()==rows && prod.cols()==cols);
70 VERIFY(prod.isZero());
71 prod = m.template block<1,0>(0,0) * m.template block<0,1>(0,0);
72 VERIFY(prod.size()==1);
73 VERIFY(prod.isZero());
74 }
75}
76
77template<typename VectorType> void zeroSizedVector()
78{

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