| 195 | |
| 196 | template<typename MatrixType> |
| 197 | void testMatrixType(const MatrixType& m) |
| 198 | { |
| 199 | using std::abs; |
| 200 | const Index rows = m.rows(); |
| 201 | const Index cols = m.cols(); |
| 202 | typedef typename MatrixType::Scalar Scalar; |
| 203 | typedef typename MatrixType::RealScalar RealScalar; |
| 204 | |
| 205 | Scalar s1; |
| 206 | do { |
| 207 | s1 = internal::random<Scalar>(); |
| 208 | } while(abs(s1)<RealScalar(1e-5) && (!NumTraits<Scalar>::IsInteger)); |
| 209 | |
| 210 | MatrixType A; |
| 211 | A.setIdentity(rows, cols); |
| 212 | VERIFY(equalsIdentity(A)); |
| 213 | VERIFY(equalsIdentity(MatrixType::Identity(rows, cols))); |
| 214 | |
| 215 | |
| 216 | A = MatrixType::Constant(rows,cols,s1); |
| 217 | Index i = internal::random<Index>(0,rows-1); |
| 218 | Index j = internal::random<Index>(0,cols-1); |
| 219 | VERIFY_IS_APPROX( MatrixType::Constant(rows,cols,s1)(i,j), s1 ); |
| 220 | VERIFY_IS_APPROX( MatrixType::Constant(rows,cols,s1).coeff(i,j), s1 ); |
| 221 | VERIFY_IS_APPROX( A(i,j), s1 ); |
| 222 | } |
| 223 | |
| 224 | void test_nullary() |
| 225 | { |