Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

matrix.h

Go to the documentation of this file.
00001 /*-*-c++-*-****************************************************************
00002  *                     matrix.h Matrix class 
00003                        -------------------
00004  begin                : Feb 2003
00005  copyright            : (C) 2003 by Christian Stimming
00006  email                : stimming@tuhh.de
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00039 #ifndef MATRIX_H
00040 #define MATRIX_H
00041 
00042 #define LA_COMPLEX_SUPPORT
00043 
00044 // activate bounds check for lapack++
00045 #if DEBUG
00046 # define LA_BOUNDS_CHECK
00047 # define VECTOR_DOUBLE_BOUNDS_CHECK
00048 #endif //DEBUG
00049 
00050 #include <simthetic/misc.h>
00051 #include <simthetic/signals.h>
00052 
00053 #include <lafnames.h>       /* macros for LAPACK++ filenames */
00054 #include <lapack.h>
00055 #include LA_GEN_MAT_DOUBLE_H
00056 #include LA_VECTOR_DOUBLE_H 
00057 #include LA_GEN_MAT_COMPLEX_H
00058 #include LA_VECTOR_COMPLEX_H
00059 #include LA_VECTOR_LONG_INT_H
00060 #include <blas++.h>
00061 #include LA_SOLVE_DOUBLE_H
00062 #include LA_EXCEPTION_H
00063 #include LA_UTIL_H
00064 #include <lacomplex.h>
00065 
00077 namespace mimo 
00078 {
00081    typedef LaComplex Complex;
00082 
00084    typedef LaGenMatDouble Matrix;
00085 
00087    typedef LaVectorDouble Vector;
00088 
00110    typedef LaGenMatComplex CMatrix;
00111 
00132    typedef LaVectorComplex CVector;
00133 } // namespace mimo
00134 
00135 namespace mimo
00136 {
00139 
00156    inline int real_size(const CMatrix &, int complex_size)
00157    { return complex_size; }
00158 
00197    inline const Complex &c_assign(CMatrix &A, int i, int j, 
00198                   const Complex &c);
00199 
00228    inline Complex c_access(const CMatrix &A, int i, int j);
00229 
00231    std::ostream& c_print(std::ostream& s, const CMatrix& G);
00232 
00250    inline int c_size(const CMatrix &A, int dim);
00251 
00252 
00255    CMatrix c_eye(int i);
00258    CMatrix c_zeros(int i, int j);
00261    CMatrix c_ones(int i, int j);
00262 
00293    inline const Complex &c_add_s(CMatrix &A, int i, int j, const Complex&c);
00294 
00298    simth::Complex c_det(const CMatrix& A);
00299    
00300 
00302 
00305 
00307    Matrix eye(int i);
00309    Matrix zeros(int i, int j);
00311    Matrix ones(int i, int j);
00312 
00315    double det(const Matrix& A);
00316 
00318 
00319 
00354    inline const Complex &c_assign(CVector &A, int i, const Complex &c);
00355 
00383    inline Complex c_access(const CVector &A, int i);
00384 
00386    std::ostream& c_print(std::ostream& s, const CVector& G);
00387 
00390    inline int c_size(const CVector &A);
00391 
00422    inline const Complex &c_add_s(CVector &a, int i, const Complex&c);
00423 
00426    CVector c_ones(int i);
00429    CVector c_zeros(int i);
00431    Vector zeros(int i);
00432 
00434 
00444    inline
00445    void Blas_Add_Mult(CVector &dy, const Complex& c, 
00446               const CVector &dx)
00447    { ::Blas_Add_Mult(dy, c.toCOMPLEX(), dx); }
00448 
00450    inline
00451    void Blas_Mult(CVector &dy, const Complex& c, 
00452           const CVector &dx)
00453    { ::Blas_Mult(dy, c, dx); }
00454 
00456    inline
00457    void Blas_Scale(const Complex& c, CVector &dx)
00458    { ::Blas_Scale(c, dx); }
00459 
00463    inline
00464    Complex Blas_Dot_Prod(const CVector &dx, const CVector &dy)
00465    { return ::Blas_H_Dot_Prod(dx, dy); }
00466 
00467 
00470    inline
00471    void Blas_R1_Update(CMatrix &A, const CVector &dx, 
00472                const CVector &dy, const Complex& alpha)
00473    { ::Blas_R1_Update(A, dx, dy, alpha); }
00474 
00482     double Blas_NormF(const CMatrix &A);
00483 
00491     double Blas_NormF(const Matrix &A);
00492 
00503    double Blas_Cond(const CMatrix &a, double threshold = 0.0);
00504 
00519    unsigned Blas_Rank(const CMatrix &a, double threshold = 0.0);
00520 
00521 
00526    double Blas_NormF_squared(const CMatrix &A);
00527 
00531    void Mat_Add_Norm(Matrix &A, const CMatrix &B);
00534 } // namespace mimo
00535 
00536 // //////////////////////////////////
00537 // CMatrix definitions
00538 // //////////////////////////////////
00539 
00540 #ifndef DOXYGEN_IGNORE
00541 
00542 
00543 inline const mimo::Complex &mimo::c_assign(CMatrix &A, int i, int j, const mimo::Complex &c)
00544 {
00545    A(i,j) = c;
00546    return c;
00547 }
00548 inline mimo::Complex mimo::c_access(const CMatrix &A, int i, int j)
00549 {
00550    return mimo::Complex(A(i,j));
00551 }
00552 inline const mimo::Complex &mimo::c_assign(CVector &A, int i, const mimo::Complex &c)
00553 {
00554    A(i)  =  c;
00555    return c;
00556 }
00557 inline mimo::Complex mimo::c_access(const CVector &A, int i)
00558 {
00559    return mimo::Complex(A(i));
00560 }
00561 
00562 inline int mimo::c_size(const CMatrix &A, int dim)
00563 {
00564    return A.size(dim); 
00565 }
00566 inline int mimo::c_size(const CVector &A)
00567 {
00568    return A.size(); 
00569 }
00570 inline const mimo::Complex &mimo::c_add_s(CVector &A, int i, const mimo::Complex&c)
00571 {
00572    A(i) = Complex(A(i)) + c;
00573    return c;
00574 }
00575 inline const mimo::Complex &mimo::c_add_s(CMatrix &A, int i, int j, const mimo::Complex&c)
00576 {
00577    A(i,j) = Complex(A(i,j)) + c;
00578    return c;
00579 }
00580 
00581 #endif // DOXYGEN_IGNORE
00582 
00583 #endif // MATRIX_H

Generated on Tue Aug 9 14:43:09 2005 for mimolib by  doxygen 1.4.1