[2615] | 1 | #include "sopnamsp.h"
|
---|
[1315] | 2 | #include "machdefs.h"
|
---|
| 3 | #include <stdlib.h>
|
---|
| 4 | #include <typeinfo>
|
---|
[2322] | 5 | #include <iostream>
|
---|
[1315] | 6 | #include <string>
|
---|
| 7 | #include <complex>
|
---|
| 8 |
|
---|
| 9 | #include "datatype.h"
|
---|
| 10 |
|
---|
| 11 | #include "nomtarradapter.h"
|
---|
[1321] | 12 | #include "tvector.h"
|
---|
| 13 | #include "pitvmaad.h"
|
---|
[1905] | 14 | #include "piyfxdrw.h"
|
---|
[1315] | 15 |
|
---|
| 16 | #include "fioarr.h"
|
---|
[1321] | 17 | #include "fitstarray.h"
|
---|
[1315] | 18 |
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | //----------------------------------------------------------------
|
---|
| 22 | // Class Adaptateur d'objet (Pour NamedObjMgr) d'objet TMatrix<T>
|
---|
| 23 | //----------------------------------------------------------------
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | /* --Methode-- */
|
---|
| 27 | template <class T>
|
---|
| 28 | NOMAdapter_TArray<T>::NOMAdapter_TArray(TArray<T>* o)
|
---|
| 29 | : NObjMgrAdapter(o)
|
---|
| 30 | {
|
---|
| 31 | mArr = o;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | /* --Methode-- */
|
---|
| 35 | template <class T>
|
---|
| 36 | NOMAdapter_TArray<T>::~NOMAdapter_TArray()
|
---|
| 37 | {
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | /* --Methode-- */
|
---|
| 41 | template <class T>
|
---|
| 42 | NObjMgrAdapter* NOMAdapter_TArray<T>::Clone(AnyDataObj* o)
|
---|
| 43 | {
|
---|
| 44 | TArray<T>* a = dynamic_cast<TArray<T> *>(o);
|
---|
| 45 | if (a) return ( new NOMAdapter_TArray<T>(a) );
|
---|
| 46 | return ( new NObjMgrAdapter(o) );
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | /* --Methode-- */
|
---|
| 50 | template <class T>
|
---|
| 51 | string NOMAdapter_TArray<T>::GetDataObjType()
|
---|
| 52 | {
|
---|
| 53 | string type = "TArray< ";
|
---|
| 54 |
|
---|
| 55 | // type += DecodeTypeIdName(typeid(T).name());
|
---|
| 56 | type += DataTypeInfo<T>::getTypeName();
|
---|
| 57 | type += " > ";
|
---|
| 58 | return(type);
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | /* --Methode-- */
|
---|
| 62 | template <class T>
|
---|
| 63 | AnyDataObj* NOMAdapter_TArray<T>::CloneDataObj(bool share)
|
---|
| 64 | {
|
---|
| 65 | return ( new TArray<T>(*mArr, share) );
|
---|
| 66 | }
|
---|
| 67 |
|
---|
[1321] | 68 |
|
---|
| 69 | /* --Methode-- */
|
---|
| 70 | template <class T>
|
---|
[1315] | 71 | void NOMAdapter_TArray<T>::SavePPF(POutPersist& pos, string const & nom)
|
---|
| 72 | {
|
---|
| 73 | FIO_TArray<T> fio(mArr);
|
---|
| 74 | fio.Write(pos, nom);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /* --Methode-- */
|
---|
| 78 | template <class T>
|
---|
| 79 | void NOMAdapter_TArray<T>::Print(ostream& os)
|
---|
| 80 | {
|
---|
| 81 | os << (*mArr);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[1321] | 84 | /* --Methode-- */
|
---|
| 85 | template <class T>
|
---|
| 86 | PIDrawer * NOMAdapter_TArray<T>::GetDrawer(string & dopt)
|
---|
| 87 | {
|
---|
| 88 | if (mArr->NbDimensions() == 1) {
|
---|
| 89 | // On peut en faire un vecteur ...
|
---|
| 90 | TVector<T>* v = new TVector<T>(*mArr, true); // on partage les donnees
|
---|
| 91 | dopt = "thinline," + dopt;
|
---|
| 92 | return( new PIYfXDrawer( new POTVectorAdapter<T>(v, true), NULL, true) );
|
---|
| 93 | }
|
---|
| 94 | else return(NULL);
|
---|
| 95 | }
|
---|
[1315] | 96 |
|
---|
| 97 | /* --Methode-- */
|
---|
| 98 | template <class T>
|
---|
[1321] | 99 | P2DArrayAdapter* NOMAdapter_TArray<T>::Get2DArray(string &)
|
---|
| 100 | {
|
---|
| 101 | if (mArr->NbDimensions() <= 2) {
|
---|
| 102 | // On peut en faire un tableau 2-D ...
|
---|
| 103 | TMatrix<T>* m = new TMatrix<T>(*mArr, true); // on partage les donnees
|
---|
| 104 | return ( new POTMatrixAdapter<T>(m, true) );
|
---|
| 105 | }
|
---|
| 106 | else return(NULL);
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | /* --Methode-- */
|
---|
| 110 | template <class T>
|
---|
[1315] | 111 | NTupleInterface* NOMAdapter_TArray<T>::GetNTupleInterface(bool& adel)
|
---|
| 112 | {
|
---|
| 113 | adel = true;
|
---|
| 114 | return( new NTupInt_TArray<T>(mArr) );
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 | // -------------------------------------------------------------
|
---|
| 121 |
|
---|
| 122 | /* --Methode-- */
|
---|
| 123 | template <class T>
|
---|
| 124 | NTupInt_TArray<T>::NTupInt_TArray(TArray<T>* a)
|
---|
| 125 | {
|
---|
| 126 | mArr = a;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | /* --Methode-- */
|
---|
| 130 | template <class T>
|
---|
| 131 | NTupInt_TArray<T>::~NTupInt_TArray()
|
---|
| 132 | {
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | /* --Methode-- */
|
---|
| 136 | template <class T>
|
---|
[2683] | 137 | sa_size_t NTupInt_TArray<T>::NbLines() const
|
---|
[1315] | 138 | {
|
---|
| 139 | return( mArr->Size() );
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | /* --Methode-- */
|
---|
| 143 | template <class T>
|
---|
[2683] | 144 | sa_size_t NTupInt_TArray<T>::NbColumns() const
|
---|
[1315] | 145 | {
|
---|
| 146 | return(11);
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | /* --Methode-- */
|
---|
| 150 | template <class T>
|
---|
[2683] | 151 | r_8* NTupInt_TArray<T>::GetLineD(sa_size_t n) const
|
---|
[1315] | 152 | {
|
---|
| 153 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) {
|
---|
| 154 | mRet[0] = n;
|
---|
| 155 | for(int i=1; i<11; i++) mRet[i] = 0.;
|
---|
| 156 | }
|
---|
| 157 | else {
|
---|
| 158 | sa_size_t ix, iy, iz, it, iu;
|
---|
| 159 | mArr->IndexAtPosition(n, ix, iy, iz, it, iu);
|
---|
| 160 | mRet[0] = n; mRet[1] = ix; mRet[2] = iy;
|
---|
| 161 | mRet[3] = iz; mRet[4] = it; mRet[5] = iu;
|
---|
| 162 | mRet[6] = (*mArr)(ix,iy,iz,it,iu);
|
---|
| 163 | mRet[7] = mRet[2]; mRet[8] = 0.;
|
---|
| 164 | mRet[9] = mRet[2]; mRet[10] = 0.;
|
---|
| 165 | }
|
---|
| 166 | return(mRet);
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | /* --Methode-- */
|
---|
| 170 | template <class T>
|
---|
| 171 | string NTupInt_TArray<T>::VarList_C(const char* nx) const
|
---|
| 172 | {
|
---|
| 173 | string nomx;
|
---|
| 174 | if (nx) nomx = nx;
|
---|
| 175 | else nomx = "_xh_";
|
---|
| 176 | string vardec = "double n,x,y,z,t,u,val,real,imag,mod,phas; \n";
|
---|
| 177 | vardec += "n = " + nomx + "[0]; x = " + nomx + "[1]; y = " + nomx + "[2]; \n";
|
---|
| 178 | vardec += "z = " + nomx + "[3]; t = " + nomx + "[4]; u = " + nomx + "[5]; \n";
|
---|
| 179 | vardec += "val = " + nomx + "[6]; \n";
|
---|
| 180 | vardec += "real = " + nomx + "[7]; imag = " + nomx + "[8]; \n";
|
---|
| 181 | vardec += "mod = " + nomx + "[9]; phas = " + nomx + "[10]; \n";
|
---|
| 182 | return(vardec);
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | /* --Methode-- */
|
---|
[2343] | 186 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2689] | 187 | r_8* NTupInt_TArray< complex<r_4> >::GetLineD(sa_size_t n) const
|
---|
[1315] | 188 | {
|
---|
| 189 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) {
|
---|
| 190 | mRet[0] = n;
|
---|
| 191 | for(int i=1; i<11; i++) mRet[i] = 0.;
|
---|
| 192 | }
|
---|
| 193 | else {
|
---|
| 194 | sa_size_t ix, iy, iz, it, iu;
|
---|
| 195 | mArr->IndexAtPosition(n, ix, iy, iz, it, iu);
|
---|
| 196 | mRet[0] = n; mRet[1] = ix; mRet[2] = iy;
|
---|
| 197 | mRet[3] = iz; mRet[4] = it; mRet[5] = iu;
|
---|
| 198 | mRet[7] = (*mArr)(ix,iy,iz,it,iu).real();
|
---|
| 199 | mRet[8] = (*mArr)(ix,iy,iz,it,iu).imag();
|
---|
| 200 | mRet[3] = mRet[6] = sqrt(mRet[7]*mRet[7]+mRet[8]*mRet[8]);
|
---|
| 201 | mRet[7] = atan2(mRet[8], mRet[7]);
|
---|
| 202 | }
|
---|
| 203 | return(mRet);
|
---|
| 204 | }
|
---|
| 205 |
|
---|
[2343] | 206 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2689] | 207 | r_8* NTupInt_TArray< complex<r_8> >::GetLineD(sa_size_t n) const
|
---|
[1315] | 208 | {
|
---|
| 209 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) {
|
---|
| 210 | mRet[0] = n;
|
---|
| 211 | for(int i=1; i<11; i++) mRet[i] = 0.;
|
---|
| 212 | }
|
---|
| 213 | else {
|
---|
| 214 | sa_size_t ix, iy, iz, it, iu;
|
---|
| 215 | mArr->IndexAtPosition(n, ix, iy, iz, it, iu);
|
---|
| 216 | mRet[0] = n; mRet[1] = ix; mRet[2] = iy;
|
---|
| 217 | mRet[3] = iz; mRet[4] = it; mRet[5] = iu;
|
---|
| 218 | mRet[7] = (*mArr)(ix,iy,iz,it,iu).real();
|
---|
| 219 | mRet[8] = (*mArr)(ix,iy,iz,it,iu).imag();
|
---|
| 220 | mRet[3] = mRet[6] = sqrt(mRet[7]*mRet[7]+mRet[8]*mRet[8]);
|
---|
| 221 | mRet[7] = atan2(mRet[8], mRet[7]);
|
---|
| 222 | }
|
---|
| 223 | return(mRet);
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 |
|
---|
| 227 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
[2930] | 228 | #pragma define_template NOMAdapter_TArray<uint_2>
|
---|
| 229 | #pragma define_template NOMAdapter_TArray<int_2>
|
---|
[1315] | 230 | #pragma define_template NOMAdapter_TArray<int_4>
|
---|
[2930] | 231 | #pragma define_template NOMAdapter_TArray<int_8>
|
---|
[1315] | 232 | #pragma define_template NOMAdapter_TArray<r_4>
|
---|
| 233 | #pragma define_template NOMAdapter_TArray<r_8>
|
---|
| 234 | #pragma define_template NOMAdapter_TArray< complex<r_4> >
|
---|
| 235 | #pragma define_template NOMAdapter_TArray< complex<r_8> >
|
---|
[2930] | 236 | #pragma define_template NTupInt_TArray<uint_2>
|
---|
| 237 | #pragma define_template NTupInt_TArray<int_2>
|
---|
[1315] | 238 | #pragma define_template NTupInt_TArray<int_4>
|
---|
[2930] | 239 | #pragma define_template NTupInt_TArray<int_8>
|
---|
[1315] | 240 | #pragma define_template NTupInt_TArray<r_4>
|
---|
| 241 | #pragma define_template NTupInt_TArray<r_8>
|
---|
| 242 | #pragma define_template NTupInt_TArray< complex<r_4> >
|
---|
| 243 | #pragma define_template NTupInt_TArray< complex<r_8> >
|
---|
| 244 | #endif
|
---|
| 245 |
|
---|
| 246 | #if defined(ANSI_TEMPLATES)
|
---|
[2930] | 247 | template class NOMAdapter_TArray<uint_2>;
|
---|
| 248 | template class NOMAdapter_TArray<int_2>;
|
---|
[1315] | 249 | template class NOMAdapter_TArray<int_4>;
|
---|
[2930] | 250 | template class NOMAdapter_TArray<int_8>;
|
---|
[1315] | 251 | template class NOMAdapter_TArray<r_4>;
|
---|
| 252 | template class NOMAdapter_TArray<r_8>;
|
---|
| 253 | template class NOMAdapter_TArray< complex<r_4> >;
|
---|
| 254 | template class NOMAdapter_TArray< complex<r_8> >;
|
---|
[2930] | 255 | template class NTupInt_TArray<uint_2>;
|
---|
| 256 | template class NTupInt_TArray<int_2>;
|
---|
[1315] | 257 | template class NTupInt_TArray<int_4>;
|
---|
[2930] | 258 | template class NTupInt_TArray<int_8>;
|
---|
[1315] | 259 | template class NTupInt_TArray<r_4>;
|
---|
| 260 | template class NTupInt_TArray<r_8>;
|
---|
| 261 | template class NTupInt_TArray< complex<r_4> >;
|
---|
| 262 | template class NTupInt_TArray< complex<r_8> >;
|
---|
| 263 | #endif
|
---|