source: Sophya/trunk/SophyaPI/PIext/pitvmaad.h@ 585

Last change on this file since 585 was 585, checked in by ercodmgr, 26 years ago

Modifs pour SOPHYA , TMatrix, PixelMap, ... - Suite - Reza 17/11/99

File size: 2.0 KB
Line 
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
18template <class T>
19class POTVectorAdapter : public P1DArrayAdapter {
20public :
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
29protected:
30 bool aDel;
31 TVector<T>* mVec;
32};
33
34typedef POTVectorAdapter<r_8> POVectorAdapter;
35
36double POTVectorAdapter< complex<float> >::Value(int i)
37{
38double re,im;
39re = (*mVec)(i).real();
40im = (*mVec)(i).imag();
41return(sqrt(re*re+im*im));
42}
43
44double POTVectorAdapter< complex<double> >::Value(int i)
45{
46double re,im;
47re = (*mVec)(i).real();
48im = (*mVec)(i).imag();
49return(sqrt(re*re+im*im));
50}
51
52// Adaptateur de matrice SOPHYA a P2DArrayAdapter
53// Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col)
54template <class T>
55class POTMatrixAdapter : public P2DArrayAdapter {
56public :
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
65protected:
66 bool aDel;
67 TMatrix<T>* mMtx;
68};
69
70typedef POTMatrixAdapter<r_8> POMatrixAdapter;
71
72double POTMatrixAdapter< complex<float> >::Value(int ix, int iy)
73{
74double re,im;
75re = (*mMtx)(iy, ix).real();
76im = (*mMtx)(iy, ix).imag();
77return(sqrt(re*re+im*im));
78}
79
80double POTMatrixAdapter< complex<double> >::Value(int ix, int iy)
81{
82double re,im;
83re = (*mMtx)(iy, ix).real();
84im = (*mMtx)(iy, ix).imag();
85return(sqrt(re*re+im*im));
86}
87#endif
Note: See TracBrowser for help on using the repository browser.