void TestTriMatrixArith_C4a()
{
    typedef std::complex<T> CT;

    tmv::Matrix<T,tmv::RowMajor> a1x(4,4);
    for(int i=0;i<4;++i) for(int j=0;j<4;++j) {
        a1x(i,j) = T(3+4*i-6*j);
    }
    a1x(0,0) = 14; 
    a1x(1,0) = -2; 
    a1x(2,0) = 7; 
    a1x(3,0) = -10;
    a1x(2,2) = 30;

    tmv::Matrix<CT,tmv::RowMajor> ca1x = a1x;
    ca1x(2,3) += CT(2,3);
    ca1x(1,0) *= CT(0,2);
    ca1x.col(1) *= CT(-1,3);
    ca1x.row(3) += tmv::Vector<CT>(4,CT(1,9));

    tmv::Matrix<T,tmv::ColMajor> a2x = a1x.transpose();
    a2x.row(1) *= T(3);
    a2x.col(2) -= tmv::Vector<T>(4,4);
    tmv::Matrix<CT,tmv::ColMajor> ca2x = ca1x;
    ca2x -= a2x;
    ca2x *= CT(1,-2);
    ca2x(0,0) = CT(0,-5);

    tmv::UpperTriMatrixView<T> u1 = a1x.upperTri();
    tmv::UpperTriMatrixView<CT> cu1 = ca1x.upperTri();
    tmv::UpperTriMatrixView<T> u2 = a2x.upperTri();
    tmv::UpperTriMatrixView<CT> cu2 = ca2x.upperTri();
    tmv::UpperTriMatrixView<T> u4 = a1x.unitUpperTri();
    tmv::UpperTriMatrixView<CT> cu4 = ca1x.unitUpperTri();
    tmv::UpperTriMatrixView<T> u5 = a2x.unitUpperTri();
    tmv::UpperTriMatrixView<CT> cu5 = ca2x.unitUpperTri();

    tmv::DiagMatrixView<T> d1 = DiagMatrixViewOf(a1x.row(0));
    tmv::DiagMatrixView<CT> cd1 = DiagMatrixViewOf(ca1x.row(0));

    TestMatrixArith4(d1,cd1,u1,cu1,"Diag/UpperTri 1");
    TestMatrixArith4(d1,cd1,u2,cu2,"Diag/UpperTri 2");
    TestMatrixArith4(d1,cd1,u4,cu4,"Diag/UpperTri 3");
    TestMatrixArith4(d1,cd1,u5,cu5,"Diag/UpperTri 4");
#if (XTEST & 1)
    tmv::Matrix<T> a3x(12,16);
    for(int i=0;i<12;++i) for(int j=0;j<16;++j) a3x(i,j) = T(1-2*i+3*j);
    a3x.diag().addToAll(30);
    tmv::Matrix<CT> ca3x = a3x*CT(1,-2);
    ca3x.diag().addToAll(CT(-22,15));

    tmv::DiagMatrixView<T> d3 = DiagMatrixViewOf(a1x.diag());
    tmv::DiagMatrixView<CT> cd3 = DiagMatrixViewOf(ca1x.diag());
    tmv::UpperTriMatrixView<T> u3 = a3x.subMatrix(0,12,0,16,3,4).upperTri();
    tmv::UpperTriMatrixView<CT> cu3 = ca3x.subMatrix(0,12,0,16,3,4).upperTri();
    tmv::UpperTriMatrixView<T> u6 = a3x.subMatrix(0,12,0,16,3,4).unitUpperTri();
    tmv::UpperTriMatrixView<CT> cu6 = ca3x.subMatrix(0,12,0,16,3,4).unitUpperTri();
    TestMatrixArith4(d3,cd3,u1,cu1,"Diag/UpperTri 5");
    TestMatrixArith4(d3,cd3,u2,cu2,"Diag/UpperTri 6");
    TestMatrixArith4(d3,cd3,u3,cu3,"Diag/UpperTri 7");
    TestMatrixArith4(d3,cd3,u4,cu4,"Diag/UpperTri 8");
    TestMatrixArith4(d3,cd3,u5,cu5,"Diag/UpperTri 9");
    TestMatrixArith4(d3,cd3,u6,cu6,"Diag/UpperTri 10");
    TestMatrixArith4(d1,cd1,u3,cu3,"Diag/UpperTri 11");
    TestMatrixArith4(d1,cd1,u6,cu6,"Diag/UpperTri 12");
#endif

#if (XTEST & 2)
    tmv::LowerTriMatrixView<T> l1 = a1x.lowerTri();
    tmv::LowerTriMatrixView<CT> cl1 = ca1x.lowerTri();
    tmv::LowerTriMatrixView<T> l2 = a2x.lowerTri();
    tmv::LowerTriMatrixView<CT> cl2 = ca2x.lowerTri();
    tmv::LowerTriMatrixView<T> l4 = a1x.unitLowerTri();
    tmv::LowerTriMatrixView<CT> cl4 = ca1x.unitLowerTri();
    tmv::LowerTriMatrixView<T> l5 = a2x.unitLowerTri();
    tmv::LowerTriMatrixView<CT> cl5 = ca2x.unitLowerTri();

    TestMatrixArith4(d1,cd1,l1,cl1,"Diag/LowerTri 1");
    TestMatrixArith4(d1,cd1,l2,cl2,"Diag/LowerTri 2");
    TestMatrixArith4(d1,cd1,l4,cl4,"Diag/LowerTri 3");
    TestMatrixArith4(d1,cd1,l5,cl5,"Diag/LowerTri 4");
#if (XTEST & 1)
    tmv::LowerTriMatrixView<T> l3 = a3x.subMatrix(0,12,0,16,3,4).lowerTri();
    tmv::LowerTriMatrixView<CT> cl3 = ca3x.subMatrix(0,12,0,16,3,4).lowerTri();
    tmv::LowerTriMatrixView<T> l6 = a3x.subMatrix(0,12,0,16,3,4).unitLowerTri();
    tmv::LowerTriMatrixView<CT> cl6 = ca3x.subMatrix(0,12,0,16,3,4).unitLowerTri();
    TestMatrixArith4(d3,cd3,l1,cl1,"Diag/LowerTri 5");
    TestMatrixArith4(d3,cd3,l2,cl2,"Diag/LowerTri 6");
    TestMatrixArith4(d3,cd3,l3,cl3,"Diag/LowerTri 7");
    TestMatrixArith4(d3,cd3,l4,cl4,"Diag/LowerTri 8");
    TestMatrixArith4(d3,cd3,l5,cl5,"Diag/LowerTri 9");
    TestMatrixArith4(d3,cd3,l6,cl6,"Diag/LowerTri 10");
    TestMatrixArith4(d1,cd1,l3,cl3,"Diag/LowerTri 11");
    TestMatrixArith4(d1,cd1,l6,cl6,"Diag/LowerTri 12");
#endif
#endif
}
Exemple #2
0
bool change_param(void)
{   bool ok = true;                     // initialize test result

    typedef CppAD::AD<double> a1type;   // for first level of taping
    typedef CppAD::AD<a1type>  a2type;  // for second level of taping

    size_t nu = 3;       // number components in u
    size_t nx = 2;       // number components in x
    size_t ny = 2;       // num components in f(x)
    size_t nJ = ny * nx; // number components in Jacobian of f(x)

    // temporary indices
    size_t j;

    // declare first level of independent variables
    // (Start taping now so can record dependency of a1f on a1p.)
    CPPAD_TESTVECTOR(a1type) a1u(nu);
    for(j = 0; j < nu; j++)
        a1u[j] = 0.;
    CppAD::Independent(a1u);

    // parameter in computation of Jacobian
    a1type a1p = a1u[2];

    // declare second level of independent variables
    CPPAD_TESTVECTOR(a2type) a2x(nx);
    for(j = 0; j < nx; j++)
        a2x[j] = 0.;
    CppAD::Independent(a2x);

    // compute dependent variables at second level
    CPPAD_TESTVECTOR(a2type) a2y(ny);
    a2y[0] = sin( a2x[0] ) * a1p;
    a2y[1] = sin( a2x[1] ) * a1p;

    // declare function object that computes values at the first level
    // (make sure we do not run zero order forward during constructor)
    CppAD::ADFun<a1type> a1f;
    a1f.Dependent(a2x, a2y);

    // compute the Jacobian of a1f at a1u[0], a1u[1]
    CPPAD_TESTVECTOR(a1type) a1x(nx);
    a1x[0] = a1u[0];
    a1x[1] = a1u[1];
    CPPAD_TESTVECTOR(a1type) a1J(nJ);
    a1J = a1f.Jacobian( a1x );

    // declare function object that maps u = (x, p) to Jacobian of f
    // (make sure we do not run zero order forward during constructor)
    CppAD::ADFun<double> g;
    g.Dependent(a1u, a1J);

    // remove extra variables used during the reconding of a1f,
    // but not needed any more.
    g.optimize();

    // compute the Jacobian of f using zero order forward
    // sweep with double values
    CPPAD_TESTVECTOR(double) J(nJ), u(nu);
    for(j = 0; j < nu; j++)
        u[j] = double(j+1);
    J = g.Forward(0, u);

    // accuracy for tests
    double eps = 100. * CppAD::numeric_limits<double>::epsilon();

    // y[0] = sin( x[0] ) * p
    // y[1] = sin( x[1] ) * p
    CPPAD_TESTVECTOR(double) x(nx);
    x[0]      = u[0];
    x[1]      = u[1];
    double p  = u[2];

    // J[0] = partial y[0] w.r.t x[0] = cos( x[0] ) * p
    double check = cos( x[0] ) * p;
    ok   &= fabs( check - J[0] ) <= eps;

    // J[1] = partial y[0] w.r.t x[1] = 0.;
    check = 0.;
    ok   &= fabs( check - J[1] ) <= eps;

    // J[2] = partial y[1] w.r.t. x[0] = 0.
    check = 0.;
    ok   &= fabs( check - J[2] ) <= eps;

    // J[3] = partial y[1] w.r.t x[1] = cos( x[1] ) * p
    check = cos( x[1] ) * p;
    ok   &= fabs( check - J[3] ) <= eps;

    return ok;
}
template <class T> void TestTriMatrixArith_C6a()
{
    typedef std::complex<T> CT;

    tmv::Matrix<T,tmv::RowMajor> a1x(4,4);
    for(int i=0;i<4;++i) for(int j=0;j<4;++j) {
        a1x(i,j) = T(3+4*i-6*j);
    }
    a1x(0,0) = 14; 
    a1x(1,0) = -2; 
    a1x(2,0) = 7; 
    a1x(3,0) = -10;
    a1x(2,2) = 30;

    tmv::Matrix<CT,tmv::RowMajor> ca1x = a1x;
    ca1x(2,3) += CT(2,3);
    ca1x(1,0) *= CT(0,2);
    ca1x.col(1) *= CT(-1,3);
    ca1x.row(3) += tmv::Vector<CT>(4,CT(1,9));

    tmv::Matrix<T,tmv::ColMajor> a2x = a1x.transpose();
    a2x.row(1) *= T(3);
    a2x.col(2) -= tmv::Vector<T>(4,4);
    tmv::Matrix<CT,tmv::ColMajor> ca2x = ca1x;
    ca2x -= a2x;
    ca2x *= CT(1,-2);
    ca2x(0,0) = CT(0,-5);

    tmv::UpperTriMatrixView<T> u1 = a1x.upperTri();
    tmv::UpperTriMatrixView<CT> cu1 = ca1x.upperTri();
    tmv::UpperTriMatrixView<T> u2 = a2x.upperTri();
    tmv::UpperTriMatrixView<CT> cu2 = ca2x.upperTri();

    tmv::DiagMatrixView<T> d1 = DiagMatrixViewOf(a1x.row(0));
    tmv::DiagMatrixView<CT> cd1 = DiagMatrixViewOf(ca1x.row(0));

    TestMatrixArith6(u1,cu1,d1,cd1,u1,cu1,"UpperTri/Diag 1");
#if (XTEST & 2)
    TestMatrixArith6(u2,cu2,d1,cd1,u1,cu1,"UpperTri/Diag 2");
    TestMatrixArith6(u2,cu2,d1,cd1,u2,cu2,"UpperTri/Diag 3");
    TestMatrixArith6(u1,cu1,d1,cd1,u2,cu2,"UpperTri/Diag 4");
#endif
#if (XTEST & 1)
    tmv::Matrix<T> a3x(12,16);
    for(int i=0;i<12;++i) for(int j=0;j<16;++j) a3x(i,j) = T(1-2*i+3*j);
    a3x.diag().addToAll(30);
    tmv::Matrix<CT> ca3x = a3x*CT(1,-2);
    ca3x.diag().addToAll(CT(-22,15));

    tmv::DiagMatrixView<T> d3 = DiagMatrixViewOf(a1x.diag());
    tmv::DiagMatrixView<CT> cd3 = DiagMatrixViewOf(ca1x.diag());
    tmv::UpperTriMatrixView<T> u3 = a3x.subMatrix(0,12,0,16,3,4).upperTri();
    tmv::UpperTriMatrixView<CT> cu3 = ca3x.subMatrix(0,12,0,16,3,4).upperTri();
    TestMatrixArith6(u3,cu3,d1,cd1,u1,cu1,"UpperTri/Diag 5");
    TestMatrixArith6(u1,cu1,d3,cd3,u1,cu1,"UpperTri/Diag 6");
    TestMatrixArith6(u2,cu2,d3,cd3,u1,cu1,"UpperTri/Diag 7");
    TestMatrixArith6(u1,cu1,d1,cd1,u3,cu3,"UpperTri/Diag 8");
    TestMatrixArith6(u2,cu2,d1,cd1,u3,cu3,"UpperTri/Diag 9");
#endif
    TestMatrixArith6x(u1,cu1,d1,cd1,"UpperTri/Diag 10");
#if (XTEST & 2)
    TestMatrixArith6x(u2,cu2,d1,cd1,"UpperTri/Diag 11");
#endif
#if (XTEST & 1)
    TestMatrixArith6x(u3,cu3,d1,cd1,"UpperTri/Diag 12");
    TestMatrixArith6x(u1,cu1,d3,cd3,"UpperTri/Diag 13");
    TestMatrixArith6x(u2,cu2,d3,cd3,"UpperTri/Diag 14");
#endif

    tmv::LowerTriMatrixView<T> l1 = a1x.lowerTri();
    tmv::LowerTriMatrixView<CT> cl1 = ca1x.lowerTri();
    tmv::LowerTriMatrixView<T> l2 = a2x.lowerTri();
    tmv::LowerTriMatrixView<CT> cl2 = ca2x.lowerTri();

    TestMatrixArith6(l1,cl1,d1,cd1,l1,cl1,"LowerTri/Diag 1");
#if (XTEST & 2)
    TestMatrixArith6(l2,cl2,d1,cd1,l1,cl1,"LowerTri/Diag 2");
    TestMatrixArith6(l2,cl2,d1,cd1,l2,cl2,"LowerTri/Diag 3");
    TestMatrixArith6(l1,cl1,d1,cd1,l2,cl2,"LowerTri/Diag 4");
#endif
#if (XTEST & 1)
    tmv::LowerTriMatrixView<T> l3 = a3x.subMatrix(0,12,0,16,3,4).lowerTri();
    tmv::LowerTriMatrixView<CT> cl3 = ca3x.subMatrix(0,12,0,16,3,4).lowerTri();
    TestMatrixArith6(l3,cl3,d1,cd1,l1,cl1,"LowerTri/Diag 5");
    TestMatrixArith6(l1,cl1,d3,cd3,l1,cl1,"LowerTri/Diag 6");
    TestMatrixArith6(l2,cl2,d3,cd3,l1,cl1,"LowerTri/Diag 7");
    TestMatrixArith6(l1,cl1,d1,cd1,l3,cl3,"LowerTri/Diag 8");
    TestMatrixArith6(l2,cl2,d1,cd1,l3,cl3,"LowerTri/Diag 9");
#endif
    TestMatrixArith6x(l1,cl1,d1,cd1,"LowerTri/Diag 10");
#if (XTEST & 2)
    TestMatrixArith6x(l2,cl2,d1,cd1,"LowerTri/Diag 11");
#endif
#if (XTEST & 1)
    TestMatrixArith6x(l3,cl3,d1,cd1,"LowerTri/Diag 12");
    TestMatrixArith6x(l1,cl1,d3,cd3,"LowerTri/Diag 13");
    TestMatrixArith6x(l2,cl2,d3,cd3,"LowerTri/Diag 14");
#endif

    tmv::UpperTriMatrixView<T> u4 = a1x.unitUpperTri();
    tmv::UpperTriMatrixView<CT> cu4 = ca1x.unitUpperTri();
    tmv::UpperTriMatrixView<T> u5 = a2x.unitUpperTri();
    tmv::UpperTriMatrixView<CT> cu5 = ca2x.unitUpperTri();

    TestMatrixArith6(u4,cu4,d1,cd1,u1,cu1,"UpperTri/Diag 15");
    TestMatrixArith6(u5,cu5,d1,cd1,u1,cu1,"UpperTri/Diag 16");
    TestMatrixArith6(u4,cu4,d1,cd1,u2,cu2,"UpperTri/Diag 17");
    TestMatrixArith6(u5,cu5,d1,cd1,u2,cu2,"UpperTri/Diag 18");
#if (XTEST & 1)
    tmv::UpperTriMatrixView<T> u6 = a3x.subMatrix(0,12,0,16,3,4).unitUpperTri();
    tmv::UpperTriMatrixView<CT> cu6 = ca3x.subMatrix(0,12,0,16,3,4).unitUpperTri();
    TestMatrixArith6(u6,cu6,d1,cd1,u1,cu1,"UpperTri/Diag 19");
    TestMatrixArith6(u6,cu6,d3,cd3,u1,cu1,"UpperTri/Diag 20");
    TestMatrixArith6(u4,cu4,d3,cd3,u1,cu1,"UpperTri/Diag 21");
    TestMatrixArith6(u5,cu5,d3,cd3,u1,cu1,"UpperTri/Diag 22");
#endif
    TestMatrixArith6x(u4,cu4,d1,cd1,"UpperTri/Diag 23");
#if (XTEST & 2)
    TestMatrixArith6x(u5,cu5,d1,cd1,"UpperTri/Diag 24");
#endif
#if (XTEST & 1)
    TestMatrixArith6x(u6,cu1,d1,cd1,"UpperTri/Diag 25");
    TestMatrixArith6x(u6,cu3,d3,cd3,"UpperTri/Diag 26");
    TestMatrixArith6x(u4,cu4,d3,cd3,"UpperTri/Diag 27");
    TestMatrixArith6x(u5,cu5,d3,cd3,"UpperTri/Diag 28");
#endif

    tmv::LowerTriMatrixView<T> l4 = a1x.unitLowerTri();
    tmv::LowerTriMatrixView<CT> cl4 = ca1x.unitLowerTri();
    tmv::LowerTriMatrixView<T> l5 = a2x.unitLowerTri();
    tmv::LowerTriMatrixView<CT> cl5 = ca2x.unitLowerTri();

    TestMatrixArith6(l4,cl4,d1,cd1,l1,cl1,"LowerTri/Diag 15");
    TestMatrixArith6(l5,cl5,d1,cd1,l1,cl1,"LowerTri/Diag 16");
    TestMatrixArith6(l4,cl4,d1,cd1,l2,cl2,"LowerTri/Diag 17");
    TestMatrixArith6(l5,cl5,d1,cd1,l2,cl2,"LowerTri/Diag 18");
#if (XTEST & 1)
    tmv::LowerTriMatrixView<T> l6 = a3x.subMatrix(0,12,0,16,3,4).unitLowerTri();
    tmv::LowerTriMatrixView<CT> cl6 = ca3x.subMatrix(0,12,0,16,3,4).unitLowerTri();
    TestMatrixArith6(l6,cl6,d1,cd1,l1,cl1,"LowerTri/Diag 19");
    TestMatrixArith6(l6,cl6,d3,cd3,l1,cl1,"LowerTri/Diag 20");
    TestMatrixArith6(l4,cl4,d3,cd3,l1,cl1,"LowerTri/Diag 21");
    TestMatrixArith6(l5,cl5,d3,cd3,l1,cl1,"LowerTri/Diag 22");
#endif
    TestMatrixArith6x(l4,cl4,d1,cd1,"LowerTri/Diag 23");
#if (XTEST & 2)
    TestMatrixArith6x(l5,cl5,d1,cd1,"LowerTri/Diag 24");
#endif
#if (XTEST & 1)
    TestMatrixArith6x(l6,cl1,d1,cd1,"LowerTri/Diag 25");
    TestMatrixArith6x(l6,cl3,d3,cd3,"LowerTri/Diag 26");
    TestMatrixArith6x(l4,cl4,d3,cd3,"LowerTri/Diag 27");
    TestMatrixArith6x(l5,cl5,d3,cd3,"LowerTri/Diag 28");
#endif
}
void TestTriMatrixArith_A6b()
{
    typedef std::complex<T> CT;

    tmv::Matrix<T,tmv::RowMajor> a1x(4,4);
    for(int i=0;i<4;++i) for(int j=0;j<4;++j) {
        a1x(i,j) = T(3+4*i-6*j);
    }
    a1x(0,0) = 14; 
    a1x(1,0) = -2; 
    a1x(2,0) = 7; 
    a1x(3,0) = -10;
    a1x(2,2) = 30;

    tmv::Matrix<CT,tmv::RowMajor> ca1x = a1x;
    ca1x(2,3) += CT(2,3);
    ca1x(1,0) *= CT(0,2);
    ca1x.col(1) *= CT(-1,3);
    ca1x.row(3) += tmv::Vector<CT>(4,CT(1,9));

    tmv::Matrix<T,tmv::ColMajor> a2x = a1x.transpose();
    a2x.row(1) *= T(3);
    a2x.col(2) -= tmv::Vector<T>(4,4);
    tmv::Matrix<CT,tmv::ColMajor> ca2x = ca1x;
    ca2x -= a2x;
    ca2x *= CT(1,-2);
    ca2x(0,0) = CT(0,-5);

    tmv::UpperTriMatrixView<T> u4 = a1x.unitUpperTri();
    tmv::UpperTriMatrixView<CT> cu4 = ca1x.unitUpperTri();
    tmv::UpperTriMatrixView<T> u5 = a2x.unitUpperTri();
    tmv::UpperTriMatrixView<CT> cu5 = ca2x.unitUpperTri();

    TestMatrixArith6(u4,cu4,u4,cu4,u4,cu4,"UpperTri 79");
    TestMatrixArith6(u5,cu5,u5,cu5,u4,cu4,"UpperTri 80");
#if (XTEST & 2)
    TestMatrixArith6(u4,cu4,u5,cu5,u4,cu4,"UpperTri 81");
    TestMatrixArith6(u5,cu5,u4,cu4,u4,cu4,"UpperTri 82");
    TestMatrixArith6(u4,cu4,u5,cu5,u5,cu5,"UpperTri 83");
    TestMatrixArith6(u5,cu5,u4,cu4,u5,cu5,"UpperTri 84");
    TestMatrixArith6(u4,cu4,u4,cu4,u5,cu5,"UpperTri 85");
    TestMatrixArith6(u5,cu5,u5,cu5,u5,cu5,"UpperTri 86");
#endif
#if (XTEST & 1)
    tmv::Matrix<T> a3x(12,16);
    for(int i=0;i<12;++i) for(int j=0;j<16;++j) a3x(i,j) = T(1-2*i+3*j);
    a3x.diag().addToAll(30);
    tmv::Matrix<CT> ca3x = a3x*CT(1,-2);
    ca3x.diag().addToAll(CT(-22,15));

    tmv::UpperTriMatrixView<T> u6 = a3x.subMatrix(0,12,0,16,3,4).unitUpperTri();
    tmv::UpperTriMatrixView<CT> cu6 = ca3x.subMatrix(0,12,0,16,3,4).unitUpperTri();
    TestMatrixArith6(u6,cu6,u4,cu4,u4,cu4,"UpperTri 87");
    TestMatrixArith6(u6,cu6,u5,cu5,u4,cu4,"UpperTri 88");
    TestMatrixArith6(u4,cu4,u6,cu6,u4,cu4,"UpperTri 89");
    TestMatrixArith6(u5,cu5,u6,cu6,u4,cu4,"UpperTri 90");
    TestMatrixArith6(u4,cu4,u4,cu4,u6,cu6,"UpperTri 91");
    TestMatrixArith6(u5,cu5,u5,cu5,u6,cu6,"UpperTri 92");
    TestMatrixArith6(u4,cu4,u5,cu5,u6,cu6,"UpperTri 93");
    TestMatrixArith6(u5,cu5,u4,cu4,u6,cu6,"UpperTri 94");
#endif

    tmv::LowerTriMatrixView<T> l4 = a1x.unitLowerTri();
    tmv::LowerTriMatrixView<CT> cl4 = ca1x.unitLowerTri();
    tmv::LowerTriMatrixView<T> l5 = a2x.unitLowerTri();
    tmv::LowerTriMatrixView<CT> cl5 = ca2x.unitLowerTri();

    TestMatrixArith6(l4,cl4,l4,cl4,l4,cl4,"LowerTri 79");
    TestMatrixArith6(l5,cl5,l5,cl5,l4,cl4,"LowerTri 80");
#if (XTEST & 2)
    TestMatrixArith6(l4,cl4,l5,cl5,l4,cl4,"LowerTri 81");
    TestMatrixArith6(l5,cl5,l4,cl4,l4,cl4,"LowerTri 82");
    TestMatrixArith6(l4,cl4,l5,cl5,l5,cl5,"LowerTri 83");
    TestMatrixArith6(l5,cl5,l4,cl4,l5,cl5,"LowerTri 84");
    TestMatrixArith6(l4,cl4,l4,cl4,l5,cl5,"LowerTri 85");
    TestMatrixArith6(l5,cl5,l5,cl5,l5,cl5,"LowerTri 86");
#endif
#if (XTEST & 1)
    tmv::LowerTriMatrixView<T> l6 = a3x.subMatrix(0,12,0,16,3,4).unitLowerTri();
    tmv::LowerTriMatrixView<CT> cl6 = ca3x.subMatrix(0,12,0,16,3,4).unitLowerTri();
    TestMatrixArith6(l6,cl6,l4,cl4,l4,cl4,"LowerTri 87");
    TestMatrixArith6(l6,cl6,l5,cl5,l4,cl4,"LowerTri 88");
    TestMatrixArith6(l4,cl4,l6,cl6,l4,cl4,"LowerTri 89");
    TestMatrixArith6(l5,cl5,l6,cl6,l4,cl4,"LowerTri 90");
    TestMatrixArith6(l4,cl4,l4,cl4,l6,cl6,"LowerTri 91");
    TestMatrixArith6(l5,cl5,l5,cl5,l6,cl6,"LowerTri 92");
    TestMatrixArith6(l4,cl4,l5,cl5,l6,cl6,"LowerTri 93");
    TestMatrixArith6(l5,cl5,l4,cl4,l6,cl6,"LowerTri 94");
#endif
}