mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-10 18:59:01 +08:00
* Fix a compilation issue with large fixed-size matrices: the unrollers were always instanciated.
* the unrolling limits are configurable at compile time.
This commit is contained in:
parent
861c6f4c9b
commit
8e0d548039
@ -5,12 +5,12 @@
|
|||||||
//
|
//
|
||||||
// Eigen is free software; you can redistribute it and/or
|
// Eigen is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
// License as published by the Free Software Foundation; either
|
// License as published by the Free Software Foundation; either
|
||||||
// version 3 of the License, or (at your option) any later version.
|
// version 3 of the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Alternatively, you can redistribute it and/or
|
// Alternatively, you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU General Public License as
|
||||||
// published by the Free Software Foundation; either version 2 of
|
// published by the Free Software Foundation; either version 2 of
|
||||||
// the License, or (at your option) any later version.
|
// the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
@ -18,7 +18,7 @@
|
|||||||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ struct DotUnroller<Index, 0, Derived1, Derived2>
|
|||||||
/** \returns the dot product of *this with other.
|
/** \returns the dot product of *this with other.
|
||||||
*
|
*
|
||||||
* \only_for_vectors
|
* \only_for_vectors
|
||||||
*
|
*
|
||||||
* \note If the scalar type is complex numbers, then this function returns the hermitian
|
* \note If the scalar type is complex numbers, then this function returns the hermitian
|
||||||
* (sesquilinear) dot product, linear in the first variable and anti-linear in the
|
* (sesquilinear) dot product, linear in the first variable and anti-linear in the
|
||||||
* second variable.
|
* second variable.
|
||||||
@ -77,8 +77,9 @@ Scalar MatrixBase<Scalar, Derived>::dot(const MatrixBase<Scalar, OtherDerived>&
|
|||||||
Scalar res;
|
Scalar res;
|
||||||
if(EIGEN_UNROLLED_LOOPS
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
&& Traits::SizeAtCompileTime != Dynamic
|
&& Traits::SizeAtCompileTime != Dynamic
|
||||||
&& Traits::SizeAtCompileTime <= 16)
|
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||||
DotUnroller<Traits::SizeAtCompileTime-1, Traits::SizeAtCompileTime,
|
DotUnroller<Traits::SizeAtCompileTime-1,
|
||||||
|
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::SizeAtCompileTime : Dynamic,
|
||||||
Derived, MatrixBase<Scalar, OtherDerived> >
|
Derived, MatrixBase<Scalar, OtherDerived> >
|
||||||
::run(*static_cast<const Derived*>(this), other, res);
|
::run(*static_cast<const Derived*>(this), other, res);
|
||||||
else
|
else
|
||||||
|
@ -49,6 +49,8 @@
|
|||||||
cout << x.row(0) << endl;
|
cout << x.row(0) << endl;
|
||||||
}
|
}
|
||||||
* \endcode
|
* \endcode
|
||||||
|
*
|
||||||
|
* \nosubgrouping
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived> class MatrixBase
|
template<typename Scalar, typename Derived> class MatrixBase
|
||||||
{
|
{
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
//
|
//
|
||||||
// Eigen is free software; you can redistribute it and/or
|
// Eigen is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
// License as published by the Free Software Foundation; either
|
// License as published by the Free Software Foundation; either
|
||||||
// version 3 of the License, or (at your option) any later version.
|
// version 3 of the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Alternatively, you can redistribute it and/or
|
// Alternatively, you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU General Public License as
|
||||||
// published by the Free Software Foundation; either version 2 of
|
// published by the Free Software Foundation; either version 2 of
|
||||||
// the License, or (at your option) any later version.
|
// the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
@ -19,7 +19,7 @@
|
|||||||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
@ -106,9 +106,12 @@ Derived& MatrixBase<Scalar, Derived>
|
|||||||
// copying a vector expression into a vector
|
// copying a vector expression into a vector
|
||||||
{
|
{
|
||||||
assert(size() == other.size());
|
assert(size() == other.size());
|
||||||
if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25)
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
|
&& Traits::SizeAtCompileTime != Dynamic
|
||||||
|
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL)
|
||||||
VectorOperatorEqualsUnroller
|
VectorOperatorEqualsUnroller
|
||||||
<Derived, OtherDerived, Traits::SizeAtCompileTime>::run
|
<Derived, OtherDerived,
|
||||||
|
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? Traits::SizeAtCompileTime : Dynamic>::run
|
||||||
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
||||||
else
|
else
|
||||||
for(int i = 0; i < size(); i++)
|
for(int i = 0; i < size(); i++)
|
||||||
@ -120,10 +123,11 @@ Derived& MatrixBase<Scalar, Derived>
|
|||||||
assert(rows() == other.rows() && cols() == other.cols());
|
assert(rows() == other.rows() && cols() == other.cols());
|
||||||
if(EIGEN_UNROLLED_LOOPS
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
&& Traits::SizeAtCompileTime != Dynamic
|
&& Traits::SizeAtCompileTime != Dynamic
|
||||||
&& Traits::SizeAtCompileTime <= 25)
|
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL)
|
||||||
{
|
{
|
||||||
MatrixOperatorEqualsUnroller
|
MatrixOperatorEqualsUnroller
|
||||||
<Derived, OtherDerived, Traits::SizeAtCompileTime>::run
|
<Derived, OtherDerived,
|
||||||
|
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? Traits::SizeAtCompileTime : Dynamic>::run
|
||||||
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -106,9 +106,10 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
|||||||
Scalar res;
|
Scalar res;
|
||||||
if(EIGEN_UNROLLED_LOOPS
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
&& Lhs::Traits::ColsAtCompileTime != Dynamic
|
&& Lhs::Traits::ColsAtCompileTime != Dynamic
|
||||||
&& Lhs::Traits::ColsAtCompileTime <= 16)
|
&& Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||||
ProductUnroller<Lhs::Traits::ColsAtCompileTime-1,
|
ProductUnroller<Lhs::Traits::ColsAtCompileTime-1,
|
||||||
Lhs::Traits::ColsAtCompileTime, LhsRef, RhsRef>
|
Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Lhs::Traits::ColsAtCompileTime : Dynamic,
|
||||||
|
LhsRef, RhsRef>
|
||||||
::run(row, col, m_lhs, m_rhs, res);
|
::run(row, col, m_lhs, m_rhs, res);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
//
|
//
|
||||||
// Eigen is free software; you can redistribute it and/or
|
// Eigen is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
// License as published by the Free Software Foundation; either
|
// License as published by the Free Software Foundation; either
|
||||||
// version 3 of the License, or (at your option) any later version.
|
// version 3 of the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Alternatively, you can redistribute it and/or
|
// Alternatively, you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU General Public License as
|
||||||
// published by the Free Software Foundation; either version 2 of
|
// published by the Free Software Foundation; either version 2 of
|
||||||
// the License, or (at your option) any later version.
|
// the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
@ -18,7 +18,7 @@
|
|||||||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
@ -61,8 +61,11 @@ Scalar MatrixBase<Scalar, Derived>::trace() const
|
|||||||
{
|
{
|
||||||
assert(rows() == cols());
|
assert(rows() == cols());
|
||||||
Scalar res;
|
Scalar res;
|
||||||
if(EIGEN_UNROLLED_LOOPS && Traits::RowsAtCompileTime != Dynamic && Traits::RowsAtCompileTime <= 16)
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
TraceUnroller<Traits::RowsAtCompileTime-1, Traits::RowsAtCompileTime, Derived>
|
&& Traits::RowsAtCompileTime != Dynamic
|
||||||
|
&& Traits::RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||||
|
TraceUnroller<Traits::RowsAtCompileTime-1,
|
||||||
|
Traits::RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::RowsAtCompileTime : Dynamic, Derived>
|
||||||
::run(*static_cast<const Derived*>(this), res);
|
::run(*static_cast<const Derived*>(this), res);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
//
|
//
|
||||||
// Eigen is free software; you can redistribute it and/or
|
// Eigen is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
// License as published by the Free Software Foundation; either
|
// License as published by the Free Software Foundation; either
|
||||||
// version 3 of the License, or (at your option) any later version.
|
// version 3 of the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Alternatively, you can redistribute it and/or
|
// Alternatively, you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU General Public License as
|
||||||
// published by the Free Software Foundation; either version 2 of
|
// published by the Free Software Foundation; either version 2 of
|
||||||
// the License, or (at your option) any later version.
|
// the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
@ -18,7 +18,7 @@
|
|||||||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
@ -31,6 +31,20 @@
|
|||||||
#define EIGEN_UNROLLED_LOOPS (true)
|
#define EIGEN_UNROLLED_LOOPS (true)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Defines the maximal loop size (i.e., the matrix size NxM) to enable
|
||||||
|
* meta unrolling of operator=.
|
||||||
|
*/
|
||||||
|
#ifndef EIGEN_UNROLLING_LIMIT_OPEQUAL
|
||||||
|
#define EIGEN_UNROLLING_LIMIT_OPEQUAL 25
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Defines the maximal loop size to enable meta unrolling
|
||||||
|
* of the matrix product, dot product and trace.
|
||||||
|
*/
|
||||||
|
#ifndef EIGEN_UNROLLING_LIMIT_PRODUCT
|
||||||
|
#define EIGEN_UNROLLING_LIMIT_PRODUCT 16
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
|
#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
|
||||||
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor
|
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor
|
||||||
#else
|
#else
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
//
|
//
|
||||||
// Eigen is free software; you can redistribute it and/or
|
// Eigen is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
// License as published by the Free Software Foundation; either
|
// License as published by the Free Software Foundation; either
|
||||||
// version 3 of the License, or (at your option) any later version.
|
// version 3 of the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Alternatively, you can redistribute it and/or
|
// Alternatively, you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU General Public License as
|
||||||
// published by the Free Software Foundation; either version 2 of
|
// published by the Free Software Foundation; either version 2 of
|
||||||
// the License, or (at your option) any later version.
|
// the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
@ -18,7 +18,7 @@
|
|||||||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
|||||||
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
||||||
int rows = m.rows();
|
int rows = m.rows();
|
||||||
int cols = m.cols();
|
int cols = m.cols();
|
||||||
|
|
||||||
MatrixType m1 = MatrixType::random(rows, cols),
|
MatrixType m1 = MatrixType::random(rows, cols),
|
||||||
m2 = MatrixType::random(rows, cols),
|
m2 = MatrixType::random(rows, cols),
|
||||||
m3(rows, cols),
|
m3(rows, cols),
|
||||||
@ -52,18 +52,18 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
|||||||
|
|
||||||
Scalar s1 = ei_random<Scalar>(),
|
Scalar s1 = ei_random<Scalar>(),
|
||||||
s2 = ei_random<Scalar>();
|
s2 = ei_random<Scalar>();
|
||||||
|
|
||||||
// check involutivity of adjoint, transpose, conjugate
|
// check involutivity of adjoint, transpose, conjugate
|
||||||
VERIFY_IS_APPROX(m1.transpose().transpose(), m1);
|
VERIFY_IS_APPROX(m1.transpose().transpose(), m1);
|
||||||
VERIFY_IS_APPROX(m1.conjugate().conjugate(), m1);
|
VERIFY_IS_APPROX(m1.conjugate().conjugate(), m1);
|
||||||
VERIFY_IS_APPROX(m1.adjoint().adjoint(), m1);
|
VERIFY_IS_APPROX(m1.adjoint().adjoint(), m1);
|
||||||
|
|
||||||
// check basic compatibility of adjoint, transpose, conjugate
|
// check basic compatibility of adjoint, transpose, conjugate
|
||||||
VERIFY_IS_APPROX(m1.transpose().conjugate().adjoint(), m1);
|
VERIFY_IS_APPROX(m1.transpose().conjugate().adjoint(), m1);
|
||||||
VERIFY_IS_APPROX(m1.adjoint().conjugate().transpose(), m1);
|
VERIFY_IS_APPROX(m1.adjoint().conjugate().transpose(), m1);
|
||||||
if(!NumTraits<Scalar>::IsComplex)
|
if(!NumTraits<Scalar>::IsComplex)
|
||||||
VERIFY_IS_APPROX(m1.adjoint().transpose(), m1);
|
VERIFY_IS_APPROX(m1.adjoint().transpose(), m1);
|
||||||
|
|
||||||
// check multiplicative behavior
|
// check multiplicative behavior
|
||||||
VERIFY_IS_APPROX((m1.transpose() * m2).transpose(), m2.transpose() * m1);
|
VERIFY_IS_APPROX((m1.transpose() * m2).transpose(), m2.transpose() * m1);
|
||||||
VERIFY_IS_APPROX((m1.adjoint() * m2).adjoint(), m2.adjoint() * m1);
|
VERIFY_IS_APPROX((m1.adjoint() * m2).adjoint(), m2.adjoint() * m1);
|
||||||
@ -71,7 +71,7 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
|||||||
VERIFY_IS_APPROX((s1 * m1).transpose(), s1 * m1.transpose());
|
VERIFY_IS_APPROX((s1 * m1).transpose(), s1 * m1.transpose());
|
||||||
VERIFY_IS_APPROX((s1 * m1).conjugate(), ei_conj(s1) * m1.conjugate());
|
VERIFY_IS_APPROX((s1 * m1).conjugate(), ei_conj(s1) * m1.conjugate());
|
||||||
VERIFY_IS_APPROX((s1 * m1).adjoint(), ei_conj(s1) * m1.adjoint());
|
VERIFY_IS_APPROX((s1 * m1).adjoint(), ei_conj(s1) * m1.adjoint());
|
||||||
|
|
||||||
// check basic properties of dot, norm, norm2
|
// check basic properties of dot, norm, norm2
|
||||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
VERIFY_IS_APPROX((s1 * v1 + s2 * v2).dot(v3), s1 * v1.dot(v3) + s2 * v2.dot(v3));
|
VERIFY_IS_APPROX((s1 * v1 + s2 * v2).dot(v3), s1 * v1.dot(v3) + s2 * v2.dot(v3));
|
||||||
@ -83,16 +83,16 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
|||||||
VERIFY_IS_MUCH_SMALLER_THAN(ei_abs(vzero.dot(v1)), static_cast<RealScalar>(1));
|
VERIFY_IS_MUCH_SMALLER_THAN(ei_abs(vzero.dot(v1)), static_cast<RealScalar>(1));
|
||||||
if(NumTraits<Scalar>::HasFloatingPoint)
|
if(NumTraits<Scalar>::HasFloatingPoint)
|
||||||
VERIFY_IS_MUCH_SMALLER_THAN(vzero.norm(), static_cast<RealScalar>(1));
|
VERIFY_IS_MUCH_SMALLER_THAN(vzero.norm(), static_cast<RealScalar>(1));
|
||||||
|
|
||||||
// check compatibility of dot and adjoint
|
// check compatibility of dot and adjoint
|
||||||
VERIFY_IS_APPROX(v1.dot(square * v2), (square.adjoint() * v1).dot(v2));
|
VERIFY_IS_APPROX(v1.dot(square * v2), (square.adjoint() * v1).dot(v2));
|
||||||
|
|
||||||
// like in testBasicStuff, test operator() to check const-qualification
|
// like in testBasicStuff, test operator() to check const-qualification
|
||||||
int r = ei_random<int>(0, rows-1),
|
int r = ei_random<int>(0, rows-1),
|
||||||
c = ei_random<int>(0, cols-1);
|
c = ei_random<int>(0, cols-1);
|
||||||
VERIFY_IS_APPROX(m1.conjugate()(r,c), ei_conj(m1(r,c)));
|
VERIFY_IS_APPROX(m1.conjugate()(r,c), ei_conj(m1(r,c)));
|
||||||
VERIFY_IS_APPROX(m1.adjoint()(c,r), ei_conj(m1(r,c)));
|
VERIFY_IS_APPROX(m1.adjoint()(c,r), ei_conj(m1(r,c)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EigenTest::testAdjoint()
|
void EigenTest::testAdjoint()
|
||||||
@ -104,6 +104,8 @@ void EigenTest::testAdjoint()
|
|||||||
adjoint(MatrixXi(8, 12));
|
adjoint(MatrixXi(8, 12));
|
||||||
adjoint(MatrixXcd(20, 20));
|
adjoint(MatrixXcd(20, 20));
|
||||||
}
|
}
|
||||||
|
// test a large matrix only once
|
||||||
|
adjoint(Matrix<float, 100, 100>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Eigen
|
} // namespace Eigen
|
||||||
|
@ -89,6 +89,7 @@ void EigenTest::testBasicStuff()
|
|||||||
basicStuff(MatrixXcf(3, 3));
|
basicStuff(MatrixXcf(3, 3));
|
||||||
basicStuff(MatrixXi(8, 12));
|
basicStuff(MatrixXi(8, 12));
|
||||||
basicStuff(MatrixXcd(20, 20));
|
basicStuff(MatrixXcd(20, 20));
|
||||||
|
basicStuff(Matrix<float, 100, 100>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
//
|
//
|
||||||
// Eigen is free software; you can redistribute it and/or
|
// Eigen is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
// License as published by the Free Software Foundation; either
|
// License as published by the Free Software Foundation; either
|
||||||
// version 3 of the License, or (at your option) any later version.
|
// version 3 of the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Alternatively, you can redistribute it and/or
|
// Alternatively, you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU General Public License as
|
||||||
// published by the Free Software Foundation; either version 2 of
|
// published by the Free Software Foundation; either version 2 of
|
||||||
// the License, or (at your option) any later version.
|
// the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
@ -18,7 +18,7 @@
|
|||||||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
@ -34,10 +34,10 @@ template<typename MatrixType> void product(const MatrixType& m)
|
|||||||
|
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
||||||
|
|
||||||
int rows = m.rows();
|
int rows = m.rows();
|
||||||
int cols = m.cols();
|
int cols = m.cols();
|
||||||
|
|
||||||
// this test relies a lot on Random.h, and there's not much more that we can do
|
// this test relies a lot on Random.h, and there's not much more that we can do
|
||||||
// to test it, hence I consider that we will have tested Random.h
|
// to test it, hence I consider that we will have tested Random.h
|
||||||
MatrixType m1 = MatrixType::random(rows, cols),
|
MatrixType m1 = MatrixType::random(rows, cols),
|
||||||
@ -53,10 +53,10 @@ template<typename MatrixType> void product(const MatrixType& m)
|
|||||||
vzero = VectorType::zero(rows);
|
vzero = VectorType::zero(rows);
|
||||||
|
|
||||||
Scalar s1 = ei_random<Scalar>();
|
Scalar s1 = ei_random<Scalar>();
|
||||||
|
|
||||||
int r = ei_random<int>(0, rows-1),
|
int r = ei_random<int>(0, rows-1),
|
||||||
c = ei_random<int>(0, cols-1);
|
c = ei_random<int>(0, cols-1);
|
||||||
|
|
||||||
// begin testing Product.h: only associativity for now
|
// begin testing Product.h: only associativity for now
|
||||||
// (we use Transpose.h but this doesn't count as a test for it)
|
// (we use Transpose.h but this doesn't count as a test for it)
|
||||||
VERIFY_IS_APPROX((m1*m1.transpose())*m2, m1*(m1.transpose()*m2));
|
VERIFY_IS_APPROX((m1*m1.transpose())*m2, m1*(m1.transpose()*m2));
|
||||||
@ -64,20 +64,20 @@ template<typename MatrixType> void product(const MatrixType& m)
|
|||||||
m3 *= (m1.transpose() * m2);
|
m3 *= (m1.transpose() * m2);
|
||||||
VERIFY_IS_APPROX(m3, m1*(m1.transpose()*m2));
|
VERIFY_IS_APPROX(m3, m1*(m1.transpose()*m2));
|
||||||
VERIFY_IS_APPROX(m3, m1.lazyProduct(m1.transpose()*m2));
|
VERIFY_IS_APPROX(m3, m1.lazyProduct(m1.transpose()*m2));
|
||||||
|
|
||||||
// continue testing Product.h: distributivity
|
// continue testing Product.h: distributivity
|
||||||
VERIFY_IS_APPROX(square*(m1 + m2), square*m1+square*m2);
|
VERIFY_IS_APPROX(square*(m1 + m2), square*m1+square*m2);
|
||||||
VERIFY_IS_APPROX(square*(m1 - m2), square*m1-square*m2);
|
VERIFY_IS_APPROX(square*(m1 - m2), square*m1-square*m2);
|
||||||
|
|
||||||
// continue testing Product.h: compatibility with ScalarMultiple.h
|
// continue testing Product.h: compatibility with ScalarMultiple.h
|
||||||
VERIFY_IS_APPROX(s1*(square*m1), (s1*square)*m1);
|
VERIFY_IS_APPROX(s1*(square*m1), (s1*square)*m1);
|
||||||
VERIFY_IS_APPROX(s1*(square*m1), square*(m1*s1));
|
VERIFY_IS_APPROX(s1*(square*m1), square*(m1*s1));
|
||||||
|
|
||||||
// continue testing Product.h: lazyProduct
|
// continue testing Product.h: lazyProduct
|
||||||
VERIFY_IS_APPROX(square.lazyProduct(m1), square*m1);
|
VERIFY_IS_APPROX(square.lazyProduct(m1), square*m1);
|
||||||
// again, test operator() to check const-qualification
|
// again, test operator() to check const-qualification
|
||||||
s1 += square.lazyProduct(m1)(r,c);
|
s1 += square.lazyProduct(m1)(r,c);
|
||||||
|
|
||||||
// test Product.h together with Identity.h
|
// test Product.h together with Identity.h
|
||||||
VERIFY_IS_APPROX(m1, identity*m1);
|
VERIFY_IS_APPROX(m1, identity*m1);
|
||||||
VERIFY_IS_APPROX(v1, identity*v1);
|
VERIFY_IS_APPROX(v1, identity*v1);
|
||||||
@ -94,6 +94,9 @@ void EigenTest::testProduct()
|
|||||||
product(MatrixXi(8, 12));
|
product(MatrixXi(8, 12));
|
||||||
product(MatrixXcd(20, 20));
|
product(MatrixXcd(20, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test a large matrix only once
|
||||||
|
product(Matrix<float, 100, 100>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Eigen
|
} // namespace Eigen
|
||||||
|
Loading…
x
Reference in New Issue
Block a user