13 template<
typename MatrixType>
19 bool offDiagOK =
true;
22 offDiagOK = offDiagOK && (
A(
i,
j) ==
zero);
27 offDiagOK = offDiagOK && (
A(
i,
j) ==
zero);
31 bool diagOK = (
A.diagonal().array() == 1).
all();
32 return offDiagOK && diagOK;
36 template<
typename VectorType>
56 std::cout <<
v(
i) <<
" != " <<
ref <<
" ; relative error: " <<
std::abs((
v(
i)-
ref)/
ref) <<
" ; required precision: " << prec <<
" ; range: " << low <<
"," << high <<
" ; i: " <<
i <<
"\n";
63 template<
typename VectorType>
71 Scalar high = internal::random<Scalar>(-500,500);
72 Scalar low = (
size == 1 ? high : internal::random<Scalar>(-500,500));
76 if(internal::random<float>(0.
f,1.
f)<0.05f)
79 else if(
size>2 && std::numeric_limits<RealScalar>::max_exponent10>0 && internal::random<float>(0.
f,1.
f)<0.1f)
86 m.setLinSpaced(
size,low,high);
107 n(
i) =
size==1 ? low : low +
Scalar((
double(range_length+1)*
double(
i))/
double(
size));
111 m = VectorType::LinSpaced(
size,low,high);
135 row_vector.setLinSpaced(
size,low,high);
136 col_vector.setLinSpaced(
size,low,high);
142 size_changer.setLinSpaced(
size,low,high);
147 scalar.setLinSpaced(1,low,high);
149 VERIFY_IS_APPROX( ScalarMatrix::LinSpaced(1,low,high), ScalarMatrix::Constant(high) );
153 m.tail(
size-1).setLinSpaced(low, high);
159 Index n0 = VectorType::SizeAtCompileTime==
Dynamic ? 0 : VectorType::SizeAtCompileTime;
160 low = internal::random<Scalar>();
161 m = VectorType::LinSpaced(n0,low,low-
RealScalar(1));
164 if(VectorType::SizeAtCompileTime==
Dynamic)
170 m.setLinSpaced(n0,0,
Scalar(n0-1));
177 m.setLinSpaced(
size,low,low);
184 if(VectorType::SizeAtCompileTime==
Dynamic)
187 for(
Index k=1; k<5; ++k)
190 for(
Index k=1; k<5; ++k)
199 for(
Index k=0; k<10; ++k)
201 Index i = internal::random<Index>(0,
m.size()-1);
205 if(VectorType::SizeAtCompileTime==
Dynamic)
207 Index i = internal::random<Index>(0,2*
m.size()-1);
208 m.setUnit(2*
m.size(),
i);
215 template<
typename MatrixType>
226 s1 = internal::random<Scalar>();
253 Array4d
x4 = Array4d::LinSpaced(0.0, 1.0);
254 Array3d
x3(Array4d::LinSpaced(0.0, 1.0).
head(3));
264 a1.setLinSpaced(
n, 0,
n-1);
265 for(
int i=0;
i<
n; ++
i)
274 VERIFY(( internal::has_nullary_operator<internal::scalar_constant_op<double> >::
value ));
275 VERIFY(( !internal::has_unary_operator<internal::scalar_constant_op<double> >::
value ));
276 VERIFY(( !internal::has_binary_operator<internal::scalar_constant_op<double> >::
value ));
277 VERIFY(( internal::functor_has_linear_access<internal::scalar_constant_op<double> >::
ret ));
279 VERIFY(( !internal::has_nullary_operator<internal::scalar_identity_op<double> >::
value ));
280 VERIFY(( !internal::has_unary_operator<internal::scalar_identity_op<double> >::
value ));
281 VERIFY(( internal::has_binary_operator<internal::scalar_identity_op<double> >::
value ));
282 VERIFY(( !internal::functor_has_linear_access<internal::scalar_identity_op<double> >::
ret ));
284 VERIFY(( !internal::has_nullary_operator<internal::linspaced_op<float> >::
value ));
285 VERIFY(( internal::has_unary_operator<internal::linspaced_op<float> >::
value ));
286 VERIFY(( !internal::has_binary_operator<internal::linspaced_op<float> >::
value ));
287 VERIFY(( internal::functor_has_linear_access<internal::linspaced_op<float> >::
ret ));
293 MatrixXf
A = MatrixXf::Random(3,3);
299 VectorXi
V = VectorXi::Random(3);
303 VERIFY(( internal::has_nullary_operator<internal::scalar_constant_op<float> >::
value ));
304 VERIFY(( !internal::has_unary_operator<internal::scalar_constant_op<float> >::
value ));
305 VERIFY(( !internal::has_binary_operator<internal::scalar_constant_op<float> >::
value ));
306 VERIFY(( internal::functor_has_linear_access<internal::scalar_constant_op<float> >::
ret ));
308 VERIFY(( !internal::has_nullary_operator<internal::linspaced_op<int> >::
value ));
309 VERIFY(( internal::has_unary_operator<internal::linspaced_op<int> >::
value ));
310 VERIFY(( !internal::has_binary_operator<internal::linspaced_op<int> >::
value ));
311 VERIFY(( internal::functor_has_linear_access<internal::linspaced_op<int> >::
ret ));