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
@@ -11,24 +11,20 @@
|
||||
#include <unsupported/Eigen/MatrixFunctions>
|
||||
|
||||
// For complex matrices, any matrix is fine.
|
||||
template<typename MatrixType, int IsComplex = NumTraits<typename internal::traits<MatrixType>::Scalar>::IsComplex>
|
||||
struct processTriangularMatrix
|
||||
{
|
||||
static void run(MatrixType&, MatrixType&, const MatrixType&)
|
||||
{ }
|
||||
template <typename MatrixType, int IsComplex = NumTraits<typename internal::traits<MatrixType>::Scalar>::IsComplex>
|
||||
struct processTriangularMatrix {
|
||||
static void run(MatrixType&, MatrixType&, const MatrixType&) {}
|
||||
};
|
||||
|
||||
// For real matrices, make sure none of the eigenvalues are negative.
|
||||
template<typename MatrixType>
|
||||
struct processTriangularMatrix<MatrixType,0>
|
||||
{
|
||||
static void run(MatrixType& m, MatrixType& T, const MatrixType& U)
|
||||
{
|
||||
template <typename MatrixType>
|
||||
struct processTriangularMatrix<MatrixType, 0> {
|
||||
static void run(MatrixType& m, MatrixType& T, const MatrixType& U) {
|
||||
const Index size = m.cols();
|
||||
|
||||
for (Index i=0; i < size; ++i) {
|
||||
if (i == size - 1 || T.coeff(i+1,i) == 0)
|
||||
T.coeffRef(i,i) = std::abs(T.coeff(i,i));
|
||||
for (Index i = 0; i < size; ++i) {
|
||||
if (i == size - 1 || T.coeff(i + 1, i) == 0)
|
||||
T.coeffRef(i, i) = std::abs(T.coeff(i, i));
|
||||
else
|
||||
++i;
|
||||
}
|
||||
@@ -40,10 +36,8 @@ template <typename MatrixType, int IsComplex = NumTraits<typename internal::trai
|
||||
struct generateTestMatrix;
|
||||
|
||||
template <typename MatrixType>
|
||||
struct generateTestMatrix<MatrixType,0>
|
||||
{
|
||||
static void run(MatrixType& result, typename MatrixType::Index size)
|
||||
{
|
||||
struct generateTestMatrix<MatrixType, 0> {
|
||||
static void run(MatrixType& result, typename MatrixType::Index size) {
|
||||
result = MatrixType::Random(size, size);
|
||||
RealSchur<MatrixType> schur(result);
|
||||
MatrixType T = schur.matrixT();
|
||||
@@ -52,16 +46,11 @@ struct generateTestMatrix<MatrixType,0>
|
||||
};
|
||||
|
||||
template <typename MatrixType>
|
||||
struct generateTestMatrix<MatrixType,1>
|
||||
{
|
||||
static void run(MatrixType& result, typename MatrixType::Index size)
|
||||
{
|
||||
result = MatrixType::Random(size, size);
|
||||
}
|
||||
struct generateTestMatrix<MatrixType, 1> {
|
||||
static void run(MatrixType& result, typename MatrixType::Index size) { result = MatrixType::Random(size, size); }
|
||||
};
|
||||
|
||||
template <typename Derived, typename OtherDerived>
|
||||
typename Derived::RealScalar relerr(const MatrixBase<Derived>& A, const MatrixBase<OtherDerived>& B)
|
||||
{
|
||||
typename Derived::RealScalar relerr(const MatrixBase<Derived>& A, const MatrixBase<OtherDerived>& B) {
|
||||
return std::sqrt((A - B).cwiseAbs2().sum() / (std::min)(A.cwiseAbs2().sum(), B.cwiseAbs2().sum()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user