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,19 +9,18 @@
#include "main.h"
template<typename MatrixType> void trmv(const MatrixType& m)
{
template <typename MatrixType>
void trmv(const MatrixType& m) {
typedef typename MatrixType::Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
RealScalar largerEps = 10*test_precision<RealScalar>();
RealScalar largerEps = 10 * test_precision<RealScalar>();
Index rows = m.rows();
Index cols = m.cols();
MatrixType m1 = MatrixType::Random(rows, cols),
m3(rows, cols);
MatrixType m1 = MatrixType::Random(rows, cols), m3(rows, cols);
VectorType v1 = VectorType::Random(rows);
Scalar s1 = internal::random<Scalar>();
@@ -40,9 +39,11 @@ template<typename MatrixType> void trmv(const MatrixType& m)
// check conjugated and scalar multiple expressions (col-major)
m3 = m1.template triangularView<Eigen::Lower>();
VERIFY(((s1*m3).conjugate() * v1).isApprox((s1*m1).conjugate().template triangularView<Eigen::Lower>() * v1, largerEps));
VERIFY(((s1 * m3).conjugate() * v1)
.isApprox((s1 * m1).conjugate().template triangularView<Eigen::Lower>() * v1, largerEps));
m3 = m1.template triangularView<Eigen::Upper>();
VERIFY((m3.conjugate() * v1.conjugate()).isApprox(m1.conjugate().template triangularView<Eigen::Upper>() * v1.conjugate(), largerEps));
VERIFY((m3.conjugate() * v1.conjugate())
.isApprox(m1.conjugate().template triangularView<Eigen::Upper>() * v1.conjugate(), largerEps));
// check with a row-major matrix
m3 = m1.template triangularView<Eigen::Upper>();
@@ -58,33 +59,34 @@ template<typename MatrixType> void trmv(const MatrixType& m)
m3 = m1.template triangularView<Eigen::Upper>();
VERIFY((m3.adjoint() * v1).isApprox(m1.adjoint().template triangularView<Eigen::Lower>() * v1, largerEps));
m3 = m1.template triangularView<Eigen::Lower>();
VERIFY((m3.adjoint() * (s1*v1.conjugate())).isApprox(m1.adjoint().template triangularView<Eigen::Upper>() * (s1*v1.conjugate()), largerEps));
VERIFY((m3.adjoint() * (s1 * v1.conjugate()))
.isApprox(m1.adjoint().template triangularView<Eigen::Upper>() * (s1 * v1.conjugate()), largerEps));
m3 = m1.template triangularView<Eigen::UnitUpper>();
// check transposed cases:
m3 = m1.template triangularView<Eigen::Lower>();
VERIFY((v1.transpose() * m3).isApprox(v1.transpose() * m1.template triangularView<Eigen::Lower>(), largerEps));
VERIFY((v1.adjoint() * m3).isApprox(v1.adjoint() * m1.template triangularView<Eigen::Lower>(), largerEps));
VERIFY((v1.adjoint() * m3.adjoint()).isApprox(v1.adjoint() * m1.template triangularView<Eigen::Lower>().adjoint(), largerEps));
VERIFY((v1.adjoint() * m3.adjoint())
.isApprox(v1.adjoint() * m1.template triangularView<Eigen::Lower>().adjoint(), largerEps));
// TODO check with sub-matrices
}
EIGEN_DECLARE_TEST(product_trmv)
{
EIGEN_DECLARE_TEST(product_trmv) {
int s = 0;
for(int i = 0; i < g_repeat ; i++) {
CALL_SUBTEST_1( trmv(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( trmv(Matrix<float, 2, 2>()) );
CALL_SUBTEST_3( trmv(Matrix3d()) );
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2);
CALL_SUBTEST_4( trmv(MatrixXcf(s,s)) );
CALL_SUBTEST_5( trmv(MatrixXcd(s,s)) );
for (int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1(trmv(Matrix<float, 1, 1>()));
CALL_SUBTEST_2(trmv(Matrix<float, 2, 2>()));
CALL_SUBTEST_3(trmv(Matrix3d()));
s = internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2);
CALL_SUBTEST_4(trmv(MatrixXcf(s, s)));
CALL_SUBTEST_5(trmv(MatrixXcd(s, s)));
TEST_SET_BUT_UNUSED_VARIABLE(s)
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE);
CALL_SUBTEST_6( trmv(Matrix<float,Dynamic,Dynamic,RowMajor>(s, s)) );
s = internal::random<int>(1, EIGEN_TEST_MAX_SIZE);
CALL_SUBTEST_6(trmv(Matrix<float, Dynamic, Dynamic, RowMajor>(s, s)));
TEST_SET_BUT_UNUSED_VARIABLE(s)
}
}