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
00026
00027
00039 #ifndef MATRIX_H
00040 #define MATRIX_H
00041
00042 #define LA_COMPLEX_SUPPORT
00043
00044
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>
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 }
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 }
00535
00536
00537
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