newmatap.h

00001 //$$ newmatap.h           definition file for matrix package applications
00002 
00003 // Copyright (C) 1991,2,3,4,8: R B Davies
00004 
00005 #ifndef NEWMATAP_LIB
00006 #define NEWMATAP_LIB 0
00007 
00008 #include "newmat.h"
00009 
00010 #ifdef use_namespace
00011 namespace NEWMAT {
00012 #endif
00013 
00014 
00015 // ************************** applications *****************************/
00016 
00017 
00018 void QRZT(Matrix&, LowerTriangularMatrix&);
00019 
00020 void QRZT(const Matrix&, Matrix&, Matrix&);
00021 
00022 void QRZ(Matrix&, UpperTriangularMatrix&);
00023 
00024 void QRZ(const Matrix&, Matrix&, Matrix&);
00025 
00026 inline void HHDecompose(Matrix& X, LowerTriangularMatrix& L)
00027 { QRZT(X,L); }
00028 
00029 inline void HHDecompose(const Matrix& X, Matrix& Y, Matrix& M)
00030 { QRZT(X, Y, M); }
00031 
00032 void UpdateQRZT(Matrix& X, LowerTriangularMatrix& L);
00033 
00034 void UpdateQRZ(Matrix& X, UpperTriangularMatrix& U);
00035 
00036 // Matrix A's first n columns are orthonormal
00037 // so A.Columns(1,n).t() * A.Columns(1,n) is the identity matrix.
00038 // Fill out the remaining columns of A to make them orthonormal
00039 // so A.t() * A is the identity matrix 
00040 void extend_orthonormal(Matrix& A, int n);
00041 
00042 
00043 ReturnMatrix Cholesky(const SymmetricMatrix&);
00044 
00045 ReturnMatrix Cholesky(const SymmetricBandMatrix&);
00046 
00047 
00048 // produces the Cholesky decomposition of A + x.t() * x where A = chol.t() * chol
00049 // and x is a RowVector
00050 void UpdateCholesky(UpperTriangularMatrix &chol, RowVector r1Modification);
00051 
00052 // produces the Cholesky decomposition of A - x.t() * x where A = chol.t() * chol
00053 // and x is a RowVector
00054 void DowndateCholesky(UpperTriangularMatrix &chol, RowVector x);
00055 
00056 // a RIGHT circular shift of the rows and columns from
00057 // 1,...,k-1,k,k+1,...l,l+1,...,p to
00058 // 1,...,k-1,l,k,k+1,...l-1,l+1,...p
00059 void RightCircularUpdateCholesky(UpperTriangularMatrix &chol, int k, int l);
00060 
00061 // a LEFT circular shift of the rows and columns from
00062 // 1,...,k-1,k,k+1,...l,l+1,...,p to
00063 // 1,...,k-1,k+1,...l,k,l+1,...,p to
00064 void LeftCircularUpdateCholesky(UpperTriangularMatrix &chol, int k, int l); 
00065 
00066 
00067 void SVD(const Matrix&, DiagonalMatrix&, Matrix&, Matrix&,
00068     bool=true, bool=true);
00069 
00070 void SVD(const Matrix&, DiagonalMatrix&);
00071 
00072 inline void SVD(const Matrix& A, DiagonalMatrix& D, Matrix& U,
00073    bool withU = true) { SVD(A, D, U, U, withU, false); }
00074 
00075 void SortSV(DiagonalMatrix& D, Matrix& U, bool ascending = false);
00076 
00077 void SortSV(DiagonalMatrix& D, Matrix& U, Matrix& V, bool ascending = false);
00078 
00079 void Jacobi(const SymmetricMatrix&, DiagonalMatrix&);
00080 
00081 void Jacobi(const SymmetricMatrix&, DiagonalMatrix&, SymmetricMatrix&);
00082 
00083 void Jacobi(const SymmetricMatrix&, DiagonalMatrix&, Matrix&);
00084 
00085 void Jacobi(const SymmetricMatrix&, DiagonalMatrix&, SymmetricMatrix&,
00086    Matrix&, bool=true);
00087 
00088 void EigenValues(const SymmetricMatrix&, DiagonalMatrix&);
00089 
00090 void EigenValues(const SymmetricMatrix&, DiagonalMatrix&, SymmetricMatrix&);
00091 
00092 void EigenValues(const SymmetricMatrix&, DiagonalMatrix&, Matrix&);
00093 
00094 class SymmetricEigenAnalysis
00095 // not implemented yet
00096 {
00097 public:
00098    SymmetricEigenAnalysis(const SymmetricMatrix&);
00099 private:
00100    DiagonalMatrix diag;
00101    DiagonalMatrix offdiag;
00102    SymmetricMatrix backtransform;
00103    FREE_CHECK(SymmetricEigenAnalysis)
00104 };
00105 
00106 void SortAscending(GeneralMatrix&);
00107 
00108 void SortDescending(GeneralMatrix&);
00109 
00110 
00111 // class for deciding which fft to use and containing new fft function
00112 class FFT_Controller
00113 {
00114 public:
00115    static bool OnlyOldFFT;
00116    static bool ar_1d_ft (int PTS, Real* X, Real *Y);
00117    static bool CanFactor(int PTS);
00118 };
00119 
00120 void FFT(const ColumnVector&, const ColumnVector&,
00121    ColumnVector&, ColumnVector&);
00122 
00123 void FFTI(const ColumnVector&, const ColumnVector&,
00124    ColumnVector&, ColumnVector&);
00125 
00126 void RealFFT(const ColumnVector&, ColumnVector&, ColumnVector&);
00127 
00128 void RealFFTI(const ColumnVector&, const ColumnVector&, ColumnVector&);
00129 
00130 void DCT_II(const ColumnVector&, ColumnVector&);
00131 
00132 void DCT_II_inverse(const ColumnVector&, ColumnVector&);
00133 
00134 void DST_II(const ColumnVector&, ColumnVector&);
00135 
00136 void DST_II_inverse(const ColumnVector&, ColumnVector&);
00137 
00138 void DCT(const ColumnVector&, ColumnVector&);
00139 
00140 void DCT_inverse(const ColumnVector&, ColumnVector&);
00141 
00142 void DST(const ColumnVector&, ColumnVector&);
00143 
00144 void DST_inverse(const ColumnVector&, ColumnVector&);
00145 
00146 void FFT2(const Matrix& U, const Matrix& V, Matrix& X, Matrix& Y);
00147 
00148 void FFT2I(const Matrix& U, const Matrix& V, Matrix& X, Matrix& Y);
00149 
00150 
00151 // This class is used by the new FFT program
00152 
00153 // Suppose an integer is expressed as a sequence of digits with each
00154 // digit having a different radix.
00155 // This class supposes we are counting with this multi-radix number
00156 // but also keeps track of the number with the digits (and radices)
00157 // reversed.
00158 // The integer starts at zero
00159 // operator++() increases it by 1
00160 // Counter gives the number of increments
00161 // Reverse() gives the value with the digits in reverse order
00162 // Swap is true if reverse is less than counter
00163 // Finish is true when we have done a complete cycle and are back at zero
00164 
00165 class MultiRadixCounter
00166 {
00167    const SimpleIntArray& Radix;
00168                               // radix of each digit
00169                               // n-1 highest order, 0 lowest order
00170    SimpleIntArray& Value;     // value of each digit
00171    const int n;               // number of digits
00172    int reverse;               // value when order of digits is reversed
00173    int product;               // product of radices
00174    int counter;               // counter
00175    bool finish;               // true when we have gone over whole range
00176 public:
00177    MultiRadixCounter(int nx, const SimpleIntArray& rx,
00178       SimpleIntArray& vx);
00179    void operator++();         // increment the multi-radix counter
00180    bool Swap() const { return reverse < counter; }
00181    bool Finish() const { return finish; }
00182    int Reverse() const { return reverse; }
00183    int Counter() const { return counter; }
00184 };
00185 
00186 
00187 #ifdef use_namespace
00188 }
00189 #endif
00190 
00191 
00192 
00193 #endif
00194 
00195 // body file: cholesky.cpp
00196 // body file: evalue.cpp
00197 // body file: fft.cpp
00198 // body file: hholder.cpp
00199 // body file: jacobi.cpp
00200 // body file: newfft.cpp
00201 // body file: sort.cpp
00202 // body file: svd.cpp
00203 
00204 
00205 
00206 
00207 
Generated on Mon Jan 24 12:04:37 2011 for FASTlib by  doxygen 1.6.3