mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Created many additional tests
This commit is contained in:
@@ -45,7 +45,34 @@ static void test_simple()
|
||||
}
|
||||
|
||||
|
||||
static void test_const()
|
||||
{
|
||||
MatrixXf input(3,3);
|
||||
input.setRandom();
|
||||
MatrixXf output = input;
|
||||
output.rowwise() -= input.colwise().maxCoeff();
|
||||
|
||||
Eigen::array<int, 1> depth_dim;
|
||||
depth_dim[0] = 0;
|
||||
Tensor<float, 2>::Dimensions dims2d;
|
||||
dims2d[0] = 1;
|
||||
dims2d[1] = 3;
|
||||
Eigen::array<int, 2> bcast;
|
||||
bcast[0] = 3;
|
||||
bcast[1] = 1;
|
||||
const TensorMap<Tensor<const float, 2>> input_tensor(input.data(), 3, 3);
|
||||
Tensor<float, 2> output_tensor= (input_tensor - input_tensor.maximum(depth_dim).eval().reshape(dims2d).broadcast(bcast));
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
VERIFY_IS_APPROX(output(i, j), output_tensor(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_cxx11_tensor_forced_eval()
|
||||
{
|
||||
CALL_SUBTEST(test_simple());
|
||||
CALL_SUBTEST(test_const());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user