[585] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Adaptateurs pour TMatrix TVector du package Sophya
|
---|
| 3 | // R. Ansari 1/99
|
---|
| 4 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 5 |
|
---|
| 6 | #ifndef PITVMAAD_H_SEEN
|
---|
| 7 | #define PITVMAAD_H_SEEN
|
---|
| 8 |
|
---|
| 9 | #include "machdefs.h"
|
---|
| 10 | #include <math.h>
|
---|
| 11 | #include "parradapter.h"
|
---|
| 12 |
|
---|
| 13 | #include "tmatrix.h"
|
---|
| 14 | #include "tvector.h"
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | // Adaptateur de vecteurs SOPHYA a P1DArrayAdapter
|
---|
| 18 | template <class T>
|
---|
| 19 | class POTVectorAdapter : public P1DArrayAdapter {
|
---|
| 20 | public :
|
---|
| 21 | POTVectorAdapter(TVector<T>* v, bool ad=false)
|
---|
| 22 | : P1DArrayAdapter(v->NElts())
|
---|
| 23 | { aDel = ad; mVec = v; }
|
---|
| 24 | virtual ~POTVectorAdapter()
|
---|
| 25 | { if (aDel) delete mVec; }
|
---|
| 26 | virtual double Value(int i)
|
---|
| 27 | { return((*mVec)(i)); }
|
---|
| 28 |
|
---|
| 29 | protected:
|
---|
| 30 | bool aDel;
|
---|
| 31 | TVector<T>* mVec;
|
---|
| 32 | };
|
---|
| 33 |
|
---|
| 34 | typedef POTVectorAdapter<r_8> POVectorAdapter;
|
---|
| 35 |
|
---|
| 36 | double POTVectorAdapter< complex<float> >::Value(int i)
|
---|
| 37 | {
|
---|
| 38 | double re,im;
|
---|
| 39 | re = (*mVec)(i).real();
|
---|
| 40 | im = (*mVec)(i).imag();
|
---|
| 41 | return(sqrt(re*re+im*im));
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | double POTVectorAdapter< complex<double> >::Value(int i)
|
---|
| 45 | {
|
---|
| 46 | double re,im;
|
---|
| 47 | re = (*mVec)(i).real();
|
---|
| 48 | im = (*mVec)(i).imag();
|
---|
| 49 | return(sqrt(re*re+im*im));
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | // Adaptateur de matrice SOPHYA a P2DArrayAdapter
|
---|
| 53 | // Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col)
|
---|
| 54 | template <class T>
|
---|
| 55 | class POTMatrixAdapter : public P2DArrayAdapter {
|
---|
| 56 | public :
|
---|
| 57 | POTMatrixAdapter(TMatrix<T>* mtx, bool ad=false)
|
---|
| 58 | : P2DArrayAdapter(mtx->NCols(), mtx->NRows())
|
---|
| 59 | { aDel = ad; mMtx = mtx; }
|
---|
| 60 | virtual ~POTMatrixAdapter()
|
---|
| 61 | { if (aDel) delete mMtx; }
|
---|
| 62 | virtual double Value(int ix, int iy)
|
---|
| 63 | { return((double)(*mMtx)(iy, ix)); }
|
---|
| 64 |
|
---|
| 65 | protected:
|
---|
| 66 | bool aDel;
|
---|
| 67 | TMatrix<T>* mMtx;
|
---|
| 68 | };
|
---|
| 69 |
|
---|
| 70 | typedef POTMatrixAdapter<r_8> POMatrixAdapter;
|
---|
| 71 |
|
---|
| 72 | double POTMatrixAdapter< complex<float> >::Value(int ix, int iy)
|
---|
| 73 | {
|
---|
| 74 | double re,im;
|
---|
| 75 | re = (*mMtx)(iy, ix).real();
|
---|
| 76 | im = (*mMtx)(iy, ix).imag();
|
---|
| 77 | return(sqrt(re*re+im*im));
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | double POTMatrixAdapter< complex<double> >::Value(int ix, int iy)
|
---|
| 81 | {
|
---|
| 82 | double re,im;
|
---|
| 83 | re = (*mMtx)(iy, ix).real();
|
---|
| 84 | im = (*mMtx)(iy, ix).imag();
|
---|
| 85 | return(sqrt(re*re+im*im));
|
---|
| 86 | }
|
---|
| 87 | #endif
|
---|