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

Function vectorwiseop_matrix

dependence/eigen-3.4.0/test/vectorwiseop.cpp:129–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129template<typename MatrixType> void vectorwiseop_matrix(const MatrixType& m)
130{
131 typedef typename MatrixType::Scalar Scalar;
132 typedef typename NumTraits<Scalar>::Real RealScalar;
133 typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> ColVectorType;
134 typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime> RowVectorType;
135 typedef Matrix<RealScalar, MatrixType::RowsAtCompileTime, 1> RealColVectorType;
136 typedef Matrix<RealScalar, 1, MatrixType::ColsAtCompileTime> RealRowVectorType;
137 typedef Matrix<Scalar,Dynamic,Dynamic> MatrixX;
138
139 Index rows = m.rows();
140 Index cols = m.cols();
141 Index r = internal::random<Index>(0, rows-1),
142 c = internal::random<Index>(0, cols-1);
143
144 MatrixType m1 = MatrixType::Random(rows, cols),
145 m2(rows, cols),
146 m3(rows, cols);
147
148 ColVectorType colvec = ColVectorType::Random(rows);
149 RowVectorType rowvec = RowVectorType::Random(cols);
150 RealColVectorType rcres;
151 RealRowVectorType rrres;
152
153 // test broadcast assignment
154 m2 = m1;
155 m2.colwise() = colvec;
156 for(Index j=0; j<cols; ++j)
157 VERIFY_IS_APPROX(m2.col(j), colvec);
158 m2.rowwise() = rowvec;
159 for(Index i=0; i<rows; ++i)
160 VERIFY_IS_APPROX(m2.row(i), rowvec);
161 if(rows>1)
162 VERIFY_RAISES_ASSERT(m2.colwise() = colvec.transpose());
163 if(cols>1)
164 VERIFY_RAISES_ASSERT(m2.rowwise() = rowvec.transpose());
165
166 // test addition
167
168 m2 = m1;
169 m2.colwise() += colvec;
170 VERIFY_IS_APPROX(m2, m1.colwise() + colvec);
171 VERIFY_IS_APPROX(m2.col(c), m1.col(c) + colvec);
172
173 if(rows>1)
174 {
175 VERIFY_RAISES_ASSERT(m2.colwise() += colvec.transpose());
176 VERIFY_RAISES_ASSERT(m1.colwise() + colvec.transpose());
177 }
178
179 m2 = m1;
180 m2.rowwise() += rowvec;
181 VERIFY_IS_APPROX(m2, m1.rowwise() + rowvec);
182 VERIFY_IS_APPROX(m2.row(r), m1.row(r) + rowvec);
183
184 if(cols>1)
185 {
186 VERIFY_RAISES_ASSERT(m2.rowwise() += rowvec.transpose());

Callers 1

EIGEN_DECLARE_TESTFunction · 0.85

Calls 15

minCoeffFunction · 0.85
maxCoeffFunction · 0.85
colwiseMethod · 0.80
rowwiseMethod · 0.80
realMethod · 0.80
prodFunction · 0.70
realClass · 0.70
rowsMethod · 0.45
colsMethod · 0.45
colMethod · 0.45
rowMethod · 0.45
transposeMethod · 0.45

Tested by

no test coverage detected