Clang-format tests, examples, libraries, benchmarks, etc.

This commit is contained in:
Antonio Sánchez
2023-12-05 21:22:55 +00:00
committed by Rasmus Munk Larsen
parent 3252ecc7a4
commit 46e9cdb7fe
876 changed files with 33453 additions and 37795 deletions

View File

@@ -9,8 +9,8 @@
#include "main.h"
template<typename MatrixType> void replicate(const MatrixType& m)
{
template <typename MatrixType>
void replicate(const MatrixType& m) {
/* this test covers the following files:
Replicate.cpp
*/
@@ -22,60 +22,52 @@ template<typename MatrixType> void replicate(const MatrixType& m)
Index rows = m.rows();
Index cols = m.cols();
MatrixType m1 = MatrixType::Random(rows, cols),
m2 = MatrixType::Random(rows, cols);
MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols);
VectorType v1 = VectorType::Random(rows);
MatrixX x1, x2;
VectorX vx1;
int f1 = internal::random<int>(1,10),
f2 = internal::random<int>(1,10);
int f1 = internal::random<int>(1, 10), f2 = internal::random<int>(1, 10);
x1.resize(rows*f1,cols*f2);
for(int j=0; j<f2; j++)
for(int i=0; i<f1; i++)
x1.block(i*rows,j*cols,rows,cols) = m1;
VERIFY_IS_APPROX(x1, m1.replicate(f1,f2));
x1.resize(rows * f1, cols * f2);
for (int j = 0; j < f2; j++)
for (int i = 0; i < f1; i++) x1.block(i * rows, j * cols, rows, cols) = m1;
VERIFY_IS_APPROX(x1, m1.replicate(f1, f2));
x2.resize(2*rows,3*cols);
x2 << m2, m2, m2,
m2, m2, m2;
VERIFY_IS_APPROX(x2, (m2.template replicate<2,3>()));
x2.resize(rows,3*cols);
x2.resize(2 * rows, 3 * cols);
x2 << m2, m2, m2, m2, m2, m2;
VERIFY_IS_APPROX(x2, (m2.template replicate<2, 3>()));
x2.resize(rows, 3 * cols);
x2 << m2, m2, m2;
VERIFY_IS_APPROX(x2, (m2.template replicate<1,3>()));
vx1.resize(3*rows,cols);
vx1 << m2, m2, m2;
VERIFY_IS_APPROX(vx1+vx1, vx1+(m2.template replicate<3,1>()));
vx1=m2+(m2.colwise().replicate(1));
if(m2.cols()==1)
VERIFY_IS_APPROX(m2.coeff(0), (m2.template replicate<3,1>().coeff(m2.rows())));
VERIFY_IS_APPROX(x2, (m2.template replicate<1, 3>()));
x2.resize(rows,f1);
for (int j=0; j<f1; ++j)
x2.col(j) = v1;
vx1.resize(3 * rows, cols);
vx1 << m2, m2, m2;
VERIFY_IS_APPROX(vx1 + vx1, vx1 + (m2.template replicate<3, 1>()));
vx1 = m2 + (m2.colwise().replicate(1));
if (m2.cols() == 1) VERIFY_IS_APPROX(m2.coeff(0), (m2.template replicate<3, 1>().coeff(m2.rows())));
x2.resize(rows, f1);
for (int j = 0; j < f1; ++j) x2.col(j) = v1;
VERIFY_IS_APPROX(x2, v1.rowwise().replicate(f1));
vx1.resize(rows*f2);
for (int j=0; j<f2; ++j)
vx1.segment(j*rows,rows) = v1;
vx1.resize(rows * f2);
for (int j = 0; j < f2; ++j) vx1.segment(j * rows, rows) = v1;
VERIFY_IS_APPROX(vx1, v1.colwise().replicate(f2));
}
EIGEN_DECLARE_TEST(array_replicate)
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( replicate(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( replicate(Vector2f()) );
CALL_SUBTEST_3( replicate(Vector3d()) );
CALL_SUBTEST_4( replicate(Vector4f()) );
CALL_SUBTEST_5( replicate(VectorXf(16)) );
CALL_SUBTEST_6( replicate(VectorXcd(10)) );
EIGEN_DECLARE_TEST(array_replicate) {
for (int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1(replicate(Matrix<float, 1, 1>()));
CALL_SUBTEST_2(replicate(Vector2f()));
CALL_SUBTEST_3(replicate(Vector3d()));
CALL_SUBTEST_4(replicate(Vector4f()));
CALL_SUBTEST_5(replicate(VectorXf(16)));
CALL_SUBTEST_6(replicate(VectorXcd(10)));
}
}