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