[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 |
|
---|
| 68 | /* --Methode-- */
|
---|
| 69 | template <class T>
|
---|
[1321] | 70 | void NOMAdapter_TArray<T>::ReadFits(string const & flnm)
|
---|
| 71 | {
|
---|
| 72 | FitsInFile fis(flnm);
|
---|
| 73 | fis >> (*mArr);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | /* --Methode-- */
|
---|
| 77 | template <class T>
|
---|
| 78 | void NOMAdapter_TArray<T>::SaveFits(string const & flnm)
|
---|
| 79 | {
|
---|
| 80 | FitsOutFile fos(flnm);
|
---|
| 81 | fos << (*mArr);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | // ---- Specialisation pour complexes -----
|
---|
[2343] | 85 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[1321] | 86 | void NOMAdapter_TArray< complex<r_4> >::ReadFits(string const & flnm)
|
---|
| 87 | {
|
---|
| 88 | cout << " NOMAdapter_TArray< complex<r_4> >::ReadFits() - Error "
|
---|
| 89 | << " Not supported (complex data type)" << endl;
|
---|
| 90 | }
|
---|
[2343] | 91 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[1321] | 92 | void NOMAdapter_TArray< complex<r_4> >::SaveFits(string const & flnm)
|
---|
| 93 | {
|
---|
| 94 | cout << " NOMAdapter_TArray< complex<r_4> >::SaveFits() - Error "
|
---|
| 95 | << " Not supported (complex data type)" << endl;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
[2343] | 98 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[1321] | 99 | void NOMAdapter_TArray< complex<r_8> >::ReadFits(string const & flnm)
|
---|
| 100 | {
|
---|
| 101 | cout << " NOMAdapter_TArray< complex<r_8> >::ReadFits() - Error "
|
---|
| 102 | << " Not supported (complex data type)" << endl;
|
---|
| 103 | }
|
---|
[2343] | 104 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[1321] | 105 | void NOMAdapter_TArray< complex<r_8> >::SaveFits(string const & flnm)
|
---|
| 106 | {
|
---|
| 107 | cout << " NOMAdapter_TArray< complex<r_8> >::SaveFits() - Error "
|
---|
| 108 | << " Not supported (complex data type)" << endl;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /* --Methode-- */
|
---|
| 112 | template <class T>
|
---|
[1315] | 113 | void NOMAdapter_TArray<T>::SavePPF(POutPersist& pos, string const & nom)
|
---|
| 114 | {
|
---|
| 115 | FIO_TArray<T> fio(mArr);
|
---|
| 116 | fio.Write(pos, nom);
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | /* --Methode-- */
|
---|
| 120 | template <class T>
|
---|
| 121 | void NOMAdapter_TArray<T>::Print(ostream& os)
|
---|
| 122 | {
|
---|
| 123 | os << (*mArr);
|
---|
| 124 | }
|
---|
| 125 |
|
---|
[1321] | 126 | /* --Methode-- */
|
---|
| 127 | template <class T>
|
---|
| 128 | PIDrawer * NOMAdapter_TArray<T>::GetDrawer(string & dopt)
|
---|
| 129 | {
|
---|
| 130 | if (mArr->NbDimensions() == 1) {
|
---|
| 131 | // On peut en faire un vecteur ...
|
---|
| 132 | TVector<T>* v = new TVector<T>(*mArr, true); // on partage les donnees
|
---|
| 133 | dopt = "thinline," + dopt;
|
---|
| 134 | return( new PIYfXDrawer( new POTVectorAdapter<T>(v, true), NULL, true) );
|
---|
| 135 | }
|
---|
| 136 | else return(NULL);
|
---|
| 137 | }
|
---|
[1315] | 138 |
|
---|
| 139 | /* --Methode-- */
|
---|
| 140 | template <class T>
|
---|
[1321] | 141 | P2DArrayAdapter* NOMAdapter_TArray<T>::Get2DArray(string &)
|
---|
| 142 | {
|
---|
| 143 | if (mArr->NbDimensions() <= 2) {
|
---|
| 144 | // On peut en faire un tableau 2-D ...
|
---|
| 145 | TMatrix<T>* m = new TMatrix<T>(*mArr, true); // on partage les donnees
|
---|
| 146 | return ( new POTMatrixAdapter<T>(m, true) );
|
---|
| 147 | }
|
---|
| 148 | else return(NULL);
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | /* --Methode-- */
|
---|
| 152 | template <class T>
|
---|
[1315] | 153 | NTupleInterface* NOMAdapter_TArray<T>::GetNTupleInterface(bool& adel)
|
---|
| 154 | {
|
---|
| 155 | adel = true;
|
---|
| 156 | return( new NTupInt_TArray<T>(mArr) );
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 |
|
---|
| 161 |
|
---|
| 162 | // -------------------------------------------------------------
|
---|
| 163 |
|
---|
| 164 | /* --Methode-- */
|
---|
| 165 | template <class T>
|
---|
| 166 | NTupInt_TArray<T>::NTupInt_TArray(TArray<T>* a)
|
---|
| 167 | {
|
---|
| 168 | mArr = a;
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | /* --Methode-- */
|
---|
| 172 | template <class T>
|
---|
| 173 | NTupInt_TArray<T>::~NTupInt_TArray()
|
---|
| 174 | {
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | /* --Methode-- */
|
---|
| 178 | template <class T>
|
---|
| 179 | uint_4 NTupInt_TArray<T>::NbLines() const
|
---|
| 180 | {
|
---|
| 181 | return( mArr->Size() );
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | /* --Methode-- */
|
---|
| 185 | template <class T>
|
---|
| 186 | uint_4 NTupInt_TArray<T>::NbColumns() const
|
---|
| 187 | {
|
---|
| 188 | return(11);
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | /* --Methode-- */
|
---|
| 192 | template <class T>
|
---|
| 193 | r_8* NTupInt_TArray<T>::GetLineD(int n) const
|
---|
| 194 | {
|
---|
| 195 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) {
|
---|
| 196 | mRet[0] = n;
|
---|
| 197 | for(int i=1; i<11; i++) mRet[i] = 0.;
|
---|
| 198 | }
|
---|
| 199 | else {
|
---|
| 200 | sa_size_t ix, iy, iz, it, iu;
|
---|
| 201 | mArr->IndexAtPosition(n, ix, iy, iz, it, iu);
|
---|
| 202 | mRet[0] = n; mRet[1] = ix; mRet[2] = iy;
|
---|
| 203 | mRet[3] = iz; mRet[4] = it; mRet[5] = iu;
|
---|
| 204 | mRet[6] = (*mArr)(ix,iy,iz,it,iu);
|
---|
| 205 | mRet[7] = mRet[2]; mRet[8] = 0.;
|
---|
| 206 | mRet[9] = mRet[2]; mRet[10] = 0.;
|
---|
| 207 | }
|
---|
| 208 | return(mRet);
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | /* --Methode-- */
|
---|
| 212 | template <class T>
|
---|
| 213 | string NTupInt_TArray<T>::VarList_C(const char* nx) const
|
---|
| 214 | {
|
---|
| 215 | string nomx;
|
---|
| 216 | if (nx) nomx = nx;
|
---|
| 217 | else nomx = "_xh_";
|
---|
| 218 | string vardec = "double n,x,y,z,t,u,val,real,imag,mod,phas; \n";
|
---|
| 219 | vardec += "n = " + nomx + "[0]; x = " + nomx + "[1]; y = " + nomx + "[2]; \n";
|
---|
| 220 | vardec += "z = " + nomx + "[3]; t = " + nomx + "[4]; u = " + nomx + "[5]; \n";
|
---|
| 221 | vardec += "val = " + nomx + "[6]; \n";
|
---|
| 222 | vardec += "real = " + nomx + "[7]; imag = " + nomx + "[8]; \n";
|
---|
| 223 | vardec += "mod = " + nomx + "[9]; phas = " + nomx + "[10]; \n";
|
---|
| 224 | return(vardec);
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | /* --Methode-- */
|
---|
[2343] | 228 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[1315] | 229 | r_8* NTupInt_TArray< complex<r_4> >::GetLineD(int n) const
|
---|
| 230 | {
|
---|
| 231 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) {
|
---|
| 232 | mRet[0] = n;
|
---|
| 233 | for(int i=1; i<11; i++) mRet[i] = 0.;
|
---|
| 234 | }
|
---|
| 235 | else {
|
---|
| 236 | sa_size_t ix, iy, iz, it, iu;
|
---|
| 237 | mArr->IndexAtPosition(n, ix, iy, iz, it, iu);
|
---|
| 238 | mRet[0] = n; mRet[1] = ix; mRet[2] = iy;
|
---|
| 239 | mRet[3] = iz; mRet[4] = it; mRet[5] = iu;
|
---|
| 240 | mRet[7] = (*mArr)(ix,iy,iz,it,iu).real();
|
---|
| 241 | mRet[8] = (*mArr)(ix,iy,iz,it,iu).imag();
|
---|
| 242 | mRet[3] = mRet[6] = sqrt(mRet[7]*mRet[7]+mRet[8]*mRet[8]);
|
---|
| 243 | mRet[7] = atan2(mRet[8], mRet[7]);
|
---|
| 244 | }
|
---|
| 245 | return(mRet);
|
---|
| 246 | }
|
---|
| 247 |
|
---|
[2343] | 248 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[1315] | 249 | r_8* NTupInt_TArray< complex<r_8> >::GetLineD(int n) const
|
---|
| 250 | {
|
---|
| 251 | if ((n < 0) || (n >= (int)(mArr->Size()) ) ) {
|
---|
| 252 | mRet[0] = n;
|
---|
| 253 | for(int i=1; i<11; i++) mRet[i] = 0.;
|
---|
| 254 | }
|
---|
| 255 | else {
|
---|
| 256 | sa_size_t ix, iy, iz, it, iu;
|
---|
| 257 | mArr->IndexAtPosition(n, ix, iy, iz, it, iu);
|
---|
| 258 | mRet[0] = n; mRet[1] = ix; mRet[2] = iy;
|
---|
| 259 | mRet[3] = iz; mRet[4] = it; mRet[5] = iu;
|
---|
| 260 | mRet[7] = (*mArr)(ix,iy,iz,it,iu).real();
|
---|
| 261 | mRet[8] = (*mArr)(ix,iy,iz,it,iu).imag();
|
---|
| 262 | mRet[3] = mRet[6] = sqrt(mRet[7]*mRet[7]+mRet[8]*mRet[8]);
|
---|
| 263 | mRet[7] = atan2(mRet[8], mRet[7]);
|
---|
| 264 | }
|
---|
| 265 | return(mRet);
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 |
|
---|
| 269 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
| 270 | //#pragma define_template NOMAdapter_TArray<uint_2>
|
---|
| 271 | //#pragma define_template NOMAdapter_TArray<int_2>
|
---|
| 272 | #pragma define_template NOMAdapter_TArray<int_4>
|
---|
| 273 | #pragma define_template NOMAdapter_TArray<r_4>
|
---|
| 274 | #pragma define_template NOMAdapter_TArray<r_8>
|
---|
| 275 | #pragma define_template NOMAdapter_TArray< complex<r_4> >
|
---|
| 276 | #pragma define_template NOMAdapter_TArray< complex<r_8> >
|
---|
| 277 | //#pragma define_template NTupInt_TArray<uint_2>
|
---|
| 278 | //#pragma define_template NTupInt_TArray<int_2>
|
---|
| 279 | #pragma define_template NTupInt_TArray<int_4>
|
---|
| 280 | #pragma define_template NTupInt_TArray<r_4>
|
---|
| 281 | #pragma define_template NTupInt_TArray<r_8>
|
---|
| 282 | #pragma define_template NTupInt_TArray< complex<r_4> >
|
---|
| 283 | #pragma define_template NTupInt_TArray< complex<r_8> >
|
---|
| 284 | #endif
|
---|
| 285 |
|
---|
| 286 | #if defined(ANSI_TEMPLATES)
|
---|
| 287 | //template class NOMAdapter_TArray<uint_2>;
|
---|
| 288 | //template class NOMAdapter_TArray<int_2>;
|
---|
| 289 | template class NOMAdapter_TArray<int_4>;
|
---|
| 290 | template class NOMAdapter_TArray<r_4>;
|
---|
| 291 | template class NOMAdapter_TArray<r_8>;
|
---|
| 292 | template class NOMAdapter_TArray< complex<r_4> >;
|
---|
| 293 | template class NOMAdapter_TArray< complex<r_8> >;
|
---|
| 294 | // template class NTupInt_TArray<uint_2>;
|
---|
| 295 | // template class NTupInt_TArray<int_2>;
|
---|
| 296 | template class NTupInt_TArray<int_4>;
|
---|
| 297 | template class NTupInt_TArray<r_4>;
|
---|
| 298 | template class NTupInt_TArray<r_8>;
|
---|
| 299 | template class NTupInt_TArray< complex<r_4> >;
|
---|
| 300 | template class NTupInt_TArray< complex<r_8> >;
|
---|
| 301 | #endif
|
---|