| [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" | 
|---|
|  | 17 |  | 
|---|
| [2999] | 18 | #include "nobjmgr.h" | 
|---|
| [1315] | 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 |  | 
|---|
| [2999] | 68 | /* --Methode-- */ | 
|---|
|  | 69 | template <class T> | 
|---|
|  | 70 | string NOMAdapter_TArray<T>::GetInfoString(vector<string>& opts) | 
|---|
|  | 71 | { | 
|---|
|  | 72 | if (opts.size() == 0) return mArr->InfoString(); | 
|---|
|  | 73 | else { | 
|---|
|  | 74 | char buff[128]; | 
|---|
|  | 75 | if (opts[0] == "rank") { | 
|---|
|  | 76 | sprintf(buff,"%d", (int)mArr->Rank()); | 
|---|
|  | 77 | return string(buff); | 
|---|
|  | 78 | } | 
|---|
|  | 79 | if (opts[0] == "sizes") { | 
|---|
| [3033] | 80 | string rs; | 
|---|
|  | 81 | for(int_4 kd=0; kd<mArr->Rank(); kd++) { | 
|---|
|  | 82 | sprintf(buff, "%ld ", (long)mArr->Size(kd)); | 
|---|
|  | 83 | rs += buff; | 
|---|
|  | 84 | } | 
|---|
|  | 85 | return rs; | 
|---|
| [2999] | 86 | } | 
|---|
|  | 87 | else if ((opts[0] == "size") || (opts[0] == "nelts")) { | 
|---|
|  | 88 | sprintf(buff, "%ld", (long)mArr->Size()); | 
|---|
|  | 89 | return string(buff); | 
|---|
|  | 90 | } | 
|---|
|  | 91 | else if (opts[0] == "sum") { | 
|---|
|  | 92 | MuTyV mtv(mArr->Sum()); | 
|---|
|  | 93 | string s; | 
|---|
|  | 94 | return mtv.Convert(s); | 
|---|
|  | 95 | } | 
|---|
| [3333] | 96 | else if (opts[0] == "sumsq") { | 
|---|
|  | 97 | MuTyV mtv(mArr->SumSq()); | 
|---|
|  | 98 | string s; | 
|---|
|  | 99 | return mtv.Convert(s); | 
|---|
|  | 100 | } | 
|---|
|  | 101 | else if (opts[0] == "norm2") { | 
|---|
|  | 102 | MuTyV mtv(mArr->Norm2()); | 
|---|
| [3335] | 103 | r_8 nrm2 = mtv.Convert(nrm2);  // we force the conversion to double | 
|---|
|  | 104 | mtv = nrm2; | 
|---|
| [3333] | 105 | string s; | 
|---|
|  | 106 | return mtv.Convert(s); | 
|---|
|  | 107 | } | 
|---|
|  | 108 | else if ((opts[0] == "min")||(opts[0] == "max")||(opts[0] == "minmax")) { | 
|---|
|  | 109 | T amin, amax; | 
|---|
|  | 110 | MuTyV mtv; | 
|---|
|  | 111 | string s; | 
|---|
|  | 112 | mArr->MinMax(amin, amax); | 
|---|
|  | 113 | if (opts[0] == "minmax") { | 
|---|
|  | 114 | mtv = amin;  mtv.Convert(s); | 
|---|
|  | 115 | s += " "; | 
|---|
|  | 116 | string mms; | 
|---|
|  | 117 | mtv = amax;  mtv.Convert(mms); | 
|---|
|  | 118 | s += mms; | 
|---|
|  | 119 | } | 
|---|
|  | 120 | else { | 
|---|
|  | 121 | if (opts[0] == "min")  mtv = amin; | 
|---|
|  | 122 | else if (opts[0] == "max")  mtv = amax; | 
|---|
|  | 123 | mtv.Convert(s); | 
|---|
|  | 124 | } | 
|---|
|  | 125 | return s; | 
|---|
|  | 126 | } | 
|---|
| [3221] | 127 | else if (opts[0] == "info") { // Acces aux valeurs stockes ds le DVList Info() | 
|---|
|  | 128 | if (opts.size() < 2)  return string(""); | 
|---|
|  | 129 | else if (mArr->Info().HasKey(opts[1]) == false) return string(""); | 
|---|
|  | 130 | else return mArr->Info().GetS(opts[1]); | 
|---|
|  | 131 | } | 
|---|
| [3333] | 132 | else return "TArray.Att: rank sizes size/nelts sum sumsq/norm2 min max minmax"; | 
|---|
| [2999] | 133 | } | 
|---|
|  | 134 | } | 
|---|
| [1321] | 135 |  | 
|---|
|  | 136 | /* --Methode-- */ | 
|---|
|  | 137 | template <class T> | 
|---|
| [2999] | 138 | int NOMAdapter_TArray<T>::PerformOperation(vector<string>& opts) | 
|---|
|  | 139 | { | 
|---|
|  | 140 | bool ok = false; | 
|---|
|  | 141 | if ((mArr->Rank() >= 3) && (opts.size() >= 2)) { | 
|---|
|  | 142 | int_4 ks = atoi(opts[1].c_str()); | 
|---|
|  | 143 | TMatrix<T> * slice = new TMatrix<T>; | 
|---|
|  | 144 | char buff[40]; | 
|---|
|  | 145 | if (opts[0] == "slicexy") { | 
|---|
|  | 146 | slice->Share(mArr->SubArray(Range::all(), Range::all(), Range(ks), | 
|---|
|  | 147 | Range::first(), Range::first()) ); | 
|---|
|  | 148 | ok = true; | 
|---|
|  | 149 | sprintf(buff,"slicexy_%ld",(long)ks); | 
|---|
|  | 150 | cout << "PerformOperation(): Extracting SliceXY(" << ks << ") from array" << endl; | 
|---|
|  | 151 | } | 
|---|
|  | 152 | else if (opts[0] == "sliceyz") { | 
|---|
| [3004] | 153 | slice->Share(mArr->SubArray(Range(ks), Range::all(), Range::all(), Range::first(), | 
|---|
|  | 154 | Range::first()).CompactAllDimensions() ); | 
|---|
| [2999] | 155 | ok = true; | 
|---|
|  | 156 | sprintf(buff,"sliceyz_%ld",(long)ks); | 
|---|
|  | 157 | cout << "PerformOperation(): Extracting SliceYZ(" << ks << ") from array" << endl; | 
|---|
|  | 158 | } | 
|---|
|  | 159 | else if (opts[0] == "slicexz") { | 
|---|
| [3004] | 160 | slice->Share(mArr->SubArray(Range::all(), Range(ks), Range::all(), Range::first(), | 
|---|
|  | 161 | Range::first()).CompactAllDimensions() ); | 
|---|
| [2999] | 162 | ok = true; | 
|---|
|  | 163 | sprintf(buff,"slicexz_%ld",(long)ks); | 
|---|
|  | 164 | cout << "PerformOperation(): Extracting SliceYZ(" << ks << ") from array" << endl; | 
|---|
|  | 165 | } | 
|---|
|  | 166 | if (ok) { | 
|---|
|  | 167 | string nslice; | 
|---|
| [3448] | 168 | if(opts.size() > 2)  nslice = opts[2]; | 
|---|
| [2999] | 169 | else nslice = buff; | 
|---|
|  | 170 | NamedObjMgr omg; | 
|---|
|  | 171 | omg.AddObj(slice, nslice, true); | 
|---|
|  | 172 | } | 
|---|
| [3448] | 173 | else delete slice; | 
|---|
|  | 174 | return 0; | 
|---|
| [2999] | 175 | } | 
|---|
| [3448] | 176 | else if (opts.size() >= 1) { | 
|---|
|  | 177 | if (opts[0] == "compactalldim") { | 
|---|
|  | 178 | mArr->CompactAllDimensions();   ok = true; | 
|---|
|  | 179 | cout << "PerformOperation(): mArr->CompactAllDimensions() " << endl; | 
|---|
|  | 180 | } | 
|---|
|  | 181 | else if (opts[0] == "compactdim") { | 
|---|
|  | 182 | mArr->CompactTrailingDimensions();   ok = true; | 
|---|
|  | 183 | cout << "PerformOperation(): mArr->CompactTrailingDimensions() " << endl; | 
|---|
|  | 184 | } | 
|---|
|  | 185 | else ok = false; | 
|---|
|  | 186 | if (ok) return 0; | 
|---|
|  | 187 | } | 
|---|
|  | 188 |  | 
|---|
|  | 189 | if (!ok) { | 
|---|
|  | 190 | cout << "NOMAdapter_TArray<T>::PerformOperation(): Error operation/arguments !" << endl; | 
|---|
|  | 191 | cout << "...Valid args: slicexy idxZ [slicename], sliceyz idxX [nm] slicexz idxY [nm]" << endl; | 
|---|
|  | 192 | cout << "... compactdim (=CompactTrailingDimensions()), compactalldim (=CompactAllDimensions())" << endl; | 
|---|
|  | 193 | return 1; | 
|---|
|  | 194 | } | 
|---|
| [3572] | 195 |  | 
|---|
|  | 196 | return 0; | 
|---|
| [2999] | 197 | } | 
|---|
|  | 198 |  | 
|---|
|  | 199 | /* --Methode-- */ | 
|---|
|  | 200 | template <class T> | 
|---|
| [1315] | 201 | void NOMAdapter_TArray<T>::SavePPF(POutPersist& pos, string const & nom) | 
|---|
|  | 202 | { | 
|---|
|  | 203 | FIO_TArray<T> fio(mArr); | 
|---|
|  | 204 | fio.Write(pos, nom); | 
|---|
|  | 205 | } | 
|---|
|  | 206 |  | 
|---|
|  | 207 | /* --Methode-- */ | 
|---|
|  | 208 | template <class T> | 
|---|
| [2975] | 209 | void NOMAdapter_TArray<T>::Print(ostream& os, int lev) | 
|---|
| [1315] | 210 | { | 
|---|
| [2975] | 211 | if (lev < 3) mArr->Show(os, false); | 
|---|
|  | 212 | else  mArr->Show(os, true); | 
|---|
|  | 213 | if (lev > 0) mArr->Print(os, 10*lev); | 
|---|
| [1315] | 214 | } | 
|---|
|  | 215 |  | 
|---|
| [1321] | 216 | /* --Methode-- */ | 
|---|
|  | 217 | template <class T> | 
|---|
|  | 218 | PIDrawer * NOMAdapter_TArray<T>::GetDrawer(string & dopt) | 
|---|
|  | 219 | { | 
|---|
| [3453] | 220 | TArray<T> arr(*mArr, true);      // on partage les donnees | 
|---|
| [3454] | 221 | arr.CompactAllDimensions(); | 
|---|
| [3453] | 222 | if (arr.NbDimensions() == 1) { | 
|---|
| [1321] | 223 | // On peut en faire un vecteur ... | 
|---|
| [3453] | 224 | TVector<T>* v = new TVector<T>(arr, true);  // on partage les donnees | 
|---|
| [1321] | 225 | dopt = "thinline," + dopt; | 
|---|
| [3713] | 226 | return( new PIYfXDrawer( new POTVectorAdapter<T>(v, true, StringToCmplxDispOption(dopt)), NULL, true) ); | 
|---|
| [1321] | 227 | } | 
|---|
| [3454] | 228 | else { | 
|---|
|  | 229 | cout << "NOMAdapter_TArray<T>::GetDrawer() NDim[Size>1]>1 -> No PIDrawer" << endl; | 
|---|
|  | 230 | return(NULL); | 
|---|
| [1321] | 231 | } | 
|---|
| [3454] | 232 | } | 
|---|
| [1315] | 233 |  | 
|---|
|  | 234 | /* --Methode-- */ | 
|---|
|  | 235 | template <class T> | 
|---|
| [3713] | 236 | P2DArrayAdapter* NOMAdapter_TArray<T>::Get2DArray(string & dopt) | 
|---|
| [1321] | 237 | { | 
|---|
| [3453] | 238 | TArray<T> arr(*mArr, true);    // on partage les donnees | 
|---|
| [3454] | 239 | arr.CompactAllDimensions(); | 
|---|
| [3453] | 240 | if (arr.NbDimensions() <= 2) { | 
|---|
| [1321] | 241 | // On peut en faire un tableau 2-D ... | 
|---|
| [3453] | 242 | TMatrix<T>* m = new TMatrix<T>(arr, true);  // on partage les donnees | 
|---|
| [3713] | 243 | return ( new POTMatrixAdapter<T>(m, true, StringToCmplxDispOption(dopt)) ); | 
|---|
| [1321] | 244 | } | 
|---|
| [3454] | 245 | else { | 
|---|
|  | 246 | cout << "NOMAdapter_TArray<T>::Get2DArray() NDim[Size>1]>2 -> No 2DArrAdapt" << endl; | 
|---|
|  | 247 | return(NULL); | 
|---|
| [1321] | 248 | } | 
|---|
| [3454] | 249 | } | 
|---|
| [1321] | 250 |  | 
|---|
|  | 251 | /* --Methode-- */ | 
|---|
|  | 252 | template <class T> | 
|---|
| [1315] | 253 | NTupleInterface* NOMAdapter_TArray<T>::GetNTupleInterface(bool& adel) | 
|---|
|  | 254 | { | 
|---|
|  | 255 | adel = true; | 
|---|
|  | 256 | return( new NTupInt_TArray<T>(mArr) ); | 
|---|
|  | 257 | } | 
|---|
|  | 258 |  | 
|---|
|  | 259 |  | 
|---|
|  | 260 |  | 
|---|
|  | 261 |  | 
|---|
|  | 262 | // ------------------------------------------------------------- | 
|---|
|  | 263 |  | 
|---|
|  | 264 | /* --Methode-- */ | 
|---|
|  | 265 | template <class T> | 
|---|
|  | 266 | NTupInt_TArray<T>::NTupInt_TArray(TArray<T>* a) | 
|---|
|  | 267 | { | 
|---|
|  | 268 | mArr = a; | 
|---|
|  | 269 | } | 
|---|
|  | 270 |  | 
|---|
|  | 271 | /* --Methode-- */ | 
|---|
|  | 272 | template <class T> | 
|---|
|  | 273 | NTupInt_TArray<T>::~NTupInt_TArray() | 
|---|
|  | 274 | { | 
|---|
|  | 275 | } | 
|---|
|  | 276 |  | 
|---|
|  | 277 | /* --Methode-- */ | 
|---|
|  | 278 | template <class T> | 
|---|
| [2683] | 279 | sa_size_t NTupInt_TArray<T>::NbLines() const | 
|---|
| [1315] | 280 | { | 
|---|
|  | 281 | return( mArr->Size() ); | 
|---|
|  | 282 | } | 
|---|
|  | 283 |  | 
|---|
|  | 284 | /* --Methode-- */ | 
|---|
|  | 285 | template <class T> | 
|---|
| [2683] | 286 | sa_size_t NTupInt_TArray<T>::NbColumns() const | 
|---|
| [1315] | 287 | { | 
|---|
|  | 288 | return(11); | 
|---|
|  | 289 | } | 
|---|
|  | 290 |  | 
|---|
|  | 291 | /* --Methode-- */ | 
|---|
|  | 292 | template <class T> | 
|---|
| [3004] | 293 | r_8 NTupInt_TArray<T>::GetCell(sa_size_t n, sa_size_t k) const | 
|---|
|  | 294 | { | 
|---|
|  | 295 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) | 
|---|
|  | 296 | return 0.; | 
|---|
|  | 297 | if ((k < 0) || (k > 10))  return 0.; | 
|---|
|  | 298 | GetLineD(n); | 
|---|
|  | 299 | return mRet[k]; | 
|---|
|  | 300 | } | 
|---|
|  | 301 |  | 
|---|
|  | 302 | /* --Methode-- */ | 
|---|
|  | 303 | template <class T> | 
|---|
|  | 304 | sa_size_t NTupInt_TArray<T>::ColumnIndex(string const & nom)  const | 
|---|
|  | 305 | { | 
|---|
|  | 306 | if (nom == "n") return 0; | 
|---|
|  | 307 | else if (nom == "x") return 1; | 
|---|
|  | 308 | else if (nom == "y") return 2; | 
|---|
|  | 309 | else if (nom == "z") return 3; | 
|---|
|  | 310 | else if (nom == "t") return 4; | 
|---|
|  | 311 | else if (nom == "u") return 5; | 
|---|
|  | 312 | else if (nom == "val") return 6; | 
|---|
|  | 313 | else if (nom == "real") return 7; | 
|---|
|  | 314 | else if (nom == "imag") return 8; | 
|---|
|  | 315 | else if (nom == "mod") return 9; | 
|---|
| [3478] | 316 | else if (nom == "phas") return 10; | 
|---|
| [3004] | 317 | else return -1; | 
|---|
|  | 318 | } | 
|---|
|  | 319 |  | 
|---|
|  | 320 | /* --Methode-- */ | 
|---|
|  | 321 | template <class T> | 
|---|
|  | 322 | void NTupInt_TArray<T>::GetMinMax(sa_size_t k, double& min, double& max) const | 
|---|
|  | 323 | { | 
|---|
|  | 324 | if (k == 0) { | 
|---|
|  | 325 | min = 0.; max = (r_8)(mArr->Size());  } | 
|---|
|  | 326 | else if (k == 1) { | 
|---|
|  | 327 | min = 0.; max = (r_8)(mArr->SizeX());  } | 
|---|
|  | 328 | else if (k == 2) { | 
|---|
|  | 329 | min = 0.; max = (r_8)(mArr->SizeY());  } | 
|---|
|  | 330 | else if (k == 3) { | 
|---|
|  | 331 | min = 0.; max = (r_8)(mArr->SizeZ());  } | 
|---|
|  | 332 | else if (k == 4) { | 
|---|
|  | 333 | min = 0.; max = (r_8)(mArr->Size(3));  } | 
|---|
|  | 334 | else if (k == 5) { | 
|---|
|  | 335 | min = 0.; max = (r_8)(mArr->Size(4));  } | 
|---|
|  | 336 | else if ((k == 6) || (k == 7) || (k == 9)) { | 
|---|
|  | 337 | T tmin, tmax; | 
|---|
|  | 338 | mArr->MinMax(tmin, tmax); | 
|---|
|  | 339 | min = (r_8)(tmin); | 
|---|
|  | 340 | max = (r_8)(tmax); | 
|---|
|  | 341 | } | 
|---|
|  | 342 | else { min = max = 0.; } | 
|---|
|  | 343 | return; | 
|---|
|  | 344 | } | 
|---|
|  | 345 |  | 
|---|
|  | 346 | /* --Methode-- */ | 
|---|
|  | 347 | template <class T> | 
|---|
| [2683] | 348 | r_8* NTupInt_TArray<T>::GetLineD(sa_size_t n) const | 
|---|
| [1315] | 349 | { | 
|---|
|  | 350 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) { | 
|---|
|  | 351 | mRet[0] = n; | 
|---|
|  | 352 | for(int i=1; i<11; i++)  mRet[i] = 0.; | 
|---|
|  | 353 | } | 
|---|
|  | 354 | else { | 
|---|
|  | 355 | sa_size_t ix, iy, iz, it, iu; | 
|---|
|  | 356 | mArr->IndexAtPosition(n, ix, iy, iz, it, iu); | 
|---|
|  | 357 | mRet[0] = n;   mRet[1] = ix;  mRet[2] = iy; | 
|---|
|  | 358 | mRet[3] = iz;  mRet[4] = it;  mRet[5] = iu; | 
|---|
|  | 359 | mRet[6] = (*mArr)(ix,iy,iz,it,iu); | 
|---|
| [3004] | 360 | mRet[7] = mRet[6];  mRet[8] = 0.; | 
|---|
|  | 361 | mRet[9] = mRet[6];  mRet[10] = 0.; | 
|---|
| [1315] | 362 | } | 
|---|
|  | 363 | return(mRet); | 
|---|
|  | 364 | } | 
|---|
|  | 365 |  | 
|---|
|  | 366 | /* --Methode-- */ | 
|---|
|  | 367 | template <class T> | 
|---|
|  | 368 | string NTupInt_TArray<T>::VarList_C(const char* nx) const | 
|---|
|  | 369 | { | 
|---|
|  | 370 | string nomx; | 
|---|
|  | 371 | if (nx) nomx = nx; | 
|---|
|  | 372 | else nomx = "_xh_"; | 
|---|
|  | 373 | string vardec = "double n,x,y,z,t,u,val,real,imag,mod,phas; \n"; | 
|---|
|  | 374 | vardec += "n = " + nomx + "[0];  x = " + nomx + "[1]; y = " + nomx + "[2]; \n"; | 
|---|
|  | 375 | vardec += "z = " + nomx + "[3];  t = " + nomx + "[4]; u = " + nomx + "[5]; \n"; | 
|---|
|  | 376 | vardec += "val = " + nomx + "[6]; \n"; | 
|---|
|  | 377 | vardec += "real = " + nomx + "[7];  imag = " + nomx + "[8]; \n"; | 
|---|
|  | 378 | vardec += "mod  = " + nomx + "[9];  phas = " + nomx + "[10]; \n"; | 
|---|
|  | 379 | return(vardec); | 
|---|
|  | 380 | } | 
|---|
|  | 381 |  | 
|---|
|  | 382 | /* --Methode-- */ | 
|---|
| [2343] | 383 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [2689] | 384 | r_8* NTupInt_TArray< complex<r_4> >::GetLineD(sa_size_t n) const | 
|---|
| [1315] | 385 | { | 
|---|
|  | 386 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) { | 
|---|
|  | 387 | mRet[0] = n; | 
|---|
|  | 388 | for(int i=1; i<11; i++)  mRet[i] = 0.; | 
|---|
|  | 389 | } | 
|---|
|  | 390 | else { | 
|---|
|  | 391 | sa_size_t ix, iy, iz, it, iu; | 
|---|
|  | 392 | mArr->IndexAtPosition(n, ix, iy, iz, it, iu); | 
|---|
|  | 393 | mRet[0] = n;   mRet[1] = ix;  mRet[2] = iy; | 
|---|
|  | 394 | mRet[3] = iz;  mRet[4] = it;  mRet[5] = iu; | 
|---|
|  | 395 | mRet[7] = (*mArr)(ix,iy,iz,it,iu).real(); | 
|---|
|  | 396 | mRet[8] = (*mArr)(ix,iy,iz,it,iu).imag(); | 
|---|
| [3004] | 397 | mRet[6] = mRet[9] = sqrt(mRet[7]*mRet[7]+mRet[8]*mRet[8]); | 
|---|
|  | 398 | mRet[10] = atan2(mRet[8], mRet[7]); | 
|---|
| [1315] | 399 | } | 
|---|
|  | 400 | return(mRet); | 
|---|
|  | 401 | } | 
|---|
|  | 402 |  | 
|---|
| [2343] | 403 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [2689] | 404 | r_8* NTupInt_TArray< complex<r_8> >::GetLineD(sa_size_t n) const | 
|---|
| [1315] | 405 | { | 
|---|
|  | 406 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) { | 
|---|
|  | 407 | mRet[0] = n; | 
|---|
|  | 408 | for(int i=1; i<11; i++)  mRet[i] = 0.; | 
|---|
|  | 409 | } | 
|---|
|  | 410 | else { | 
|---|
|  | 411 | sa_size_t ix, iy, iz, it, iu; | 
|---|
|  | 412 | mArr->IndexAtPosition(n, ix, iy, iz, it, iu); | 
|---|
|  | 413 | mRet[0] = n;   mRet[1] = ix;  mRet[2] = iy; | 
|---|
|  | 414 | mRet[3] = iz;  mRet[4] = it;  mRet[5] = iu; | 
|---|
|  | 415 | mRet[7] = (*mArr)(ix,iy,iz,it,iu).real(); | 
|---|
|  | 416 | mRet[8] = (*mArr)(ix,iy,iz,it,iu).imag(); | 
|---|
| [3004] | 417 | mRet[6] = mRet[9] = sqrt(mRet[7]*mRet[7]+mRet[8]*mRet[8]); | 
|---|
|  | 418 | mRet[10] = atan2(mRet[8], mRet[7]); | 
|---|
| [1315] | 419 | } | 
|---|
|  | 420 | return(mRet); | 
|---|
|  | 421 | } | 
|---|
|  | 422 |  | 
|---|
| [3004] | 423 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
|  | 424 | void NTupInt_TArray< complex<r_4> >::GetMinMax(sa_size_t k, double& min, double& max) const | 
|---|
|  | 425 | { | 
|---|
|  | 426 | if (k == 0) { | 
|---|
|  | 427 | min = 0.; max = (r_8)(mArr->Size());  } | 
|---|
|  | 428 | else if (k == 1) { | 
|---|
|  | 429 | min = 0.; max = (r_8)(mArr->SizeX());  } | 
|---|
|  | 430 | else if (k == 2) { | 
|---|
|  | 431 | min = 0.; max = (r_8)(mArr->SizeY());  } | 
|---|
|  | 432 | else if (k == 3) { | 
|---|
|  | 433 | min = 0.; max = (r_8)(mArr->SizeZ());  } | 
|---|
|  | 434 | else if (k == 4) { | 
|---|
|  | 435 | min = 0.; max = (r_8)(mArr->Size(3));  } | 
|---|
|  | 436 | else if (k == 5) { | 
|---|
|  | 437 | min = 0.; max = (r_8)(mArr->Size(4));  } | 
|---|
|  | 438 | else if ((k >= 6) || (k <= 9)) { | 
|---|
|  | 439 | r_8 tmin[3] = {9.e39,9.e39,9.e39}; | 
|---|
|  | 440 | r_8 tmax[3] = {-9.e39,-9.e39,-9.e39}; | 
|---|
|  | 441 | for(sa_size_t jj=0; jj<mArr->Size(); jj++) { | 
|---|
|  | 442 | sa_size_t ix, iy, iz, it, iu; | 
|---|
|  | 443 | mArr->IndexAtPosition(jj, ix, iy, iz, it, iu); | 
|---|
|  | 444 | r_8 cv[3]; | 
|---|
|  | 445 | cv[0] = (*mArr)(ix,iy,iz,it,iu).real(); | 
|---|
|  | 446 | cv[1] = (*mArr)(ix,iy,iz,it,iu).imag(); | 
|---|
|  | 447 | cv[2] = sqrt(cv[0]*cv[0]+cv[1]*cv[1]); | 
|---|
|  | 448 | for(int i=0; i<3; i++) { | 
|---|
|  | 449 | if (cv[i] < tmin[i]) tmin[i] = cv[i]; | 
|---|
|  | 450 | if (cv[i] > tmax[i]) tmax[i] = cv[i]; | 
|---|
|  | 451 | } | 
|---|
|  | 452 | } | 
|---|
|  | 453 | if (k == 7) { min = tmin[0]; max = tmax[0]; } | 
|---|
|  | 454 | else if (k == 8) { min = tmin[0]; max = tmax[0]; } | 
|---|
|  | 455 | else { min = tmin[2]; max = tmax[2]; } | 
|---|
|  | 456 | } | 
|---|
|  | 457 | else { min = max = 0.; } | 
|---|
|  | 458 | return; | 
|---|
|  | 459 | } | 
|---|
|  | 460 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
|  | 461 | void NTupInt_TArray< complex<r_8> >::GetMinMax(sa_size_t k, double& min, double& max) const | 
|---|
|  | 462 | { | 
|---|
|  | 463 | if (k == 0) { | 
|---|
|  | 464 | min = 0.; max = (r_8)(mArr->Size());  } | 
|---|
|  | 465 | else if (k == 1) { | 
|---|
|  | 466 | min = 0.; max = (r_8)(mArr->SizeX());  } | 
|---|
|  | 467 | else if (k == 2) { | 
|---|
|  | 468 | min = 0.; max = (r_8)(mArr->SizeY());  } | 
|---|
|  | 469 | else if (k == 3) { | 
|---|
|  | 470 | min = 0.; max = (r_8)(mArr->SizeZ());  } | 
|---|
|  | 471 | else if (k == 4) { | 
|---|
|  | 472 | min = 0.; max = (r_8)(mArr->Size(3));  } | 
|---|
|  | 473 | else if (k == 5) { | 
|---|
|  | 474 | min = 0.; max = (r_8)(mArr->Size(4));  } | 
|---|
|  | 475 | else if ((k >= 6) || (k <= 9)) { | 
|---|
|  | 476 | r_8 tmin[3] = {9.e39,9.e39,9.e39}; | 
|---|
|  | 477 | r_8 tmax[3] = {-9.e39,-9.e39,-9.e39}; | 
|---|
|  | 478 | for(sa_size_t jj=0; jj<mArr->Size(); jj++) { | 
|---|
|  | 479 | sa_size_t ix, iy, iz, it, iu; | 
|---|
|  | 480 | mArr->IndexAtPosition(jj, ix, iy, iz, it, iu); | 
|---|
|  | 481 | r_8 cv[3]; | 
|---|
|  | 482 | cv[0] = (*mArr)(ix,iy,iz,it,iu).real(); | 
|---|
|  | 483 | cv[1] = (*mArr)(ix,iy,iz,it,iu).imag(); | 
|---|
|  | 484 | cv[2] = sqrt(cv[0]*cv[0]+cv[1]*cv[1]); | 
|---|
|  | 485 | for(int i=0; i<3; i++) { | 
|---|
|  | 486 | if (cv[i] < tmin[i]) tmin[i] = cv[i]; | 
|---|
|  | 487 | if (cv[i] > tmax[i]) tmax[i] = cv[i]; | 
|---|
|  | 488 | } | 
|---|
|  | 489 | } | 
|---|
|  | 490 | if (k == 7) { min = tmin[0]; max = tmax[0]; } | 
|---|
|  | 491 | else if (k == 8) { min = tmin[0]; max = tmax[0]; } | 
|---|
|  | 492 | else { min = tmin[2]; max = tmax[2]; } | 
|---|
|  | 493 | } | 
|---|
|  | 494 | else { min = max = 0.; } | 
|---|
|  | 495 | return; | 
|---|
|  | 496 | } | 
|---|
| [1315] | 497 |  | 
|---|
|  | 498 | #ifdef __CXX_PRAGMA_TEMPLATES__ | 
|---|
| [3661] | 499 | #pragma define_template NOMAdapter_TArray<uint_1> | 
|---|
| [2930] | 500 | #pragma define_template NOMAdapter_TArray<uint_2> | 
|---|
| [3528] | 501 | #pragma define_template NOMAdapter_TArray<uint_4> | 
|---|
|  | 502 | #pragma define_template NOMAdapter_TArray<uint_8> | 
|---|
| [3661] | 503 | #pragma define_template NOMAdapter_TArray<int_1> | 
|---|
| [2930] | 504 | #pragma define_template NOMAdapter_TArray<int_2> | 
|---|
| [1315] | 505 | #pragma define_template NOMAdapter_TArray<int_4> | 
|---|
| [2930] | 506 | #pragma define_template NOMAdapter_TArray<int_8> | 
|---|
| [1315] | 507 | #pragma define_template NOMAdapter_TArray<r_4> | 
|---|
|  | 508 | #pragma define_template NOMAdapter_TArray<r_8> | 
|---|
|  | 509 | #pragma define_template NOMAdapter_TArray< complex<r_4> > | 
|---|
|  | 510 | #pragma define_template NOMAdapter_TArray< complex<r_8> > | 
|---|
| [3661] | 511 | #pragma define_template NTupInt_TArray<uint_1> | 
|---|
| [2930] | 512 | #pragma define_template NTupInt_TArray<uint_2> | 
|---|
| [3528] | 513 | #pragma define_template NTupInt_TArray<uint_4> | 
|---|
|  | 514 | #pragma define_template NTupInt_TArray<uint_8> | 
|---|
| [3661] | 515 | #pragma define_template NTupInt_TArray<int_1> | 
|---|
| [2930] | 516 | #pragma define_template NTupInt_TArray<int_2> | 
|---|
| [1315] | 517 | #pragma define_template NTupInt_TArray<int_4> | 
|---|
| [2930] | 518 | #pragma define_template NTupInt_TArray<int_8> | 
|---|
| [1315] | 519 | #pragma define_template NTupInt_TArray<r_4> | 
|---|
|  | 520 | #pragma define_template NTupInt_TArray<r_8> | 
|---|
|  | 521 | #pragma define_template NTupInt_TArray< complex<r_4> > | 
|---|
|  | 522 | #pragma define_template NTupInt_TArray< complex<r_8> > | 
|---|
|  | 523 | #endif | 
|---|
|  | 524 |  | 
|---|
|  | 525 | #if defined(ANSI_TEMPLATES) | 
|---|
| [3661] | 526 | template class NOMAdapter_TArray<uint_1>; | 
|---|
| [2930] | 527 | template class NOMAdapter_TArray<uint_2>; | 
|---|
| [3528] | 528 | template class NOMAdapter_TArray<uint_4>; | 
|---|
|  | 529 | template class NOMAdapter_TArray<uint_8>; | 
|---|
| [3661] | 530 | template class NOMAdapter_TArray<int_1>; | 
|---|
| [2930] | 531 | template class NOMAdapter_TArray<int_2>; | 
|---|
| [1315] | 532 | template class NOMAdapter_TArray<int_4>; | 
|---|
| [2930] | 533 | template class NOMAdapter_TArray<int_8>; | 
|---|
| [1315] | 534 | template class NOMAdapter_TArray<r_4>; | 
|---|
|  | 535 | template class NOMAdapter_TArray<r_8>; | 
|---|
|  | 536 | template class NOMAdapter_TArray< complex<r_4> >; | 
|---|
|  | 537 | template class NOMAdapter_TArray< complex<r_8> >; | 
|---|
| [3661] | 538 | template class NTupInt_TArray<uint_1>; | 
|---|
| [2930] | 539 | template class NTupInt_TArray<uint_2>; | 
|---|
| [3528] | 540 | template class NTupInt_TArray<uint_4>; | 
|---|
|  | 541 | template class NTupInt_TArray<uint_8>; | 
|---|
| [3661] | 542 | template class NTupInt_TArray<int_1>; | 
|---|
| [2930] | 543 | template class NTupInt_TArray<int_2>; | 
|---|
| [1315] | 544 | template class NTupInt_TArray<int_4>; | 
|---|
| [2930] | 545 | template class NTupInt_TArray<int_8>; | 
|---|
| [1315] | 546 | template class NTupInt_TArray<r_4>; | 
|---|
|  | 547 | template class NTupInt_TArray<r_8>; | 
|---|
|  | 548 | template class NTupInt_TArray< complex<r_4> >; | 
|---|
|  | 549 | template class NTupInt_TArray< complex<r_8> >; | 
|---|
|  | 550 | #endif | 
|---|