2008-12-23 03:17:44 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
2009-05-23 02:25:33 +08:00
|
|
|
// for linear algebra.
|
2008-12-23 03:17:44 +08:00
|
|
|
//
|
2015-10-06 23:24:01 +08:00
|
|
|
// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2008-12-23 03:17:44 +08:00
|
|
|
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
|
|
|
|
//
|
2012-07-14 02:42:47 +08:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2008-12-23 03:17:44 +08:00
|
|
|
|
2018-07-26 06:01:24 +08:00
|
|
|
#if defined(EIGEN_TEST_PART_7)
|
2009-11-13 04:02:52 +08:00
|
|
|
|
2009-01-15 21:30:50 +08:00
|
|
|
#ifndef EIGEN_NO_STATIC_ASSERT
|
2008-12-23 03:17:44 +08:00
|
|
|
#define EIGEN_NO_STATIC_ASSERT // turn static asserts into runtime asserts in order to check them
|
2009-01-15 21:30:50 +08:00
|
|
|
#endif
|
|
|
|
|
2018-07-26 06:01:24 +08:00
|
|
|
// ignore double-promotion diagnostic for clang and gcc, if we check for static assertion anyway:
|
|
|
|
// TODO do the same for MSVC?
|
|
|
|
#if defined(__clang__)
|
|
|
|
# if (__clang_major__ * 100 + __clang_minor__) >= 308
|
|
|
|
# pragma clang diagnostic ignored "-Wdouble-promotion"
|
|
|
|
# endif
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
// TODO is there a minimal GCC version for this? At least g++-4.7 seems to be fine with this.
|
|
|
|
# pragma GCC diagnostic ignored "-Wdouble-promotion"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-10-06 23:24:01 +08:00
|
|
|
#if defined(EIGEN_TEST_PART_1) || defined(EIGEN_TEST_PART_2) || defined(EIGEN_TEST_PART_3)
|
|
|
|
|
|
|
|
#ifndef EIGEN_DONT_VECTORIZE
|
|
|
|
#define EIGEN_DONT_VECTORIZE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
2009-01-15 21:30:50 +08:00
|
|
|
|
2016-06-14 20:10:07 +08:00
|
|
|
static bool g_called;
|
|
|
|
#define EIGEN_SCALAR_BINARY_OP_PLUGIN { g_called |= (!internal::is_same<LhsScalar,RhsScalar>::value); }
|
|
|
|
|
2008-12-23 03:17:44 +08:00
|
|
|
#include "main.h"
|
|
|
|
|
2009-09-04 16:17:28 +08:00
|
|
|
using namespace std;
|
2008-12-23 03:17:44 +08:00
|
|
|
|
2016-06-14 20:10:07 +08:00
|
|
|
#define VERIFY_MIX_SCALAR(XPR,REF) \
|
|
|
|
g_called = false; \
|
|
|
|
VERIFY_IS_APPROX(XPR,REF); \
|
|
|
|
VERIFY( g_called && #XPR" not properly optimized");
|
|
|
|
|
2018-07-26 06:01:24 +08:00
|
|
|
template<int SizeAtCompileType>
|
|
|
|
void raise_assertion(Index size = SizeAtCompileType)
|
|
|
|
{
|
|
|
|
// VERIFY_RAISES_ASSERT(mf+md); // does not even compile
|
|
|
|
Matrix<float, SizeAtCompileType, 1> vf; vf.setRandom(size);
|
|
|
|
Matrix<double, SizeAtCompileType, 1> vd; vd.setRandom(size);
|
|
|
|
VERIFY_RAISES_ASSERT(vf=vd);
|
|
|
|
VERIFY_RAISES_ASSERT(vf+=vd);
|
|
|
|
VERIFY_RAISES_ASSERT(vf-=vd);
|
|
|
|
VERIFY_RAISES_ASSERT(vd=vf);
|
|
|
|
VERIFY_RAISES_ASSERT(vd+=vf);
|
|
|
|
VERIFY_RAISES_ASSERT(vd-=vf);
|
|
|
|
|
|
|
|
// vd.asDiagonal() * mf; // does not even compile
|
|
|
|
// vcd.asDiagonal() * mf; // does not even compile
|
|
|
|
|
|
|
|
#if 0 // we get other compilation errors here than just static asserts
|
|
|
|
VERIFY_RAISES_ASSERT(vd.dot(vf));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-23 03:17:44 +08:00
|
|
|
template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType)
|
|
|
|
{
|
2010-07-22 19:15:49 +08:00
|
|
|
typedef std::complex<float> CF;
|
|
|
|
typedef std::complex<double> CD;
|
2008-12-23 03:17:44 +08:00
|
|
|
typedef Matrix<float, SizeAtCompileType, SizeAtCompileType> Mat_f;
|
|
|
|
typedef Matrix<double, SizeAtCompileType, SizeAtCompileType> Mat_d;
|
|
|
|
typedef Matrix<std::complex<float>, SizeAtCompileType, SizeAtCompileType> Mat_cf;
|
|
|
|
typedef Matrix<std::complex<double>, SizeAtCompileType, SizeAtCompileType> Mat_cd;
|
|
|
|
typedef Matrix<float, SizeAtCompileType, 1> Vec_f;
|
|
|
|
typedef Matrix<double, SizeAtCompileType, 1> Vec_d;
|
|
|
|
typedef Matrix<std::complex<float>, SizeAtCompileType, 1> Vec_cf;
|
|
|
|
typedef Matrix<std::complex<double>, SizeAtCompileType, 1> Vec_cd;
|
|
|
|
|
2010-07-22 19:15:49 +08:00
|
|
|
Mat_f mf = Mat_f::Random(size,size);
|
|
|
|
Mat_d md = mf.template cast<double>();
|
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 21:11:41 +08:00
|
|
|
//Mat_d rd = md;
|
2010-07-22 19:15:49 +08:00
|
|
|
Mat_cf mcf = Mat_cf::Random(size,size);
|
|
|
|
Mat_cd mcd = mcf.template cast<complex<double> >();
|
2016-01-28 00:12:25 +08:00
|
|
|
Mat_cd rcd = mcd;
|
2010-07-22 19:15:49 +08:00
|
|
|
Vec_f vf = Vec_f::Random(size,1);
|
|
|
|
Vec_d vd = vf.template cast<double>();
|
|
|
|
Vec_cf vcf = Vec_cf::Random(size,1);
|
|
|
|
Vec_cd vcd = vcf.template cast<complex<double> >();
|
2010-10-25 22:15:22 +08:00
|
|
|
float sf = internal::random<float>();
|
|
|
|
double sd = internal::random<double>();
|
|
|
|
complex<float> scf = internal::random<complex<float> >();
|
|
|
|
complex<double> scd = internal::random<complex<double> >();
|
2009-09-04 17:22:32 +08:00
|
|
|
|
2008-12-23 03:17:44 +08:00
|
|
|
mf+mf;
|
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 21:11:41 +08:00
|
|
|
|
2016-07-07 17:03:01 +08:00
|
|
|
float epsf = std::sqrt(std::numeric_limits<float> ::min EIGEN_EMPTY ());
|
|
|
|
double epsd = std::sqrt(std::numeric_limits<double>::min EIGEN_EMPTY ());
|
|
|
|
|
|
|
|
while(std::abs(sf )<epsf) sf = internal::random<float>();
|
2016-12-16 00:22:12 +08:00
|
|
|
while(std::abs(sd )<epsd) sd = internal::random<double>();
|
2016-07-07 17:03:01 +08:00
|
|
|
while(std::abs(scf)<epsf) scf = internal::random<CF>();
|
|
|
|
while(std::abs(scd)<epsd) scd = internal::random<CD>();
|
|
|
|
|
2009-09-04 17:22:32 +08:00
|
|
|
// check scalar products
|
2016-06-14 20:10:07 +08:00
|
|
|
VERIFY_MIX_SCALAR(vcf * sf , vcf * complex<float>(sf));
|
|
|
|
VERIFY_MIX_SCALAR(sd * vcd , complex<double>(sd) * vcd);
|
|
|
|
VERIFY_MIX_SCALAR(vf * scf , vf.template cast<complex<float> >() * scf);
|
|
|
|
VERIFY_MIX_SCALAR(scd * vd , scd * vd.template cast<complex<double> >());
|
2016-06-13 22:15:32 +08:00
|
|
|
|
2016-06-23 20:27:20 +08:00
|
|
|
VERIFY_MIX_SCALAR(vcf * 2 , vcf * complex<float>(2));
|
|
|
|
VERIFY_MIX_SCALAR(vcf * 2.1 , vcf * complex<float>(2.1));
|
|
|
|
VERIFY_MIX_SCALAR(2 * vcf, vcf * complex<float>(2));
|
|
|
|
VERIFY_MIX_SCALAR(2.1 * vcf , vcf * complex<float>(2.1));
|
|
|
|
|
2016-06-13 22:15:32 +08:00
|
|
|
// check scalar quotients
|
2016-06-14 20:10:07 +08:00
|
|
|
VERIFY_MIX_SCALAR(vcf / sf , vcf / complex<float>(sf));
|
|
|
|
VERIFY_MIX_SCALAR(vf / scf , vf.template cast<complex<float> >() / scf);
|
2016-06-14 21:26:37 +08:00
|
|
|
VERIFY_MIX_SCALAR(vf.array() / scf, vf.template cast<complex<float> >().array() / scf);
|
|
|
|
VERIFY_MIX_SCALAR(scd / vd.array() , scd / vd.template cast<complex<double> >().array());
|
2009-09-04 17:22:32 +08:00
|
|
|
|
2016-06-14 18:06:10 +08:00
|
|
|
// check scalar increment
|
2016-06-14 20:10:07 +08:00
|
|
|
VERIFY_MIX_SCALAR(vcf.array() + sf , vcf.array() + complex<float>(sf));
|
|
|
|
VERIFY_MIX_SCALAR(sd + vcd.array(), complex<double>(sd) + vcd.array());
|
|
|
|
VERIFY_MIX_SCALAR(vf.array() + scf, vf.template cast<complex<float> >().array() + scf);
|
|
|
|
VERIFY_MIX_SCALAR(scd + vd.array() , scd + vd.template cast<complex<double> >().array());
|
2016-06-14 18:06:10 +08:00
|
|
|
|
|
|
|
// check scalar subtractions
|
2016-06-14 20:10:07 +08:00
|
|
|
VERIFY_MIX_SCALAR(vcf.array() - sf , vcf.array() - complex<float>(sf));
|
|
|
|
VERIFY_MIX_SCALAR(sd - vcd.array(), complex<double>(sd) - vcd.array());
|
|
|
|
VERIFY_MIX_SCALAR(vf.array() - scf, vf.template cast<complex<float> >().array() - scf);
|
|
|
|
VERIFY_MIX_SCALAR(scd - vd.array() , scd - vd.template cast<complex<double> >().array());
|
|
|
|
|
|
|
|
// check scalar powers
|
2016-07-04 17:49:03 +08:00
|
|
|
VERIFY_MIX_SCALAR( pow(vcf.array(), sf), Eigen::pow(vcf.array(), complex<float>(sf)) );
|
|
|
|
VERIFY_MIX_SCALAR( vcf.array().pow(sf) , Eigen::pow(vcf.array(), complex<float>(sf)) );
|
|
|
|
VERIFY_MIX_SCALAR( pow(sd, vcd.array()), Eigen::pow(complex<double>(sd), vcd.array()) );
|
|
|
|
VERIFY_MIX_SCALAR( Eigen::pow(vf.array(), scf), Eigen::pow(vf.template cast<complex<float> >().array(), scf) );
|
|
|
|
VERIFY_MIX_SCALAR( vf.array().pow(scf) , Eigen::pow(vf.template cast<complex<float> >().array(), scf) );
|
|
|
|
VERIFY_MIX_SCALAR( Eigen::pow(scd, vd.array()), Eigen::pow(scd, vd.template cast<complex<double> >().array()) );
|
2016-06-14 18:06:10 +08:00
|
|
|
|
2009-09-04 17:22:32 +08:00
|
|
|
// check dot product
|
2009-09-03 19:03:26 +08:00
|
|
|
vf.dot(vf);
|
2011-01-27 20:51:17 +08:00
|
|
|
VERIFY_IS_APPROX(vcf.dot(vf), vcf.dot(vf.template cast<complex<float> >()));
|
2009-09-04 16:17:28 +08:00
|
|
|
|
2009-09-04 17:22:32 +08:00
|
|
|
// check diagonal product
|
2009-09-04 16:17:28 +08:00
|
|
|
VERIFY_IS_APPROX(vf.asDiagonal() * mcf, vf.template cast<complex<float> >().asDiagonal() * mcf);
|
|
|
|
VERIFY_IS_APPROX(vcd.asDiagonal() * md, vcd.asDiagonal() * md.template cast<complex<double> >());
|
|
|
|
VERIFY_IS_APPROX(mcf * vf.asDiagonal(), mcf * vf.template cast<complex<float> >().asDiagonal());
|
|
|
|
VERIFY_IS_APPROX(md * vcd.asDiagonal(), md.template cast<complex<double> >() * vcd.asDiagonal());
|
2015-10-06 23:24:01 +08:00
|
|
|
|
2009-09-04 17:22:32 +08:00
|
|
|
// check inner product
|
|
|
|
VERIFY_IS_APPROX((vf.transpose() * vcf).value(), (vf.template cast<complex<float> >().transpose() * vcf).value());
|
|
|
|
|
|
|
|
// check outer product
|
|
|
|
VERIFY_IS_APPROX((vf * vcf.transpose()).eval(), (vf.template cast<complex<float> >() * vcf.transpose()).eval());
|
2010-06-20 06:35:33 +08:00
|
|
|
|
|
|
|
// coeff wise product
|
|
|
|
|
|
|
|
VERIFY_IS_APPROX((vf * vcf.transpose()).eval(), (vf.template cast<complex<float> >() * vcf.transpose()).eval());
|
|
|
|
|
|
|
|
Mat_cd mcd2 = mcd;
|
|
|
|
VERIFY_IS_APPROX(mcd.array() *= md.array(), mcd2.array() *= md.array().template cast<std::complex<double> >());
|
2010-07-15 14:40:09 +08:00
|
|
|
|
2010-07-22 19:15:49 +08:00
|
|
|
// check matrix-matrix products
|
|
|
|
VERIFY_IS_APPROX(sd*md*mcd, (sd*md).template cast<CD>().eval()*mcd);
|
|
|
|
VERIFY_IS_APPROX(sd*mcd*md, sd*mcd*md.template cast<CD>());
|
|
|
|
VERIFY_IS_APPROX(scd*md*mcd, scd*md.template cast<CD>().eval()*mcd);
|
|
|
|
VERIFY_IS_APPROX(scd*mcd*md, scd*mcd*md.template cast<CD>());
|
2016-01-28 00:29:53 +08:00
|
|
|
|
2010-07-22 19:15:49 +08:00
|
|
|
VERIFY_IS_APPROX(sf*mf*mcf, sf*mf.template cast<CF>()*mcf);
|
|
|
|
VERIFY_IS_APPROX(sf*mcf*mf, sf*mcf*mf.template cast<CF>());
|
|
|
|
VERIFY_IS_APPROX(scf*mf*mcf, scf*mf.template cast<CF>()*mcf);
|
|
|
|
VERIFY_IS_APPROX(scf*mcf*mf, scf*mcf*mf.template cast<CF>());
|
2016-01-28 00:29:53 +08:00
|
|
|
|
2014-04-17 22:26:35 +08:00
|
|
|
VERIFY_IS_APPROX(sd*md.adjoint()*mcd, (sd*md).template cast<CD>().eval().adjoint()*mcd);
|
|
|
|
VERIFY_IS_APPROX(sd*mcd.adjoint()*md, sd*mcd.adjoint()*md.template cast<CD>());
|
|
|
|
VERIFY_IS_APPROX(sd*md.adjoint()*mcd.adjoint(), (sd*md).template cast<CD>().eval().adjoint()*mcd.adjoint());
|
|
|
|
VERIFY_IS_APPROX(sd*mcd.adjoint()*md.adjoint(), sd*mcd.adjoint()*md.template cast<CD>().adjoint());
|
|
|
|
VERIFY_IS_APPROX(sd*md*mcd.adjoint(), (sd*md).template cast<CD>().eval()*mcd.adjoint());
|
|
|
|
VERIFY_IS_APPROX(sd*mcd*md.adjoint(), sd*mcd*md.template cast<CD>().adjoint());
|
2016-01-28 00:29:53 +08:00
|
|
|
|
2014-04-17 22:26:35 +08:00
|
|
|
VERIFY_IS_APPROX(sf*mf.adjoint()*mcf, (sf*mf).template cast<CF>().eval().adjoint()*mcf);
|
|
|
|
VERIFY_IS_APPROX(sf*mcf.adjoint()*mf, sf*mcf.adjoint()*mf.template cast<CF>());
|
|
|
|
VERIFY_IS_APPROX(sf*mf.adjoint()*mcf.adjoint(), (sf*mf).template cast<CF>().eval().adjoint()*mcf.adjoint());
|
|
|
|
VERIFY_IS_APPROX(sf*mcf.adjoint()*mf.adjoint(), sf*mcf.adjoint()*mf.template cast<CF>().adjoint());
|
|
|
|
VERIFY_IS_APPROX(sf*mf*mcf.adjoint(), (sf*mf).template cast<CF>().eval()*mcf.adjoint());
|
|
|
|
VERIFY_IS_APPROX(sf*mcf*mf.adjoint(), sf*mcf*mf.template cast<CF>().adjoint());
|
2010-07-22 19:15:49 +08:00
|
|
|
|
|
|
|
VERIFY_IS_APPROX(sf*mf*vcf, (sf*mf).template cast<CF>().eval()*vcf);
|
|
|
|
VERIFY_IS_APPROX(scf*mf*vcf,(scf*mf.template cast<CF>()).eval()*vcf);
|
|
|
|
VERIFY_IS_APPROX(sf*mcf*vf, sf*mcf*vf.template cast<CF>());
|
|
|
|
VERIFY_IS_APPROX(scf*mcf*vf,scf*mcf*vf.template cast<CF>());
|
|
|
|
|
|
|
|
VERIFY_IS_APPROX(sf*vcf.adjoint()*mf, sf*vcf.adjoint()*mf.template cast<CF>().eval());
|
|
|
|
VERIFY_IS_APPROX(scf*vcf.adjoint()*mf, scf*vcf.adjoint()*mf.template cast<CF>().eval());
|
|
|
|
VERIFY_IS_APPROX(sf*vf.adjoint()*mcf, sf*vf.adjoint().template cast<CF>().eval()*mcf);
|
|
|
|
VERIFY_IS_APPROX(scf*vf.adjoint()*mcf, scf*vf.adjoint().template cast<CF>().eval()*mcf);
|
|
|
|
|
|
|
|
VERIFY_IS_APPROX(sd*md*vcd, (sd*md).template cast<CD>().eval()*vcd);
|
|
|
|
VERIFY_IS_APPROX(scd*md*vcd,(scd*md.template cast<CD>()).eval()*vcd);
|
|
|
|
VERIFY_IS_APPROX(sd*mcd*vd, sd*mcd*vd.template cast<CD>().eval());
|
|
|
|
VERIFY_IS_APPROX(scd*mcd*vd,scd*mcd*vd.template cast<CD>().eval());
|
|
|
|
|
|
|
|
VERIFY_IS_APPROX(sd*vcd.adjoint()*md, sd*vcd.adjoint()*md.template cast<CD>().eval());
|
|
|
|
VERIFY_IS_APPROX(scd*vcd.adjoint()*md, scd*vcd.adjoint()*md.template cast<CD>().eval());
|
|
|
|
VERIFY_IS_APPROX(sd*vd.adjoint()*mcd, sd*vd.adjoint().template cast<CD>().eval()*mcd);
|
|
|
|
VERIFY_IS_APPROX(scd*vd.adjoint()*mcd, scd*vd.adjoint().template cast<CD>().eval()*mcd);
|
2016-01-28 00:12:25 +08:00
|
|
|
|
2016-04-15 23:58:36 +08:00
|
|
|
VERIFY_IS_APPROX( sd*vcd.adjoint()*md.template triangularView<Upper>(), sd*vcd.adjoint()*md.template cast<CD>().eval().template triangularView<Upper>());
|
2016-01-28 00:29:53 +08:00
|
|
|
VERIFY_IS_APPROX(scd*vcd.adjoint()*md.template triangularView<Lower>(), scd*vcd.adjoint()*md.template cast<CD>().eval().template triangularView<Lower>());
|
2016-04-15 23:58:36 +08:00
|
|
|
VERIFY_IS_APPROX( sd*vcd.adjoint()*md.transpose().template triangularView<Upper>(), sd*vcd.adjoint()*md.transpose().template cast<CD>().eval().template triangularView<Upper>());
|
|
|
|
VERIFY_IS_APPROX(scd*vcd.adjoint()*md.transpose().template triangularView<Lower>(), scd*vcd.adjoint()*md.transpose().template cast<CD>().eval().template triangularView<Lower>());
|
|
|
|
VERIFY_IS_APPROX( sd*vd.adjoint()*mcd.template triangularView<Lower>(), sd*vd.adjoint().template cast<CD>().eval()*mcd.template triangularView<Lower>());
|
2016-01-28 00:29:53 +08:00
|
|
|
VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.template triangularView<Upper>(), scd*vd.adjoint().template cast<CD>().eval()*mcd.template triangularView<Upper>());
|
2016-04-15 23:58:36 +08:00
|
|
|
VERIFY_IS_APPROX( sd*vd.adjoint()*mcd.transpose().template triangularView<Lower>(), sd*vd.adjoint().template cast<CD>().eval()*mcd.transpose().template triangularView<Lower>());
|
|
|
|
VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.transpose().template triangularView<Upper>(), scd*vd.adjoint().template cast<CD>().eval()*mcd.transpose().template triangularView<Upper>());
|
2016-01-28 00:29:53 +08:00
|
|
|
|
|
|
|
// Not supported yet: trmm
|
|
|
|
// VERIFY_IS_APPROX(sd*mcd*md.template triangularView<Lower>(), sd*mcd*md.template cast<CD>().eval().template triangularView<Lower>());
|
|
|
|
// VERIFY_IS_APPROX(scd*mcd*md.template triangularView<Upper>(), scd*mcd*md.template cast<CD>().eval().template triangularView<Upper>());
|
|
|
|
// VERIFY_IS_APPROX(sd*md*mcd.template triangularView<Lower>(), sd*md.template cast<CD>().eval()*mcd.template triangularView<Lower>());
|
|
|
|
// VERIFY_IS_APPROX(scd*md*mcd.template triangularView<Upper>(), scd*md.template cast<CD>().eval()*mcd.template triangularView<Upper>());
|
|
|
|
|
|
|
|
// Not supported yet: symv
|
|
|
|
// VERIFY_IS_APPROX(sd*vcd.adjoint()*md.template selfadjointView<Upper>(), sd*vcd.adjoint()*md.template cast<CD>().eval().template selfadjointView<Upper>());
|
|
|
|
// VERIFY_IS_APPROX(scd*vcd.adjoint()*md.template selfadjointView<Lower>(), scd*vcd.adjoint()*md.template cast<CD>().eval().template selfadjointView<Lower>());
|
|
|
|
// VERIFY_IS_APPROX(sd*vd.adjoint()*mcd.template selfadjointView<Lower>(), sd*vd.adjoint().template cast<CD>().eval()*mcd.template selfadjointView<Lower>());
|
|
|
|
// VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.template selfadjointView<Upper>(), scd*vd.adjoint().template cast<CD>().eval()*mcd.template selfadjointView<Upper>());
|
|
|
|
|
|
|
|
// Not supported yet: symm
|
|
|
|
// VERIFY_IS_APPROX(sd*vcd.adjoint()*md.template selfadjointView<Upper>(), sd*vcd.adjoint()*md.template cast<CD>().eval().template selfadjointView<Upper>());
|
|
|
|
// VERIFY_IS_APPROX(scd*vcd.adjoint()*md.template selfadjointView<Upper>(), scd*vcd.adjoint()*md.template cast<CD>().eval().template selfadjointView<Upper>());
|
|
|
|
// VERIFY_IS_APPROX(sd*vd.adjoint()*mcd.template selfadjointView<Upper>(), sd*vd.adjoint().template cast<CD>().eval()*mcd.template selfadjointView<Upper>());
|
|
|
|
// VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.template selfadjointView<Upper>(), scd*vd.adjoint().template cast<CD>().eval()*mcd.template selfadjointView<Upper>());
|
|
|
|
|
2016-01-28 00:12:25 +08:00
|
|
|
rcd.setZero();
|
|
|
|
VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView<Upper>() = sd * mcd * md),
|
|
|
|
Mat_cd((sd * mcd * md.template cast<CD>().eval()).template triangularView<Upper>()));
|
|
|
|
VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView<Upper>() = sd * md * mcd),
|
|
|
|
Mat_cd((sd * md.template cast<CD>().eval() * mcd).template triangularView<Upper>()));
|
|
|
|
VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView<Upper>() = scd * mcd * md),
|
|
|
|
Mat_cd((scd * mcd * md.template cast<CD>().eval()).template triangularView<Upper>()));
|
|
|
|
VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView<Upper>() = scd * md * mcd),
|
|
|
|
Mat_cd((scd * md.template cast<CD>().eval() * mcd).template triangularView<Upper>()));
|
2016-05-19 05:00:13 +08:00
|
|
|
|
|
|
|
|
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 21:11:41 +08:00
|
|
|
VERIFY_IS_APPROX( md.array() * mcd.array(), md.template cast<CD>().eval().array() * mcd.array() );
|
|
|
|
VERIFY_IS_APPROX( mcd.array() * md.array(), mcd.array() * md.template cast<CD>().eval().array() );
|
|
|
|
|
|
|
|
VERIFY_IS_APPROX( md.array() + mcd.array(), md.template cast<CD>().eval().array() + mcd.array() );
|
|
|
|
VERIFY_IS_APPROX( mcd.array() + md.array(), mcd.array() + md.template cast<CD>().eval().array() );
|
|
|
|
|
|
|
|
VERIFY_IS_APPROX( md.array() - mcd.array(), md.template cast<CD>().eval().array() - mcd.array() );
|
|
|
|
VERIFY_IS_APPROX( mcd.array() - md.array(), mcd.array() - md.template cast<CD>().eval().array() );
|
2016-05-19 05:00:13 +08:00
|
|
|
|
2016-07-07 17:03:01 +08:00
|
|
|
if(mcd.array().abs().minCoeff()>epsd)
|
|
|
|
{
|
|
|
|
VERIFY_IS_APPROX( md.array() / mcd.array(), md.template cast<CD>().eval().array() / mcd.array() );
|
|
|
|
}
|
|
|
|
if(md.array().abs().minCoeff()>epsd)
|
|
|
|
{
|
|
|
|
VERIFY_IS_APPROX( mcd.array() / md.array(), mcd.array() / md.template cast<CD>().eval().array() );
|
|
|
|
}
|
2016-05-19 05:00:13 +08:00
|
|
|
|
2016-07-07 17:03:01 +08:00
|
|
|
if(md.array().abs().minCoeff()>epsd || mcd.array().abs().minCoeff()>epsd)
|
|
|
|
{
|
|
|
|
VERIFY_IS_APPROX( md.array().pow(mcd.array()), md.template cast<CD>().eval().array().pow(mcd.array()) );
|
|
|
|
VERIFY_IS_APPROX( mcd.array().pow(md.array()), mcd.array().pow(md.template cast<CD>().eval().array()) );
|
2016-06-10 21:58:22 +08:00
|
|
|
|
2016-07-07 17:03:01 +08:00
|
|
|
VERIFY_IS_APPROX( pow(md.array(),mcd.array()), md.template cast<CD>().eval().array().pow(mcd.array()) );
|
|
|
|
VERIFY_IS_APPROX( pow(mcd.array(),md.array()), mcd.array().pow(md.template cast<CD>().eval().array()) );
|
|
|
|
}
|
2016-06-14 20:10:07 +08:00
|
|
|
|
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 21:11:41 +08:00
|
|
|
rcd = mcd;
|
|
|
|
VERIFY_IS_APPROX( rcd = md, md.template cast<CD>().eval() );
|
|
|
|
rcd = mcd;
|
|
|
|
VERIFY_IS_APPROX( rcd += md, mcd + md.template cast<CD>().eval() );
|
|
|
|
rcd = mcd;
|
|
|
|
VERIFY_IS_APPROX( rcd -= md, mcd - md.template cast<CD>().eval() );
|
2016-05-19 05:00:13 +08:00
|
|
|
rcd = mcd;
|
|
|
|
VERIFY_IS_APPROX( rcd.array() *= md.array(), mcd.array() * md.template cast<CD>().eval().array() );
|
|
|
|
rcd = mcd;
|
2016-07-07 17:03:01 +08:00
|
|
|
if(md.array().abs().minCoeff()>epsd)
|
|
|
|
{
|
|
|
|
VERIFY_IS_APPROX( rcd.array() /= md.array(), mcd.array() / md.template cast<CD>().eval().array() );
|
|
|
|
}
|
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 21:11:41 +08:00
|
|
|
|
|
|
|
rcd = mcd;
|
2016-06-07 05:10:55 +08:00
|
|
|
VERIFY_IS_APPROX( rcd.noalias() += md + mcd*md, mcd + (md.template cast<CD>().eval()) + mcd*(md.template cast<CD>().eval()));
|
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 21:11:41 +08:00
|
|
|
|
2016-06-07 05:10:55 +08:00
|
|
|
VERIFY_IS_APPROX( rcd.noalias() = md*md, ((md*md).eval().template cast<CD>()) );
|
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP>
- Remove the "functor_is_product_like" helper (was pretty ugly)
- Currently, OP is not used, but it is available to the user for fine grained tuning
- Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-=
- TODO: generalize all other binray operators (comparisons,pow,etc.)
- TODO: handle "scalar op array" operators (currently only * is handled)
- TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
2016-06-06 21:11:41 +08:00
|
|
|
rcd = mcd;
|
2016-06-07 05:10:55 +08:00
|
|
|
VERIFY_IS_APPROX( rcd.noalias() += md*md, mcd + ((md*md).eval().template cast<CD>()) );
|
|
|
|
rcd = mcd;
|
|
|
|
VERIFY_IS_APPROX( rcd.noalias() -= md*md, mcd - ((md*md).eval().template cast<CD>()) );
|
|
|
|
|
|
|
|
VERIFY_IS_APPROX( rcd.noalias() = mcd + md*md, mcd + ((md*md).eval().template cast<CD>()) );
|
|
|
|
rcd = mcd;
|
|
|
|
VERIFY_IS_APPROX( rcd.noalias() += mcd + md*md, mcd + mcd + ((md*md).eval().template cast<CD>()) );
|
|
|
|
rcd = mcd;
|
|
|
|
VERIFY_IS_APPROX( rcd.noalias() -= mcd + md*md, - ((md*md).eval().template cast<CD>()) );
|
2009-09-03 19:03:26 +08:00
|
|
|
}
|
2008-12-23 03:17:44 +08:00
|
|
|
|
2018-07-17 20:46:15 +08:00
|
|
|
EIGEN_DECLARE_TEST(mixingtypes)
|
2008-12-23 03:17:44 +08:00
|
|
|
{
|
2014-03-31 16:41:40 +08:00
|
|
|
for(int i = 0; i < g_repeat; i++) {
|
|
|
|
CALL_SUBTEST_1(mixingtypes<3>());
|
|
|
|
CALL_SUBTEST_2(mixingtypes<4>());
|
|
|
|
CALL_SUBTEST_3(mixingtypes<Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE)));
|
2015-10-06 23:24:01 +08:00
|
|
|
|
|
|
|
CALL_SUBTEST_4(mixingtypes<3>());
|
|
|
|
CALL_SUBTEST_5(mixingtypes<4>());
|
|
|
|
CALL_SUBTEST_6(mixingtypes<Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE)));
|
2018-07-26 06:01:24 +08:00
|
|
|
CALL_SUBTEST_7(raise_assertion<Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE)));
|
2014-03-31 16:41:40 +08:00
|
|
|
}
|
2018-07-26 06:01:24 +08:00
|
|
|
CALL_SUBTEST_7(raise_assertion<0>());
|
|
|
|
CALL_SUBTEST_7(raise_assertion<3>());
|
|
|
|
CALL_SUBTEST_7(raise_assertion<4>());
|
|
|
|
CALL_SUBTEST_7(raise_assertion<Dynamic>(0));
|
2008-12-23 03:17:44 +08:00
|
|
|
}
|