ExpInfo.h

Go to the documentation of this file.
00001 /*
00002  * Expression Template Matrix Library
00003  *
00004  * Copyright (C) 2004 - 2006 Ricky Lung <mtlung@users.sourceforge.net>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00030 #ifdef _MSC_VER
00031 #pragma once
00032 #endif  // _MSC_VER
00033 
00034 #ifndef _EXMAT_EXPINFO_H
00035 #define _EXMAT_EXPINFO_H
00036 
00037 #include <iostream>
00038 #include "ExpTmp.h"
00039 
00040 namespace exmat {
00041 
00042 template<class EXP>
00043 class ExpInfo {
00044 public:
00045     ExpInfo(const EXP& exp_) : exp(exp_) {}
00046 private:
00047     const EXP& exp;
00048 };
00049 
00050 template<class EXP>
00051 void printExpInfo(const EXP& exp) {
00052     using std::cout;
00053     using std::endl;
00054 
00055     enum {
00056         IsScalar = HasTagOf<EXP,ScalarTag>::RET,
00057         IsRowVec = (EXP::ROWS == 1),
00058         IsColVec = (EXP::COLS == 1),
00059         IsRowStatic = (EXP::ROWS > 0),
00060         IsColStatic = (EXP::COLS > 0),
00061         IsRowMajor = HasTagOf<EXP,RowMajorTag>::RET,
00062         IsColMajor = HasTagOf<EXP,ColMajorTag>::RET
00063     };
00064 
00065     typedef typename EXP::ErrChecker ErrChecker;
00066     cout << "Error checker: " << (
00067         ISSAMETYPE<ErrChecker, EmptyErrorChecker>::RET ? "EmptyErrorChecker" :
00068         ISSAMETYPE<ErrChecker, DefaultErrorChecker>::RET ? "DefaultErrorChecker" :
00069         "FullErrorChecker"
00070         )<< endl;
00071     if(IsRowVec) cout << "It's a row vector\n";
00072     else if(IsColVec) cout << "It's a column vector\n";
00073     cout << "Rows: " << (IsRowStatic ? "static, " : "dynamic, ") << exp.rows() << endl;
00074     cout << "Cols: " << (IsColStatic ? "static, " : "dynamic, ") << exp.cols() << endl;
00075     cout << "TNOP: " << EXP::TNOP << endl;
00076 
00077     if(IsRowMajor)
00078         cout << "It's row major\n";
00079     if(IsColMajor)
00080         cout << "It's row major\n";
00081 //  cout << "Required temporaries: " <<
00082 //      typeid(typename TmpAnalyser<EXP, ::Loki::NullType>::longest_list).name() << endl;
00083 }
00084 
00085 };
00086 
00087 
00088 /************************************************/
00089 // I/O operators
00090 template<class EXP>
00091 std::ostream& operator<<(std::ostream &os, const exmat::ExpInfo<EXP>& expinfo) {
00092     return os;
00093 }
00094 
00095 #endif  // _EXMAT_EXPINFO_H

Generated on Sat May 6 23:11:55 2006 for Exmat by  doxygen 1.4.6-NO