Changeset 2999 in Sophya for trunk/SophyaPI/PIext/nomtmatvecadapter.cc
- Timestamp:
- Jul 2, 2006, 7:20:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/nomtmatvecadapter.cc
r2975 r2999 17 17 #include "fioarr.h" 18 18 19 #include "nobjmgr.h" 19 20 20 21 //---------------------------------------------------------------- … … 71 72 } 72 73 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 } 93 else if (opts[0] == "sum") { 94 MuTyV mtv(mMtx->Sum()); 95 string s; 96 return mtv.Convert(s); 97 } 98 else return mMtx->InfoString(); 99 } 100 } 101 102 /* --Methode-- */ 103 template <class T> 104 int NOMAdapter_TMatrix<T>::PerformOperation(vector<string>& opts) 105 { 106 bool ok = false; 107 if (opts.size() >= 2) { 108 int_4 kk = atoi(opts[1].c_str()); 109 TVector<T> * vrc = new TVector<T>; 110 char buff[40]; 111 if ((opts[0] == "row") || (opts[0] == "line")) { 112 vrc->Share(mMtx->Row((sa_size_t)kk)); 113 ok = true; 114 sprintf(buff,"row_%ld",(long)kk); 115 cout << "PerformOperation(): Extracting Row(" << kk << ") from matrix" << endl; 116 } 117 else if ((opts[0] == "col") || (opts[0] == "column")) { 118 vrc->Share(mMtx->Column((sa_size_t)kk)); 119 ok = true; 120 sprintf(buff,"col_%ld",(long)kk); 121 cout << "PerformOperation(): Extracting Column(" << kk << ") from matrix" << endl; 122 } 123 if (ok) { 124 string nvrc; 125 if (opts.size() > 2) nvrc = opts[2]; 126 else nvrc = buff; 127 NamedObjMgr omg; 128 omg.AddObj(vrc, nvrc, true); 129 return 0; 130 } 131 } 132 133 cout << "NOMAdapter_TMatrix<T>::PerformOperation(): Error operation/arguments !" << endl; 134 return 1; 135 } 73 136 74 137 /* --Methode-- */
Note:
See TracChangeset
for help on using the changeset viewer.