00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "main.h"
00026
00027 template<typename Scalar> void trmm(int size,int )
00028 {
00029 typedef typename NumTraits<Scalar>::Real RealScalar;
00030
00031 typedef Matrix<Scalar,Dynamic,Dynamic,ColMajor> MatrixColMaj;
00032 typedef Matrix<Scalar,Dynamic,Dynamic,RowMajor> MatrixRowMaj;
00033
00034 DenseIndex rows = size;
00035 DenseIndex cols = internal::random<DenseIndex>(1,size);
00036
00037 MatrixColMaj triV(rows,cols), triH(cols,rows), upTri(cols,rows), loTri(rows,cols),
00038 unitUpTri(cols,rows), unitLoTri(rows,cols), strictlyUpTri(cols,rows), strictlyLoTri(rows,cols);
00039 MatrixColMaj ge1(rows,cols), ge2(cols,rows), ge3;
00040 MatrixRowMaj rge3;
00041
00042 Scalar s1 = internal::random<Scalar>(),
00043 s2 = internal::random<Scalar>();
00044
00045 triV.setRandom();
00046 triH.setRandom();
00047 loTri = triV.template triangularView<Lower>();
00048 upTri = triH.template triangularView<Upper>();
00049 unitLoTri = triV.template triangularView<UnitLower>();
00050 unitUpTri = triH.template triangularView<UnitUpper>();
00051 strictlyLoTri = triV.template triangularView<StrictlyLower>();
00052 strictlyUpTri = triH.template triangularView<StrictlyUpper>();
00053 ge1.setRandom();
00054 ge2.setRandom();
00055
00056 VERIFY_IS_APPROX( ge3 = triV.template triangularView<Lower>() * ge2, loTri * ge2);
00057 VERIFY_IS_APPROX( ge3 = ge2 * triV.template triangularView<Lower>(), ge2 * loTri);
00058 VERIFY_IS_APPROX( ge3 = triH.template triangularView<Upper>() * ge1, upTri * ge1);
00059 VERIFY_IS_APPROX( ge3 = ge1 * triH.template triangularView<Upper>(), ge1 * upTri);
00060 VERIFY_IS_APPROX( ge3 = (s1*triV.adjoint()).template triangularView<Upper>() * (s2*ge1), s1*loTri.adjoint() * (s2*ge1));
00061 VERIFY_IS_APPROX( ge3 = ge1 * triV.adjoint().template triangularView<Upper>(), ge1 * loTri.adjoint());
00062 VERIFY_IS_APPROX( ge3 = triH.adjoint().template triangularView<Lower>() * ge2, upTri.adjoint() * ge2);
00063 VERIFY_IS_APPROX( ge3 = ge2 * triH.adjoint().template triangularView<Lower>(), ge2 * upTri.adjoint());
00064 VERIFY_IS_APPROX( ge3 = triV.template triangularView<Lower>() * ge1.adjoint(), loTri * ge1.adjoint());
00065 VERIFY_IS_APPROX( ge3 = ge1.adjoint() * triV.template triangularView<Lower>(), ge1.adjoint() * loTri);
00066 VERIFY_IS_APPROX( ge3 = triH.template triangularView<Upper>() * ge2.adjoint(), upTri * ge2.adjoint());
00067 VERIFY_IS_APPROX(rge3.noalias() = triH.template triangularView<Upper>() * ge2.adjoint(), upTri * ge2.adjoint());
00068 VERIFY_IS_APPROX( ge3 = (s1*triV).adjoint().template triangularView<Upper>() * ge2.adjoint(), internal::conj(s1) * loTri.adjoint() * ge2.adjoint());
00069 VERIFY_IS_APPROX(rge3.noalias() = triV.adjoint().template triangularView<Upper>() * ge2.adjoint(), loTri.adjoint() * ge2.adjoint());
00070 VERIFY_IS_APPROX( ge3 = triH.adjoint().template triangularView<Lower>() * ge1.adjoint(), upTri.adjoint() * ge1.adjoint());
00071 VERIFY_IS_APPROX(rge3.noalias() = triH.adjoint().template triangularView<Lower>() * ge1.adjoint(), upTri.adjoint() * ge1.adjoint());
00072
00073 VERIFY_IS_APPROX( ge3 = triV.template triangularView<UnitLower>() * ge2, unitLoTri * ge2);
00074 VERIFY_IS_APPROX( rge3.noalias() = ge2 * triV.template triangularView<UnitLower>(), ge2 * unitLoTri);
00075 VERIFY_IS_APPROX( ge3 = ge2 * triV.template triangularView<UnitLower>(), ge2 * unitLoTri);
00076 VERIFY_IS_APPROX( ge3 = (s1*triV).adjoint().template triangularView<UnitUpper>() * ge2.adjoint(), internal::conj(s1) * unitLoTri.adjoint() * ge2.adjoint());
00077
00078 VERIFY_IS_APPROX( ge3 = triV.template triangularView<StrictlyLower>() * ge2, strictlyLoTri * ge2);
00079 VERIFY_IS_APPROX( rge3.noalias() = ge2 * triV.template triangularView<StrictlyLower>(), ge2 * strictlyLoTri);
00080 VERIFY_IS_APPROX( ge3 = ge2 * triV.template triangularView<StrictlyLower>(), ge2 * strictlyLoTri);
00081 VERIFY_IS_APPROX( ge3 = (s1*triV).adjoint().template triangularView<StrictlyUpper>() * ge2.adjoint(), internal::conj(s1) * strictlyLoTri.adjoint() * ge2.adjoint());
00082 }
00083
00084 void test_product_trmm()
00085 {
00086 for(int i = 0; i < g_repeat ; i++)
00087 {
00088 CALL_SUBTEST_1((trmm<float>(internal::random<int>(1,320),internal::random<int>(1,320))));
00089 CALL_SUBTEST_2((trmm<double>(internal::random<int>(1,320),internal::random<int>(1,320))));
00090 CALL_SUBTEST_3((trmm<std::complex<float> >(internal::random<int>(1,200),internal::random<int>(1,200))));
00091 CALL_SUBTEST_4((trmm<std::complex<double> >(internal::random<int>(1,200),internal::random<int>(1,200))));
00092 }
00093 }