| [2615] | 1 | #include "sopnamsp.h" | 
|---|
| [585] | 2 | #include "machdefs.h" | 
|---|
|  | 3 | #include <stdlib.h> | 
|---|
|  | 4 | #include <typeinfo> | 
|---|
| [2322] | 5 | #include <iostream> | 
|---|
| [585] | 6 | #include <string> | 
|---|
|  | 7 | #include <complex> | 
|---|
|  | 8 |  | 
|---|
| [1224] | 9 | #include "datatype.h" | 
|---|
|  | 10 |  | 
|---|
| [585] | 11 | #include "tvector.h" | 
|---|
| [1207] | 12 | #include "objfitter.h" | 
|---|
| [585] | 13 | #include "nomtmatvecadapter.h" | 
|---|
| [1905] | 14 | #include "piyfxdrw.h" | 
|---|
| [585] | 15 | #include "pitvmaad.h" | 
|---|
|  | 16 |  | 
|---|
| [810] | 17 | #include "fioarr.h" | 
|---|
| [585] | 18 |  | 
|---|
| [2999] | 19 | #include "nobjmgr.h" | 
|---|
| [585] | 20 |  | 
|---|
|  | 21 | //---------------------------------------------------------------- | 
|---|
|  | 22 | // Class Adaptateur d'objet (Pour NamedObjMgr) d'objet TMatrix<T> | 
|---|
|  | 23 | //---------------------------------------------------------------- | 
|---|
|  | 24 |  | 
|---|
|  | 25 |  | 
|---|
|  | 26 | /* --Methode-- */ | 
|---|
|  | 27 | template <class T> | 
|---|
|  | 28 | NOMAdapter_TMatrix<T>::NOMAdapter_TMatrix(TMatrix<T>* o) | 
|---|
|  | 29 | : NObjMgrAdapter(o) | 
|---|
|  | 30 | { | 
|---|
|  | 31 | mMtx = o; | 
|---|
|  | 32 | } | 
|---|
|  | 33 |  | 
|---|
|  | 34 | /* --Methode-- */ | 
|---|
|  | 35 | template <class T> | 
|---|
|  | 36 | NOMAdapter_TMatrix<T>::~NOMAdapter_TMatrix() | 
|---|
|  | 37 | { | 
|---|
|  | 38 | } | 
|---|
|  | 39 |  | 
|---|
|  | 40 | /* --Methode-- */ | 
|---|
|  | 41 | template <class T> | 
|---|
|  | 42 | NObjMgrAdapter* NOMAdapter_TMatrix<T>::Clone(AnyDataObj* o) | 
|---|
|  | 43 | { | 
|---|
|  | 44 | TMatrix<T>* m = dynamic_cast<TMatrix<T> *>(o); | 
|---|
|  | 45 | if (m) return ( new NOMAdapter_TMatrix<T>(m) ); | 
|---|
|  | 46 | return ( new NObjMgrAdapter(o) ); | 
|---|
|  | 47 | } | 
|---|
|  | 48 |  | 
|---|
|  | 49 | /* --Methode-- */ | 
|---|
|  | 50 | template <class T> | 
|---|
| [1165] | 51 | string NOMAdapter_TMatrix<T>::GetDataObjType() | 
|---|
| [585] | 52 | { | 
|---|
| [1165] | 53 | string type = "TMatrix< "; | 
|---|
|  | 54 |  | 
|---|
|  | 55 | TVector<T>* v = dynamic_cast<TVector<T> *>(mMtx); | 
|---|
|  | 56 | if (v != NULL) type = "TVector< "; | 
|---|
|  | 57 |  | 
|---|
| [1224] | 58 | // type +=  DecodeTypeIdName(typeid(T).name()); | 
|---|
| [1237] | 59 | type += DataTypeInfo<T>::getTypeName(); | 
|---|
| [1165] | 60 | type +=  " > "; | 
|---|
|  | 61 | return(type); | 
|---|
|  | 62 | } | 
|---|
|  | 63 |  | 
|---|
|  | 64 | /* --Methode-- */ | 
|---|
|  | 65 | template <class T> | 
|---|
| [1315] | 66 | AnyDataObj* NOMAdapter_TMatrix<T>::CloneDataObj(bool share) | 
|---|
| [1165] | 67 | { | 
|---|
| [585] | 68 | if (mMtx == NULL)  return(NULL); | 
|---|
|  | 69 | TVector<T>* v = dynamic_cast<TVector<T> *>(mMtx); | 
|---|
| [1315] | 70 | if (v != NULL) return( new TVector<T>(*v, share) ); | 
|---|
|  | 71 | else return ( new TMatrix<T>(*mMtx, share) ); | 
|---|
| [585] | 72 | } | 
|---|
|  | 73 |  | 
|---|
| [2999] | 74 | /* --Methode-- */ | 
|---|
|  | 75 | template <class T> | 
|---|
|  | 76 | string NOMAdapter_TMatrix<T>::GetInfoString(vector<string>& opts) | 
|---|
|  | 77 | { | 
|---|
|  | 78 | if (opts.size() == 0) return mMtx->InfoString(); | 
|---|
|  | 79 | else { | 
|---|
|  | 80 | if (opts[0] == "rank") return string("2"); | 
|---|
|  | 81 | else if (opts[0] == "sizes") { | 
|---|
|  | 82 | char buff[64]; | 
|---|
|  | 83 | TVector<T>* v = dynamic_cast<TVector<T> *>(mMtx); | 
|---|
|  | 84 | if (v != NULL) sprintf(buff, "%ld", (long)mMtx->Size()); | 
|---|
|  | 85 | else sprintf(buff, "%ld %ld", (long)mMtx->NRows(), (long)mMtx->NCols()); | 
|---|
|  | 86 | return string(buff); | 
|---|
|  | 87 | } | 
|---|
|  | 88 | else if ((opts[0] == "size") || (opts[0] == "nelts")) { | 
|---|
|  | 89 | char buff[32]; | 
|---|
|  | 90 | sprintf(buff, "%ld", (long)mMtx->Size()); | 
|---|
|  | 91 | return string(buff); | 
|---|
|  | 92 | } | 
|---|
| [3033] | 93 | else if ((opts[0] == "nrow") || (opts[0] == "nrows")) { | 
|---|
|  | 94 | char buff[32]; | 
|---|
|  | 95 | sprintf(buff, "%ld", (long)mMtx->NRows()); | 
|---|
|  | 96 | return string(buff); | 
|---|
|  | 97 | } | 
|---|
|  | 98 | else if ((opts[0] == "ncol") || (opts[0] == "ncols")) { | 
|---|
|  | 99 | char buff[32]; | 
|---|
|  | 100 | sprintf(buff, "%ld", (long)mMtx->NCols()); | 
|---|
|  | 101 | return string(buff); | 
|---|
|  | 102 | } | 
|---|
| [2999] | 103 | else if (opts[0] == "sum") { | 
|---|
|  | 104 | MuTyV mtv(mMtx->Sum()); | 
|---|
|  | 105 | string s; | 
|---|
|  | 106 | return mtv.Convert(s); | 
|---|
|  | 107 | } | 
|---|
| [3039] | 108 | else return "TMatrix.Att: rank size/nelts nrow/nrows ncol/ncols sum"; | 
|---|
| [2999] | 109 | } | 
|---|
|  | 110 | } | 
|---|
| [1321] | 111 |  | 
|---|
|  | 112 | /* --Methode-- */ | 
|---|
|  | 113 | template <class T> | 
|---|
| [2999] | 114 | int NOMAdapter_TMatrix<T>::PerformOperation(vector<string>& opts) | 
|---|
|  | 115 | { | 
|---|
|  | 116 | bool ok = false; | 
|---|
|  | 117 | if (opts.size() >= 2) { | 
|---|
|  | 118 | int_4 kk = atoi(opts[1].c_str()); | 
|---|
|  | 119 | TVector<T> * vrc = new TVector<T>; | 
|---|
|  | 120 | char buff[40]; | 
|---|
|  | 121 | if ((opts[0] == "row") || (opts[0] == "line")) { | 
|---|
|  | 122 | vrc->Share(mMtx->Row((sa_size_t)kk)); | 
|---|
|  | 123 | ok = true; | 
|---|
|  | 124 | sprintf(buff,"row_%ld",(long)kk); | 
|---|
|  | 125 | cout << "PerformOperation(): Extracting Row(" << kk << ") from matrix" << endl; | 
|---|
|  | 126 | } | 
|---|
|  | 127 | else if ((opts[0] == "col") || (opts[0] == "column")) { | 
|---|
|  | 128 | vrc->Share(mMtx->Column((sa_size_t)kk)); | 
|---|
|  | 129 | ok = true; | 
|---|
|  | 130 | sprintf(buff,"col_%ld",(long)kk); | 
|---|
|  | 131 | cout << "PerformOperation(): Extracting Column(" << kk << ") from matrix" << endl; | 
|---|
|  | 132 | } | 
|---|
|  | 133 | if (ok) { | 
|---|
|  | 134 | string nvrc; | 
|---|
|  | 135 | if (opts.size() > 2)  nvrc = opts[2]; | 
|---|
|  | 136 | else nvrc = buff; | 
|---|
|  | 137 | NamedObjMgr omg; | 
|---|
|  | 138 | omg.AddObj(vrc, nvrc, true); | 
|---|
|  | 139 | return 0; | 
|---|
|  | 140 | } | 
|---|
|  | 141 | } | 
|---|
|  | 142 |  | 
|---|
| [3039] | 143 | cout << "NOMAdapter_TMatrix<T>::PerformOperation(): Error operation/arguments !" << endl; | 
|---|
|  | 144 | cout << "...Valid args: row/line r [rowname] , col/column c [rowname]" << endl; | 
|---|
| [2999] | 145 | return 1; | 
|---|
|  | 146 | } | 
|---|
|  | 147 |  | 
|---|
|  | 148 | /* --Methode-- */ | 
|---|
|  | 149 | template <class T> | 
|---|
| [585] | 150 | void NOMAdapter_TMatrix<T>::SavePPF(POutPersist& pos, string const & nom) | 
|---|
|  | 151 | { | 
|---|
|  | 152 | if (mMtx == NULL)  return; | 
|---|
|  | 153 | TVector<T>* v = dynamic_cast<TVector<T> *>(mMtx); | 
|---|
|  | 154 | if (v != NULL) { | 
|---|
| [810] | 155 | FIO_TArray<T> fio(v); | 
|---|
| [585] | 156 | fio.Write(pos, nom); | 
|---|
|  | 157 | } | 
|---|
|  | 158 | else { | 
|---|
| [810] | 159 | FIO_TArray<T> fio(mMtx); | 
|---|
| [585] | 160 | fio.Write(pos, nom); | 
|---|
|  | 161 | } | 
|---|
|  | 162 | } | 
|---|
|  | 163 |  | 
|---|
|  | 164 | /* --Methode-- */ | 
|---|
|  | 165 | template <class T> | 
|---|
| [2975] | 166 | void NOMAdapter_TMatrix<T>::Print(ostream& os, int lev) | 
|---|
| [585] | 167 | { | 
|---|
| [2975] | 168 | if (lev < 3) mMtx->Show(os, false); | 
|---|
|  | 169 | else  mMtx->Show(os, true); | 
|---|
|  | 170 | if (lev > 0) mMtx->Print(os, 10*lev); | 
|---|
| [585] | 171 | } | 
|---|
|  | 172 |  | 
|---|
|  | 173 | /* --Methode-- */ | 
|---|
|  | 174 | template <class T> | 
|---|
|  | 175 | PIDrawer* NOMAdapter_TMatrix<T>::GetDrawer(string & dopt) | 
|---|
|  | 176 | { | 
|---|
|  | 177 | TVector<T>* v = dynamic_cast<TVector<T> *>(mMtx); | 
|---|
|  | 178 | if (v == NULL) return(NULL); | 
|---|
|  | 179 | else { | 
|---|
| [1971] | 180 | dopt = "thinline " + dopt; | 
|---|
| [585] | 181 | return( new PIYfXDrawer( new POTVectorAdapter<T>(v, false), NULL, true) ); | 
|---|
|  | 182 | } | 
|---|
|  | 183 | } | 
|---|
|  | 184 |  | 
|---|
|  | 185 | /* --Methode-- */ | 
|---|
|  | 186 | template <class T> | 
|---|
|  | 187 | P2DArrayAdapter* NOMAdapter_TMatrix<T>::Get2DArray(string &) | 
|---|
|  | 188 | { | 
|---|
|  | 189 | return ( new POTMatrixAdapter<T>(mMtx, false) ); | 
|---|
|  | 190 | } | 
|---|
|  | 191 |  | 
|---|
|  | 192 | /* --Methode-- */ | 
|---|
|  | 193 | template <class T> | 
|---|
|  | 194 | NTupleInterface* NOMAdapter_TMatrix<T>::GetNTupleInterface(bool& adel) | 
|---|
|  | 195 | { | 
|---|
|  | 196 | adel = true; | 
|---|
|  | 197 | return( new NTupInt_TMatrix<T>(mMtx) ); | 
|---|
|  | 198 | } | 
|---|
|  | 199 |  | 
|---|
|  | 200 |  | 
|---|
| [1207] | 201 | /* --Methode-- */ | 
|---|
|  | 202 | template <class T> | 
|---|
|  | 203 | GeneralFitData* NOMAdapter_TMatrix<T>::GetGeneralFitData(bool& adel | 
|---|
|  | 204 | ,GeneralFitData::FitErrType errtype,double errscale,double errmin | 
|---|
|  | 205 | ,int i1,int i2,int j1,int j2) | 
|---|
|  | 206 | { | 
|---|
|  | 207 | adel = false; | 
|---|
|  | 208 | if(!mMtx) return(NULL); | 
|---|
| [585] | 209 |  | 
|---|
| [1207] | 210 | int nx,ny; | 
|---|
|  | 211 | TVector<T>* vec = dynamic_cast<TVector<T> *>(mMtx); | 
|---|
|  | 212 |  | 
|---|
|  | 213 | if(vec) {  // C'est un TVector | 
|---|
|  | 214 | nx = vec->NElts(); | 
|---|
|  | 215 | ny = 1; | 
|---|
|  | 216 | } else { | 
|---|
|  | 217 | nx = mMtx->NRows(); | 
|---|
|  | 218 | ny = mMtx->NCol(); | 
|---|
|  | 219 | if(nx<=0 || ny<=0) return(NULL); | 
|---|
|  | 220 | } | 
|---|
|  | 221 |  | 
|---|
|  | 222 | i1 = (i1<0||i1>=nx)? 0: i1; | 
|---|
|  | 223 | i2 = (i2<0||i2>=nx||i2<i1)? nx-1: i2; | 
|---|
|  | 224 | j1 = (j1<0||j1>=ny)? 0: j1; | 
|---|
|  | 225 | j2 = (j2<0||j2>=ny||j2<j1)? ny-1: j2; | 
|---|
|  | 226 |  | 
|---|
|  | 227 | GeneralFitData* mGData = NULL; | 
|---|
|  | 228 |  | 
|---|
|  | 229 | if(vec) {  // C'est un TVector | 
|---|
|  | 230 | mGData = new GeneralFitData(1,(i2-i1+1),0); | 
|---|
|  | 231 | adel = true; | 
|---|
|  | 232 | for(int i=i1;i<=i2;i++) { | 
|---|
|  | 233 | double x = (double) i; | 
|---|
|  | 234 | double f = (*vec)(i); | 
|---|
|  | 235 | double e = 1.; | 
|---|
|  | 236 | e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); | 
|---|
|  | 237 | mGData->AddData1(x,f,e); | 
|---|
|  | 238 | } | 
|---|
|  | 239 | } else { | 
|---|
|  | 240 | mGData = new GeneralFitData(2,(i2-i1+1)*(j2-j1+1),0); | 
|---|
|  | 241 | adel = true; | 
|---|
|  | 242 | for(int i=i1;i<=i2;i++) for(int j=j1;j<=j2;j++) { | 
|---|
|  | 243 | double x = (double) i; | 
|---|
|  | 244 | double y = (double) j; | 
|---|
|  | 245 | double f = (*mMtx)(i,j); | 
|---|
|  | 246 | double e = 1.; | 
|---|
|  | 247 | e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin); | 
|---|
|  | 248 | mGData->AddData2(x,y,f,e); | 
|---|
|  | 249 | } | 
|---|
|  | 250 | } | 
|---|
|  | 251 |  | 
|---|
|  | 252 | return mGData; | 
|---|
|  | 253 | } | 
|---|
|  | 254 |  | 
|---|
|  | 255 | template <class T> | 
|---|
|  | 256 | AnyDataObj* NOMAdapter_TMatrix<T>::FitResidusObj(GeneralFit& mfit) | 
|---|
|  | 257 | { | 
|---|
|  | 258 | TVector<T>* vec = dynamic_cast<TVector<T> *>(mMtx); | 
|---|
|  | 259 | if(vec) { | 
|---|
|  | 260 | TVector<T>* v = new TVector<T>(ObjectFitter::FitResidus(*vec,mfit),true); | 
|---|
|  | 261 | return v; | 
|---|
|  | 262 | } else { | 
|---|
|  | 263 | TMatrix<T>* m = new TMatrix<T>(ObjectFitter::FitResidus(*mMtx,mfit),true); | 
|---|
|  | 264 | return m; | 
|---|
|  | 265 | } | 
|---|
|  | 266 | } | 
|---|
|  | 267 |  | 
|---|
|  | 268 | template <class T> | 
|---|
|  | 269 | AnyDataObj* NOMAdapter_TMatrix<T>::FitFunctionObj(GeneralFit& mfit) | 
|---|
|  | 270 | { | 
|---|
|  | 271 | TVector<T>* vec = dynamic_cast<TVector<T> *>(mMtx); | 
|---|
|  | 272 | if(vec) { | 
|---|
|  | 273 | TVector<T>* v = new TVector<T>(ObjectFitter::FitFunction(*vec,mfit),true); | 
|---|
|  | 274 | return v; | 
|---|
|  | 275 | } else { | 
|---|
|  | 276 | TMatrix<T>* m = new TMatrix<T>(ObjectFitter::FitFunction(*mMtx,mfit),true); | 
|---|
|  | 277 | return m; | 
|---|
|  | 278 | } | 
|---|
|  | 279 | } | 
|---|
|  | 280 |  | 
|---|
| [1315] | 281 | // ---- Specialisation pour complexes ----- | 
|---|
| [2343] | 282 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [1315] | 283 | GeneralFitData* NOMAdapter_TMatrix< complex<r_4> >::GetGeneralFitData(bool& adel | 
|---|
|  | 284 | ,GeneralFitData::FitErrType errtype,double errscale,double errmin | 
|---|
|  | 285 | ,int i1,int i2,int j1,int j2) | 
|---|
|  | 286 | { | 
|---|
|  | 287 | return(NULL); | 
|---|
|  | 288 | } | 
|---|
| [1207] | 289 |  | 
|---|
| [2343] | 290 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [1315] | 291 | AnyDataObj* NOMAdapter_TMatrix< complex<r_4> >::FitResidusObj(GeneralFit& mfit) | 
|---|
|  | 292 | { | 
|---|
|  | 293 | return(NULL); | 
|---|
|  | 294 | } | 
|---|
|  | 295 |  | 
|---|
| [2343] | 296 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [1315] | 297 | AnyDataObj* NOMAdapter_TMatrix< complex<r_4> >::FitFunctionObj(GeneralFit& mfit) | 
|---|
|  | 298 | { | 
|---|
|  | 299 | return(NULL); | 
|---|
|  | 300 | } | 
|---|
|  | 301 |  | 
|---|
| [2343] | 302 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [1315] | 303 | GeneralFitData* NOMAdapter_TMatrix< complex<r_8> >::GetGeneralFitData(bool& adel | 
|---|
|  | 304 | ,GeneralFitData::FitErrType errtype,double errscale,double errmin | 
|---|
|  | 305 | ,int i1,int i2,int j1,int j2) | 
|---|
|  | 306 | { | 
|---|
|  | 307 | return(NULL); | 
|---|
|  | 308 | } | 
|---|
|  | 309 |  | 
|---|
| [2343] | 310 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [1315] | 311 | AnyDataObj* NOMAdapter_TMatrix< complex<r_8> >::FitResidusObj(GeneralFit& mfit) | 
|---|
|  | 312 | { | 
|---|
|  | 313 | return(NULL); | 
|---|
|  | 314 | } | 
|---|
|  | 315 |  | 
|---|
| [2343] | 316 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [1315] | 317 | AnyDataObj* NOMAdapter_TMatrix< complex<r_8> >::FitFunctionObj(GeneralFit& mfit) | 
|---|
|  | 318 | { | 
|---|
|  | 319 | return(NULL); | 
|---|
|  | 320 | } | 
|---|
|  | 321 |  | 
|---|
| [585] | 322 | // ------------------------------------------------------------- | 
|---|
|  | 323 |  | 
|---|
|  | 324 | /* --Methode-- */ | 
|---|
|  | 325 | template <class T> | 
|---|
|  | 326 | NTupInt_TMatrix<T>::NTupInt_TMatrix(TMatrix<T>* m) | 
|---|
|  | 327 | { | 
|---|
|  | 328 | mMtx = m; | 
|---|
|  | 329 | } | 
|---|
|  | 330 |  | 
|---|
|  | 331 | /* --Methode-- */ | 
|---|
|  | 332 | template <class T> | 
|---|
|  | 333 | NTupInt_TMatrix<T>::~NTupInt_TMatrix() | 
|---|
|  | 334 | { | 
|---|
|  | 335 | } | 
|---|
|  | 336 |  | 
|---|
|  | 337 | /* --Methode-- */ | 
|---|
|  | 338 | template <class T> | 
|---|
| [2683] | 339 | sa_size_t NTupInt_TMatrix<T>::NbLines() const | 
|---|
| [585] | 340 | { | 
|---|
|  | 341 | return( mMtx->NRows()*mMtx->NCols() ); | 
|---|
|  | 342 | } | 
|---|
|  | 343 |  | 
|---|
|  | 344 | /* --Methode-- */ | 
|---|
|  | 345 | template <class T> | 
|---|
| [2683] | 346 | sa_size_t  NTupInt_TMatrix<T>::NbColumns() const | 
|---|
| [585] | 347 | { | 
|---|
|  | 348 | return(8); | 
|---|
|  | 349 | } | 
|---|
|  | 350 |  | 
|---|
|  | 351 | /* --Methode-- */ | 
|---|
|  | 352 | template <class T> | 
|---|
| [2683] | 353 | r_8* NTupInt_TMatrix<T>::GetLineD(sa_size_t n) const | 
|---|
| [585] | 354 | { | 
|---|
|  | 355 | int i,j; | 
|---|
|  | 356 | if ((n < 0) || (n >= (int)(mMtx->NRows()*mMtx->NCols()) )) { | 
|---|
|  | 357 | mRet[0] = n; | 
|---|
|  | 358 | for(i=1; i<8; i++)  mRet[i] = 0.; | 
|---|
|  | 359 | } | 
|---|
|  | 360 | else { | 
|---|
|  | 361 | i = n/mMtx->NCols(); j = n%mMtx->NCols(); | 
|---|
|  | 362 | mRet[0] = n;  mRet[1] = i;  mRet[2] = j; | 
|---|
|  | 363 | mRet[3] = (*mMtx)(i,j); | 
|---|
|  | 364 | mRet[4] = mRet[2];  mRet[5] = 0.; | 
|---|
|  | 365 | mRet[6] = mRet[2];  mRet[7] = 0.; | 
|---|
|  | 366 | } | 
|---|
|  | 367 | return(mRet); | 
|---|
|  | 368 | } | 
|---|
|  | 369 |  | 
|---|
|  | 370 | /* --Methode-- */ | 
|---|
|  | 371 | template <class T> | 
|---|
|  | 372 | string NTupInt_TMatrix<T>::VarList_C(const char* nx) const | 
|---|
|  | 373 | { | 
|---|
|  | 374 | string nomx; | 
|---|
|  | 375 | if (nx) nomx = nx; | 
|---|
|  | 376 | else nomx = "_xh_"; | 
|---|
|  | 377 | string vardec = "double n,r,c,val,real,imag,mod,phas; \n"; | 
|---|
|  | 378 | vardec += "n = " + nomx + "[0];  r = " + nomx + "[1]; c = " + nomx + "[2]; \n"; | 
|---|
|  | 379 | vardec += "val = " + nomx + "[3]; \n"; | 
|---|
|  | 380 | vardec += "real = " + nomx + "[4];  imag = " + nomx + "[5]; \n"; | 
|---|
|  | 381 | vardec += "mod  = " + nomx + "[6];  phas = " + nomx + "[7]; \n"; | 
|---|
|  | 382 | return(vardec); | 
|---|
|  | 383 | } | 
|---|
|  | 384 |  | 
|---|
|  | 385 | /* --Methode-- */ | 
|---|
| [2343] | 386 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [2689] | 387 | r_8* NTupInt_TMatrix< complex<r_4> >::GetLineD(sa_size_t n) const | 
|---|
| [585] | 388 | { | 
|---|
|  | 389 | int i,j; | 
|---|
|  | 390 | if ((n < 0) || (n >= (int)(mMtx->NRows()*mMtx->NCols()) )) { | 
|---|
|  | 391 | mRet[0] = n; | 
|---|
|  | 392 | for(i=1; i<8; i++)  mRet[i] = 0.; | 
|---|
|  | 393 | } | 
|---|
|  | 394 | else { | 
|---|
|  | 395 | i = n/mMtx->NCols(); j = n%mMtx->NCols(); | 
|---|
|  | 396 | mRet[0] = n;   mRet[1] = i;  mRet[2] = j; | 
|---|
|  | 397 | mRet[4] = (*mMtx)(i,j).real();  mRet[5] = (*mMtx)(i,j).imag(); | 
|---|
|  | 398 | mRet[3] = mRet[6] = sqrt(mRet[4]*mRet[4]+mRet[5]*mRet[5]); | 
|---|
|  | 399 | mRet[7] = atan2(mRet[5], mRet[4]); | 
|---|
|  | 400 | } | 
|---|
|  | 401 | return(mRet); | 
|---|
|  | 402 | } | 
|---|
|  | 403 |  | 
|---|
| [2343] | 404 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [2689] | 405 | r_8* NTupInt_TMatrix< complex<r_8> >::GetLineD(sa_size_t n) const | 
|---|
| [585] | 406 | { | 
|---|
|  | 407 | int i,j; | 
|---|
|  | 408 | if ((n < 0) || (n >= (int)(mMtx->NRows()*mMtx->NCols()) )) { | 
|---|
|  | 409 | mRet[0] = n; | 
|---|
|  | 410 | for(i=1; i<8; i++)  mRet[i] = 0.; | 
|---|
|  | 411 | } | 
|---|
|  | 412 | else { | 
|---|
|  | 413 | i = n/mMtx->NCols(); j = n%mMtx->NCols(); | 
|---|
|  | 414 | mRet[0] = n;   mRet[1] = i;  mRet[2] = j; | 
|---|
|  | 415 | mRet[4] = (*mMtx)(i,j).real();  mRet[5] = (*mMtx)(i,j).imag(); | 
|---|
|  | 416 | mRet[3] = mRet[6] = sqrt(mRet[4]*mRet[4]+mRet[5]*mRet[5]); | 
|---|
|  | 417 | mRet[7] = atan2(mRet[5], mRet[4]); | 
|---|
|  | 418 | } | 
|---|
|  | 419 | return(mRet); | 
|---|
|  | 420 | } | 
|---|
|  | 421 |  | 
|---|
|  | 422 |  | 
|---|
|  | 423 | #ifdef __CXX_PRAGMA_TEMPLATES__ | 
|---|
| [2930] | 424 | #pragma define_template NOMAdapter_TMatrix<uint_2> | 
|---|
|  | 425 | #pragma define_template NOMAdapter_TMatrix<int_2> | 
|---|
| [585] | 426 | #pragma define_template NOMAdapter_TMatrix<int_4> | 
|---|
| [2930] | 427 | #pragma define_template NOMAdapter_TMatrix<int_8> | 
|---|
| [585] | 428 | #pragma define_template NOMAdapter_TMatrix<r_4> | 
|---|
|  | 429 | #pragma define_template NOMAdapter_TMatrix<r_8> | 
|---|
| [1315] | 430 | #pragma define_template NOMAdapter_TMatrix< complex<r_4> > | 
|---|
|  | 431 | #pragma define_template NOMAdapter_TMatrix< complex<r_8> > | 
|---|
| [2930] | 432 | #pragma define_template NTupInt_TMatrix<uint_2> | 
|---|
|  | 433 | #pragma define_template NTupInt_TMatrix<int_2> | 
|---|
| [585] | 434 | #pragma define_template NTupInt_TMatrix<int_4> | 
|---|
| [2930] | 435 | #pragma define_template NTupInt_TMatrix<int_8> | 
|---|
| [585] | 436 | #pragma define_template NTupInt_TMatrix<r_4> | 
|---|
|  | 437 | #pragma define_template NTupInt_TMatrix<r_8> | 
|---|
| [719] | 438 | #pragma define_template NTupInt_TMatrix< complex<r_4> > | 
|---|
|  | 439 | #pragma define_template NTupInt_TMatrix< complex<r_8> > | 
|---|
| [585] | 440 | #endif | 
|---|
|  | 441 |  | 
|---|
|  | 442 | #if defined(ANSI_TEMPLATES) | 
|---|
| [2930] | 443 | template class NOMAdapter_TMatrix<uint_2>; | 
|---|
|  | 444 | template class NOMAdapter_TMatrix<int_2>; | 
|---|
| [585] | 445 | template class NOMAdapter_TMatrix<int_4>; | 
|---|
| [2930] | 446 | template class NOMAdapter_TMatrix<int_8>; | 
|---|
| [585] | 447 | template class NOMAdapter_TMatrix<r_4>; | 
|---|
|  | 448 | template class NOMAdapter_TMatrix<r_8>; | 
|---|
| [1315] | 449 | template class NOMAdapter_TMatrix< complex<r_4> >; | 
|---|
|  | 450 | template class NOMAdapter_TMatrix< complex<r_8> >; | 
|---|
| [2930] | 451 | template class NTupInt_TMatrix<uint_2>; | 
|---|
|  | 452 | template class NTupInt_TMatrix<int_2>; | 
|---|
| [585] | 453 | template class NTupInt_TMatrix<int_4>; | 
|---|
| [2930] | 454 | template class NTupInt_TMatrix<int_8>; | 
|---|
| [585] | 455 | template class NTupInt_TMatrix<r_4>; | 
|---|
|  | 456 | template class NTupInt_TMatrix<r_8>; | 
|---|
| [719] | 457 | template class NTupInt_TMatrix< complex<r_4> >; | 
|---|
|  | 458 | template class NTupInt_TMatrix< complex<r_8> >; | 
|---|
| [585] | 459 | #endif | 
|---|