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

Function call_ref

test/ref.cpp:167–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165EIGEN_DONT_INLINE void call_ref_7(Ref<Matrix<float,Dynamic,3> > a, const B &b) { VERIFY_IS_EQUAL(a,b); }
166
167void call_ref()
168{
169 VectorXcf ca = VectorXcf::Random(10);
170 VectorXf a = VectorXf::Random(10);
171 RowVectorXf b = RowVectorXf::Random(10);
172 MatrixXf A = MatrixXf::Random(10,10);
173 RowVector3f c = RowVector3f::Random();
174 const VectorXf& ac(a);
175 VectorBlock<VectorXf> ab(a,0,3);
176 const VectorBlock<VectorXf> abc(a,0,3);
177
178
179 VERIFY_EVALUATION_COUNT( call_ref_1(a,a), 0);
180 VERIFY_EVALUATION_COUNT( call_ref_1(b,b.transpose()), 0);
181// call_ref_1(ac,a<c); // does not compile because ac is const
182 VERIFY_EVALUATION_COUNT( call_ref_1(ab,ab), 0);
183 VERIFY_EVALUATION_COUNT( call_ref_1(a.head(4),a.head(4)), 0);
184 VERIFY_EVALUATION_COUNT( call_ref_1(abc,abc), 0);
185 VERIFY_EVALUATION_COUNT( call_ref_1(A.col(3),A.col(3)), 0);
186// call_ref_1(A.row(3),A.row(3)); // does not compile because innerstride!=1
187 VERIFY_EVALUATION_COUNT( call_ref_3(A.row(3),A.row(3).transpose()), 0);
188 VERIFY_EVALUATION_COUNT( call_ref_4(A.row(3),A.row(3).transpose()), 0);
189// call_ref_1(a+a, a+a); // does not compile for obvious reason
190
191 MatrixXf tmp = A*A.col(1);
192 VERIFY_EVALUATION_COUNT( call_ref_2(A*A.col(1), tmp), 1); // evaluated into a temp
193 VERIFY_EVALUATION_COUNT( call_ref_2(ac.head(5),ac.head(5)), 0);
194 VERIFY_EVALUATION_COUNT( call_ref_2(ac,ac), 0);
195 VERIFY_EVALUATION_COUNT( call_ref_2(a,a), 0);
196 VERIFY_EVALUATION_COUNT( call_ref_2(ab,ab), 0);
197 VERIFY_EVALUATION_COUNT( call_ref_2(a.head(4),a.head(4)), 0);
198 tmp = a+a;
199 VERIFY_EVALUATION_COUNT( call_ref_2(a+a,tmp), 1); // evaluated into a temp
200 VERIFY_EVALUATION_COUNT( call_ref_2(ca.imag(),ca.imag()), 1); // evaluated into a temp
201
202 VERIFY_EVALUATION_COUNT( call_ref_4(ac.head(5),ac.head(5)), 0);
203 tmp = a+a;
204 VERIFY_EVALUATION_COUNT( call_ref_4(a+a,tmp), 1); // evaluated into a temp
205 VERIFY_EVALUATION_COUNT( call_ref_4(ca.imag(),ca.imag()), 0);
206
207 VERIFY_EVALUATION_COUNT( call_ref_5(a,a), 0);
208 VERIFY_EVALUATION_COUNT( call_ref_5(a.head(3),a.head(3)), 0);
209 VERIFY_EVALUATION_COUNT( call_ref_5(A,A), 0);
210// call_ref_5(A.transpose(),A.transpose()); // does not compile because storage order does not match
211 VERIFY_EVALUATION_COUNT( call_ref_5(A.block(1,1,2,2),A.block(1,1,2,2)), 0);
212 VERIFY_EVALUATION_COUNT( call_ref_5(b,b), 0); // storage order do not match, but this is a degenerate case that should work
213 VERIFY_EVALUATION_COUNT( call_ref_5(a.row(3),a.row(3)), 0);
214
215 VERIFY_EVALUATION_COUNT( call_ref_6(a,a), 0);
216 VERIFY_EVALUATION_COUNT( call_ref_6(a.head(3),a.head(3)), 0);
217 VERIFY_EVALUATION_COUNT( call_ref_6(A.row(3),A.row(3)), 1); // evaluated into a temp thouth it could be avoided by viewing it as a 1xn matrix
218 tmp = A+A;
219 VERIFY_EVALUATION_COUNT( call_ref_6(A+A,tmp), 1); // evaluated into a temp
220 VERIFY_EVALUATION_COUNT( call_ref_6(A,A), 0);
221 VERIFY_EVALUATION_COUNT( call_ref_6(A.transpose(),A.transpose()), 1); // evaluated into a temp because the storage orders do not match
222 VERIFY_EVALUATION_COUNT( call_ref_6(A.block(1,1,2,2),A.block(1,1,2,2)), 0);
223
224 VERIFY_EVALUATION_COUNT( call_ref_7(c,c), 0);

Callers 1

test_refFunction · 0.70

Calls 11

call_ref_6Function · 0.85
call_ref_7Function · 0.85
imagMethod · 0.80
call_ref_1Function · 0.70
call_ref_3Function · 0.70
call_ref_4Function · 0.70
call_ref_2Function · 0.70
call_ref_5Function · 0.70
transposeMethod · 0.45
colMethod · 0.45
rowMethod · 0.45

Tested by 1

test_refFunction · 0.56