mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -15,17 +15,16 @@
|
||||
using Eigen::MatrixXf;
|
||||
using Eigen::Tensor;
|
||||
|
||||
static void test_simple()
|
||||
{
|
||||
MatrixXf m1(3,3);
|
||||
MatrixXf m2(3,3);
|
||||
static void test_simple() {
|
||||
MatrixXf m1(3, 3);
|
||||
MatrixXf m2(3, 3);
|
||||
m1.setRandom();
|
||||
m2.setRandom();
|
||||
|
||||
TensorMap<Tensor<float, 2> > mat1(m1.data(), 3,3);
|
||||
TensorMap<Tensor<float, 2> > mat2(m2.data(), 3,3);
|
||||
TensorMap<Tensor<float, 2> > mat1(m1.data(), 3, 3);
|
||||
TensorMap<Tensor<float, 2> > mat2(m2.data(), 3, 3);
|
||||
|
||||
Tensor<float, 2> mat3(3,3);
|
||||
Tensor<float, 2> mat3(3, 3);
|
||||
mat3 = mat1;
|
||||
|
||||
typedef Tensor<float, 1>::DimensionPair DimPair;
|
||||
@@ -34,21 +33,19 @@ static void test_simple()
|
||||
|
||||
mat3 = mat3.contract(mat2, dims).eval();
|
||||
|
||||
VERIFY_IS_APPROX(mat3(0, 0), (m1*m2).eval()(0,0));
|
||||
VERIFY_IS_APPROX(mat3(0, 1), (m1*m2).eval()(0,1));
|
||||
VERIFY_IS_APPROX(mat3(0, 2), (m1*m2).eval()(0,2));
|
||||
VERIFY_IS_APPROX(mat3(1, 0), (m1*m2).eval()(1,0));
|
||||
VERIFY_IS_APPROX(mat3(1, 1), (m1*m2).eval()(1,1));
|
||||
VERIFY_IS_APPROX(mat3(1, 2), (m1*m2).eval()(1,2));
|
||||
VERIFY_IS_APPROX(mat3(2, 0), (m1*m2).eval()(2,0));
|
||||
VERIFY_IS_APPROX(mat3(2, 1), (m1*m2).eval()(2,1));
|
||||
VERIFY_IS_APPROX(mat3(2, 2), (m1*m2).eval()(2,2));
|
||||
VERIFY_IS_APPROX(mat3(0, 0), (m1 * m2).eval()(0, 0));
|
||||
VERIFY_IS_APPROX(mat3(0, 1), (m1 * m2).eval()(0, 1));
|
||||
VERIFY_IS_APPROX(mat3(0, 2), (m1 * m2).eval()(0, 2));
|
||||
VERIFY_IS_APPROX(mat3(1, 0), (m1 * m2).eval()(1, 0));
|
||||
VERIFY_IS_APPROX(mat3(1, 1), (m1 * m2).eval()(1, 1));
|
||||
VERIFY_IS_APPROX(mat3(1, 2), (m1 * m2).eval()(1, 2));
|
||||
VERIFY_IS_APPROX(mat3(2, 0), (m1 * m2).eval()(2, 0));
|
||||
VERIFY_IS_APPROX(mat3(2, 1), (m1 * m2).eval()(2, 1));
|
||||
VERIFY_IS_APPROX(mat3(2, 2), (m1 * m2).eval()(2, 2));
|
||||
}
|
||||
|
||||
|
||||
static void test_const()
|
||||
{
|
||||
MatrixXf input(3,3);
|
||||
static void test_const() {
|
||||
MatrixXf input(3, 3);
|
||||
input.setRandom();
|
||||
MatrixXf output = input;
|
||||
output.rowwise() -= input.colwise().maxCoeff();
|
||||
@@ -62,7 +59,8 @@ static void test_const()
|
||||
bcast[0] = 3;
|
||||
bcast[1] = 1;
|
||||
const TensorMap<const Tensor<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));
|
||||
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) {
|
||||
@@ -71,9 +69,7 @@ static void test_const()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_forced_eval)
|
||||
{
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_forced_eval) {
|
||||
CALL_SUBTEST(test_simple());
|
||||
CALL_SUBTEST(test_const());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user