source: Sophya/trunk/SophyaLib/TArray/toeplitzMatrix.h@ 2888

Last change on this file since 2888 was 2806, checked in by ansari, 20 years ago

MAJ documentation+ namespace pour module TArray - Reza 9 Juin 2005

File size: 5.3 KB
Line 
1#ifndef TOEPLITZMATRIX_SEEN
2#define TOEPLITZMATRIX_SEEN
3
4
5
6// matrice de Toeplitz reelle ou complexe
7//------------------------------------------------------------------
8// ***** Guy Le Meur -- LAL-Orsay mars 2002 ****************
9//-------------------------------------------------------------------
10
11
12#include "machdefs.h" // Definitions specifiques SOPHYA
13
14#include <math.h>
15#include <iostream>
16
17#include "nbmath.h"
18#include "timing.h"
19
20#include "array.h"
21
22#include "fftservintf.h"
23#include "fftpserver.h"
24
25// classe pour decrire une matrice de Toeplitz reelle ou complexe,
26// symetrique (hermitienne) ou non.
27// Methodes de gradient conjugues pour resolution de systemes (uniquement
28// pour symetriques ou hermitiennes, pour le moment)
29
30namespace SOPHYA {
31
32class Toeplitz
33{
34
35 private:
36 // verouiller le clonage
37Toeplitz(const Toeplitz&) {}
38Toeplitz &operator = (const Toeplitz&) {return *this;}
39
40public:
41
42Toeplitz();
43Toeplitz(const TVector<complex<double> >& firstCol);
44
45~Toeplitz();
46
47 // toeplitz complexe generale
48 void setMatrix(const TVector<complex<double> >& firstCol, const TVector<complex<double> >& firstRow);
49 // toeplitz hermitienne
50 void setMatrix(const TVector<complex<double> >& firstCol);
51 // toeplitz reelle generale
52 void setMatrix(const TVector<double>& firstCol, const TVector<double>& firstRow);
53 // toeplitz reelle symetrique
54 void setMatrix(const TVector<double>& firstCol);
55
56
57 int gradientToeplitz(TVector<complex<double> >& b) const;
58 int gradientToeplitz(TVector<double>& b) const;
59
60 int gradientToeplitzPreconTChang(TVector<complex<double> >& b) const;
61
62 int CGSToeplitz(TVector<double>& b) const;
63 int DCGToeplitz(TVector<double>& b) ;
64
65private:
66
67inline complex<double> prodScalaire(int n, TVector<complex<double> >& v1, TVector<complex<double> >& v2) const
68{
69 complex<double> produit = complex<double>(0.,0.);
70 for (int k =0; k<n; k++) produit += v1(k)*conj(v2(k));
71 return produit;
72}
73inline double prodScalaire(int n, TVector<double>& v1, TVector<double>& v2) const
74{
75 double produit = 0.;
76 for (int k =0; k<n; k++) produit += v1(k)*v2(k);
77 return produit;
78}
79
80
81inline void transformeeFourier(const TVector<complex<double> >& v, TVector< complex<double> >& tv) const
82{
83 fftIntfPtr_-> FFTForward(v, tv);
84}
85inline void transformeeFourier(const TVector<double>& v, TVector< complex<double> >& tv) const
86{
87 fftIntfPtr_-> FFTForward(v, tv);
88}
89
90
91inline void transformeeInverseFourier(const TVector<complex<double> >& tv, TVector<complex<double> >& v) const
92{
93 int n= tv.Size();
94 fftIntfPtr_-> FFTBackward(tv, v);
95 v/=n;
96}
97inline void transformeeInverseFourier(const TVector<complex<double> >& tv, TVector<double>& v) const
98{
99 int n= tv.Size();
100 fftIntfPtr_-> FFTBackward(tv, v);
101 double fac = 1./(2*(n-1));
102 v *= fac;
103}
104
105inline void initTFTransposeeToeplitzComplexe()
106{
107 int k;
108 int ndyad = vecteurCirculant_.Size();
109 TVector<complex<double> > vecteurCirculantTranspose(ndyad);
110 vecteurCirculantTranspose = complex<double>(0.,0.);
111 vecteurCirculantTranspose(0) = vecteurCirculant_(0);
112 for (k=1; k< dimTop_; k++)
113 {
114 vecteurCirculantTranspose(k) = vecteurCirculant_(ndyad-k);
115 vecteurCirculantTranspose(ndyad-k) = vecteurCirculant_(k);
116 }
117
118 transformeeFourier(vecteurCirculantTranspose, CirculanteTransposeeFourier_);
119}
120inline void initTFTransposeeToeplitzReelle()
121{
122 int k;
123 int ndyad = vecteurCirculantD_.Size();
124 TVector<double> vecteurCirculantTranspose(ndyad);
125 vecteurCirculantTranspose = 0.;
126 vecteurCirculantTranspose(0) = vecteurCirculantD_(0);
127 for (k=1; k< dimTop_; k++)
128 {
129 vecteurCirculantTranspose(k) = vecteurCirculantD_(ndyad-k);
130 vecteurCirculantTranspose(ndyad-k) = vecteurCirculantD_(k);
131 }
132
133 transformeeFourier(vecteurCirculantTranspose, CirculanteTransposeeFourier_);
134}
135
136void extensionACirculanteDyadique(const TVector<complex<double> >& firstCol, const TVector<complex<double> >& firstRow);
137
138void extensionACirculanteDyadique(const TVector<double>& firstCol, const TVector<double>& firstRow);
139void extensionACirculanteDyadique(const TVector<complex<double> >& firstCol);
140
141void extensionACirculanteDyadique(const TVector<double>& firstCol);
142
143
144// matrice circulante entree par sa T. de Fourier
145void produitParVecFourier(const TVector<complex<double> >& q, TVector<complex<double> >& Tq) const;
146void produitParVecFourier(const TVector<double>& q, TVector<double>& Tq) const;
147
148void produitTransposeeParVecFourier(const TVector<double>& q, TVector<double>& Tq) const;
149
150
151// preconditionneur pour une Toeplitz HERMITIENNE
152// LE RESUTAT EST UNE TRANSFORMEE DE FOURIER
153void fabricationTChangPreconHerm(TVector<complex<double> >& TFourierC) const;
154
155// matrice circulante entree par sa T. de Fourier
156void inverseSystemeCirculantFourier(const TVector<complex<double> >& TFourierC, const TVector<complex<double> >& secondMembre, TVector<complex<double> >& resul) const;
157
158
159void expliciteCirculante(TMatrix<complex<double> >& m) const;
160void expliciteToeplitz(TMatrix<complex<double> >& m) const;
161void expliciteToeplitz(TMatrix<double>& m) const;
162
163
164 bool hermitian_;
165 int dimTop_;
166 TVector<complex<double> > vecteurCirculant_;
167 TVector<double> vecteurCirculantD_;
168 TVector<complex<double> > CirculanteFourier_;
169 TVector<complex<double> > CirculanteTransposeeFourier_;
170 FFTServerInterface* fftIntfPtr_;
171};
172
173
174// fin classe Toeplitz
175
176
177} // Fin du namespace
178
179#endif
Note: See TracBrowser for help on using the repository browser.