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