source: ntrip/trunk/BNC/newmat/newmatap.h@ 8938

Last change on this file since 8938 was 8901, checked in by stuerze, 5 years ago

upgrade to newmat11 library

File size: 8.3 KB
Line 
1/// \ingroup newmat
2///@{
3
4/// \file newmatap.h
5/// Definition file for advanced matrix functions.
6
7// Copyright (C) 1991,2,3,4,8: R B Davies
8
9#ifndef NEWMATAP_LIB
10#define NEWMATAP_LIB 0
11
12#include "newmat.h"
13
14#ifdef use_namespace
15namespace NEWMAT {
16#endif
17
18
19// ************************** applications *****************************/
20
21
22void QRZT(Matrix&, LowerTriangularMatrix&);
23
24void QRZT(const Matrix&, Matrix&, Matrix&);
25
26void QRZ(Matrix&, UpperTriangularMatrix&);
27
28void QRZ(const Matrix&, Matrix&, Matrix&);
29
30inline void QRZT(Matrix& X, Matrix& Y, LowerTriangularMatrix& L, Matrix& M)
31 { QRZT(X, L); QRZT(X, Y, M); }
32
33inline void QRZ(Matrix& X, Matrix& Y, UpperTriangularMatrix& U, Matrix& M)
34 { QRZ(X, U); QRZ(X, Y, M); }
35
36inline void HHDecompose(Matrix& X, LowerTriangularMatrix& L)
37{ QRZT(X,L); }
38
39inline void HHDecompose(const Matrix& X, Matrix& Y, Matrix& M)
40{ QRZT(X, Y, M); }
41
42void updateQRZT(Matrix& X, LowerTriangularMatrix& L);
43
44void updateQRZ(Matrix& X, UpperTriangularMatrix& U);
45
46void updateQRZ(const Matrix& X, Matrix& MX, Matrix& MU);
47
48void updateQRZ(UpperTriangularMatrix& X, UpperTriangularMatrix& U);
49
50void updateQRZ(const UpperTriangularMatrix& X, Matrix& MX, Matrix& MU);
51
52inline void UpdateQRZT(Matrix& X, LowerTriangularMatrix& L)
53 { updateQRZT(X, L); }
54
55inline void UpdateQRZ(Matrix& X, UpperTriangularMatrix& U)
56 { updateQRZ(X, U); }
57
58inline void UpdateQRZ(UpperTriangularMatrix& X, UpperTriangularMatrix& U)
59 { updateQRZ(X, U); }
60
61inline void UpdateQRZ(const UpperTriangularMatrix& X, Matrix& MX, Matrix& MU)
62 { updateQRZ(X, MX, MU); }
63
64inline void UpdateQRZ(const Matrix& X, Matrix& MX, Matrix& MU)
65 { updateQRZ(X, MX, MU); }
66
67
68// Matrix A's first n columns are orthonormal
69// so A.Columns(1,n).t() * A.Columns(1,n) is the identity matrix.
70// Fill out the remaining columns of A to make them orthonormal
71// so A.t() * A is the identity matrix
72void extend_orthonormal(Matrix& A, int n);
73
74
75ReturnMatrix Cholesky(const SymmetricMatrix&);
76
77ReturnMatrix Cholesky(const SymmetricBandMatrix&);
78
79
80// produces the Cholesky decomposition of A + x.t() * x
81// where A = chol.t() * chol and x is a RowVector
82void update_Cholesky(UpperTriangularMatrix& chol, RowVector x);
83inline void UpdateCholesky(UpperTriangularMatrix& chol, const RowVector& x)
84 { update_Cholesky(chol, x); }
85
86// produces the Cholesky decomposition of A - x.t() * x
87// where A = chol.t() * chol and x is a RowVector
88void downdate_Cholesky(UpperTriangularMatrix &chol, RowVector x);
89inline void DowndateCholesky(UpperTriangularMatrix &chol, const RowVector& x)
90 { downdate_Cholesky(chol, x); }
91
92// a RIGHT circular shift of the rows and columns from
93// 1,...,k-1,k,k+1,...l,l+1,...,p to
94// 1,...,k-1,l,k,k+1,...l-1,l+1,...p
95void right_circular_update_Cholesky(UpperTriangularMatrix &chol, int k, int l);
96inline void RightCircularUpdateCholesky(UpperTriangularMatrix &chol,
97 int k, int l) { right_circular_update_Cholesky(chol, k, l); }
98
99// a LEFT circular shift of the rows and columns from
100// 1,...,k-1,k,k+1,...l,l+1,...,p to
101// 1,...,k-1,k+1,...l,k,l+1,...,p to
102void left_circular_update_Cholesky(UpperTriangularMatrix &chol, int k, int l);
103inline void LeftCircularUpdateCholesky(UpperTriangularMatrix &chol,
104 int k, int l) { left_circular_update_Cholesky(chol, k, l); }
105
106
107void SVD(const Matrix&, DiagonalMatrix&, Matrix&, Matrix&,
108 bool=true, bool=true);
109
110void SVD(const Matrix&, DiagonalMatrix&);
111
112inline void SVD(const Matrix& A, DiagonalMatrix& D, Matrix& U,
113 bool withU = true) { SVD(A, D, U, U, withU, false); }
114
115void SortSV(DiagonalMatrix& D, Matrix& U, bool ascending = false);
116
117void SortSV(DiagonalMatrix& D, Matrix& U, Matrix& V, bool ascending = false);
118
119void Jacobi(const SymmetricMatrix&, DiagonalMatrix&);
120
121void Jacobi(const SymmetricMatrix&, DiagonalMatrix&, SymmetricMatrix&);
122
123void Jacobi(const SymmetricMatrix&, DiagonalMatrix&, Matrix&);
124
125void Jacobi(const SymmetricMatrix&, DiagonalMatrix&, SymmetricMatrix&,
126 Matrix&, bool=true);
127
128void eigenvalues(const SymmetricMatrix&, DiagonalMatrix&);
129
130void eigenvalues(const SymmetricMatrix&, DiagonalMatrix&, SymmetricMatrix&);
131
132void eigenvalues(const SymmetricMatrix&, DiagonalMatrix&, Matrix&);
133
134inline void EigenValues(const SymmetricMatrix& A, DiagonalMatrix& D)
135 { eigenvalues(A, D); }
136
137inline void EigenValues(const SymmetricMatrix& A, DiagonalMatrix& D,
138 SymmetricMatrix& S) { eigenvalues(A, D, S); }
139
140inline void EigenValues(const SymmetricMatrix& A, DiagonalMatrix& D, Matrix& V)
141 { eigenvalues(A, D, V); }
142
143class SymmetricEigenAnalysis
144// not implemented yet
145{
146public:
147 SymmetricEigenAnalysis(const SymmetricMatrix&);
148private:
149 DiagonalMatrix diag;
150 DiagonalMatrix offdiag;
151 SymmetricMatrix backtransform;
152 FREE_CHECK(SymmetricEigenAnalysis)
153};
154
155void sort_ascending(GeneralMatrix&);
156
157void sort_descending(GeneralMatrix&);
158
159inline void SortAscending(GeneralMatrix& gm) { sort_ascending(gm); }
160
161inline void SortDescending(GeneralMatrix& gm) { sort_descending(gm); }
162
163/// Decide which fft method to use and carry out new fft function
164class FFT_Controller
165{
166public:
167 static bool OnlyOldFFT;
168 static bool ar_1d_ft (int PTS, Real* X, Real *Y);
169 static bool CanFactor(int PTS);
170};
171
172void FFT(const ColumnVector&, const ColumnVector&,
173 ColumnVector&, ColumnVector&);
174
175void FFTI(const ColumnVector&, const ColumnVector&,
176 ColumnVector&, ColumnVector&);
177
178void RealFFT(const ColumnVector&, ColumnVector&, ColumnVector&);
179
180void RealFFTI(const ColumnVector&, const ColumnVector&, ColumnVector&);
181
182void DCT_II(const ColumnVector&, ColumnVector&);
183
184void DCT_II_inverse(const ColumnVector&, ColumnVector&);
185
186void DST_II(const ColumnVector&, ColumnVector&);
187
188void DST_II_inverse(const ColumnVector&, ColumnVector&);
189
190void DCT(const ColumnVector&, ColumnVector&);
191
192void DCT_inverse(const ColumnVector&, ColumnVector&);
193
194void DST(const ColumnVector&, ColumnVector&);
195
196void DST_inverse(const ColumnVector&, ColumnVector&);
197
198void FFT2(const Matrix& U, const Matrix& V, Matrix& X, Matrix& Y);
199
200void FFT2I(const Matrix& U, const Matrix& V, Matrix& X, Matrix& Y);
201
202
203// This class is used by the new FFT program
204
205// Suppose an integer is expressed as a sequence of digits with each
206// digit having a different radix.
207// This class supposes we are counting with this multi-radix number
208// but also keeps track of the number with the digits (and radices)
209// reversed.
210// The integer starts at zero
211// operator++() increases it by 1
212// Counter gives the number of increments
213// Reverse() gives the value with the digits in reverse order
214// Swap is true if reverse is less than counter
215// Finish is true when we have done a complete cycle and are back at zero
216
217class MultiRadixCounter
218{
219 const SimpleIntArray& Radix;
220 // radix of each digit
221 // n-1 highest order, 0 lowest order
222 SimpleIntArray& Value; // value of each digit
223 const int n; // number of digits
224 int reverse; // value when order of digits is reversed
225 int product; // product of radices
226 int counter; // counter
227 bool finish; // true when we have gone over whole range
228public:
229 MultiRadixCounter(int nx, const SimpleIntArray& rx,
230 SimpleIntArray& vx);
231 void operator++(); // increment the multi-radix counter
232 bool Swap() const { return reverse < counter; }
233 bool Finish() const { return finish; }
234 int Reverse() const { return reverse; }
235 int Counter() const { return counter; }
236};
237
238// multiplication by Helmert matrix
239ReturnMatrix Helmert(int n, bool full=false);
240ReturnMatrix Helmert(const ColumnVector& X, bool full=false);
241ReturnMatrix Helmert(int n, int j, bool full=false);
242ReturnMatrix Helmert_transpose(const ColumnVector& Y, bool full=false);
243Real Helmert_transpose(const ColumnVector& Y, int j, bool full=false);
244ReturnMatrix Helmert(const Matrix& X, bool full=false);
245ReturnMatrix Helmert_transpose(const Matrix& Y, bool full=false);
246
247
248
249
250#ifdef use_namespace
251}
252#endif
253
254
255
256#endif
257
258// body file: cholesky.cpp
259// body file: evalue.cpp
260// body file: fft.cpp
261// body file: hholder.cpp
262// body file: jacobi.cpp
263// body file: newfft.cpp
264// body file: sort.cpp
265// body file: svd.cpp
266// body file: nm_misc.cpp
267
268
269
270///@}
271
272
Note: See TracBrowser for help on using the repository browser.