[594] | 1 | // Adaptateurs pour TMatrix TVector du package Sophya
|
---|
| 2 | // R. Ansari 1/99
|
---|
| 3 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 4 |
|
---|
[2615] | 5 | #include "sopnamsp.h"
|
---|
[594] | 6 | #include "pitvmaad.h"
|
---|
| 7 | #include <math.h>
|
---|
| 8 |
|
---|
| 9 | /* --Methode-- */
|
---|
| 10 | template <class T>
|
---|
| 11 | POTVectorAdapter<T>::POTVectorAdapter(TVector<T>* v, bool ad)
|
---|
| 12 | : P1DArrayAdapter(v->NElts())
|
---|
| 13 | {
|
---|
| 14 | aDel = ad;
|
---|
| 15 | mVec = v;
|
---|
| 16 | }
|
---|
| 17 | /* --Methode-- */
|
---|
| 18 | template <class T>
|
---|
| 19 | POTVectorAdapter<T>::~POTVectorAdapter()
|
---|
| 20 | {
|
---|
| 21 | if (aDel) delete mVec;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | /* --Methode-- */
|
---|
| 25 | template <class T>
|
---|
| 26 | double POTVectorAdapter<T>::Value(int i)
|
---|
| 27 | {
|
---|
| 28 | return((*mVec)(i));
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | /* --Methode-- */
|
---|
[2343] | 32 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[594] | 33 | double POTVectorAdapter< complex<float> >::Value(int i)
|
---|
| 34 | {
|
---|
| 35 | double re,im;
|
---|
| 36 | re = (*mVec)(i).real();
|
---|
| 37 | im = (*mVec)(i).imag();
|
---|
| 38 | return(sqrt(re*re+im*im));
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | /* --Methode-- */
|
---|
[2343] | 42 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[594] | 43 | double POTVectorAdapter< complex<double> >::Value(int i)
|
---|
| 44 | {
|
---|
| 45 | double re,im;
|
---|
| 46 | re = (*mVec)(i).real();
|
---|
| 47 | im = (*mVec)(i).imag();
|
---|
| 48 | return(sqrt(re*re+im*im));
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | /* --Methode-- */
|
---|
| 52 | template <class T>
|
---|
| 53 | POTMatrixAdapter<T>::POTMatrixAdapter(TMatrix<T>* mtx, bool ad)
|
---|
| 54 | : P2DArrayAdapter(mtx->NCols(), mtx->NRows())
|
---|
| 55 | {
|
---|
| 56 | aDel = ad;
|
---|
| 57 | mMtx = mtx;
|
---|
| 58 | }
|
---|
| 59 | /* --Methode-- */
|
---|
| 60 | template <class T>
|
---|
| 61 | POTMatrixAdapter<T>::~POTMatrixAdapter()
|
---|
| 62 | {
|
---|
| 63 | if (aDel) delete mMtx;
|
---|
| 64 | }
|
---|
| 65 | /* --Methode-- */
|
---|
| 66 | template <class T>
|
---|
| 67 | double POTMatrixAdapter<T>::Value(int ix, int iy)
|
---|
| 68 | {
|
---|
| 69 | return((double)(*mMtx)(iy, ix));
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | /* --Methode-- */
|
---|
[2343] | 73 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[594] | 74 | double POTMatrixAdapter< complex<float> >::Value(int ix, int iy)
|
---|
| 75 | {
|
---|
| 76 | double re,im;
|
---|
| 77 | re = (*mMtx)(iy, ix).real();
|
---|
| 78 | im = (*mMtx)(iy, ix).imag();
|
---|
| 79 | return(sqrt(re*re+im*im));
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | /* --Methode-- */
|
---|
[2343] | 83 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[594] | 84 | double POTMatrixAdapter< complex<double> >::Value(int ix, int iy)
|
---|
| 85 | {
|
---|
| 86 | double re,im;
|
---|
| 87 | re = (*mMtx)(iy, ix).real();
|
---|
| 88 | im = (*mMtx)(iy, ix).imag();
|
---|
| 89 | return(sqrt(re*re+im*im));
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
| 93 | #pragma define_template POTVectorAdapter< int_4 >
|
---|
| 94 | #pragma define_template POTVectorAdapter< int_8 >
|
---|
| 95 | #pragma define_template POTVectorAdapter< float >
|
---|
| 96 | #pragma define_template POTVectorAdapter< double >
|
---|
| 97 | #pragma define_template POTVectorAdapter< complex<float> >
|
---|
| 98 | #pragma define_template POTVectorAdapter< complex<double> >
|
---|
| 99 |
|
---|
| 100 | #pragma define_template POTMatrixAdapter< int_4 >
|
---|
| 101 | #pragma define_template POTMatrixAdapter< int_8 >
|
---|
| 102 | #pragma define_template POTMatrixAdapter< float >
|
---|
| 103 | #pragma define_template POTMatrixAdapter< double >
|
---|
| 104 | #pragma define_template POTMatrixAdapter< complex<float> >
|
---|
| 105 | #pragma define_template POTMatrixAdapter< complex<double> >
|
---|
| 106 | #endif
|
---|
| 107 |
|
---|
| 108 | #if defined(ANSI_TEMPLATES)
|
---|
| 109 | template class POTVectorAdapter< int_4 >;
|
---|
| 110 | template class POTVectorAdapter< int_8 >;
|
---|
| 111 | template class POTVectorAdapter< float >;
|
---|
| 112 | template class POTVectorAdapter< double >;
|
---|
| 113 | template class POTVectorAdapter< complex<float> >;
|
---|
| 114 | template class POTVectorAdapter< complex<double> >;
|
---|
| 115 |
|
---|
| 116 | template class POTMatrixAdapter< int_4 >;
|
---|
| 117 | template class POTMatrixAdapter< int_8 >;
|
---|
| 118 | template class POTMatrixAdapter< float >;
|
---|
| 119 | template class POTMatrixAdapter< double >;
|
---|
| 120 | template class POTMatrixAdapter< complex<float> >;
|
---|
| 121 | template class POTMatrixAdapter< complex<double> >;
|
---|
| 122 | #endif
|
---|