Example: Passing Mat or Vec as function argument

/*
 * Expression Template Matrix Library
 *
 * Copyright (C) 2004 - 2004 Ricky Lung <mtlung@users.sourceforge.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

/*
 *  Demonstrate the use of matrix/matrix expression as a
 *  function parameter
 */

#include <iostream>
#include <complex>
#include "../include/exmat.h"

using namespace std;
using namespace exmat;

// A dense matrix of static size 3x3, with double complex as the element type
//typedef Mat<DenseMatCon<std::complex<double>,3,3> > Mat3x3;
typedef Mat<DenseMatCon<float,3,3> > Mat3x3;

void testOutM(const Mat3x3& m) {
    cout << m << endl;
}

void testMM(Mat3x3& res, const Mat3x3& m1, const Mat3x3& m2) {
    res = trans(m1) * m2;
}

// Function with matrix expression as parameter
template<class REP, class ErrChk>
void testExpMat(Mat3x3& res, const Mat<REP, ErrChk>& exp) {
    res = exp + exp;
}

int main()
{
    Mat3x3 m1, m2, m3;

    m1 = 1,4,7,
         2,5,8,
         3,6,9;
    m2 = m1;

    testMM(m3, m1, m2);
    testOutM(m1);
    cout << "*\n";
    testOutM(m2);
    cout << "=\n";
    testOutM(m3);

    testExpMat(m3, m1*m2);
    testOutM(m3);

    return 0;
}

Generated on Sat May 6 23:12:04 2006 for Exmat by  doxygen 1.4.6-NO