| 327 | } |
| 328 | |
| 329 | void test_array() |
| 330 | { |
| 331 | typedef Array<bfloat16,1,Dynamic> ArrayXh; |
| 332 | Index size = internal::random<Index>(1,10); |
| 333 | Index i = internal::random<Index>(0,size-1); |
| 334 | ArrayXh a1 = ArrayXh::Random(size), a2 = ArrayXh::Random(size); |
| 335 | VERIFY_IS_APPROX( a1+a1, bfloat16(2)*a1 ); |
| 336 | VERIFY( (a1.abs() >= bfloat16(0)).all() ); |
| 337 | VERIFY_IS_APPROX( (a1*a1).sqrt(), a1.abs() ); |
| 338 | |
| 339 | VERIFY( ((a1.min)(a2) <= (a1.max)(a2)).all() ); |
| 340 | a1(i) = bfloat16(-10.); |
| 341 | VERIFY_IS_EQUAL( a1.minCoeff(), bfloat16(-10.) ); |
| 342 | a1(i) = bfloat16(10.); |
| 343 | VERIFY_IS_EQUAL( a1.maxCoeff(), bfloat16(10.) ); |
| 344 | |
| 345 | std::stringstream ss; |
| 346 | ss << a1; |
| 347 | } |
| 348 | |
| 349 | void test_product() |
| 350 | { |