| [224] | 1 | #include <stdio.h> | 
|---|
|  | 2 | #include <stdlib.h> | 
|---|
|  | 3 | #include <math.h> | 
|---|
| [2322] | 4 | #include <iostream> | 
|---|
| [2832] | 5 | #include <fstream> | 
|---|
| [224] | 6 |  | 
|---|
| [2615] | 7 | #include "sopnamsp.h" | 
|---|
| [768] | 8 | #include "histinit.h" | 
|---|
| [720] | 9 | #include "dvlist.h" | 
|---|
| [224] | 10 | #include "ntuple.h" | 
|---|
| [2686] | 11 | #include "datatable.h" | 
|---|
| [2702] | 12 | #include "swppfdtable.h" | 
|---|
| [224] | 13 |  | 
|---|
| [3906] | 14 | /* --- Programme de test des classes  DVList, NTuple, | 
|---|
|  | 15 | DataTable et les handlers PPF | 
|---|
|  | 16 |  | 
|---|
|  | 17 | --- This code is part of the SOPHYA library --- | 
|---|
|  | 18 | (C) Univ. Paris-Sud   (C) LAL-IN2P3/CNRS   (C) IRFU-CEA | 
|---|
|  | 19 | (C) R. Ansari, C.Magneville    2000 - 2010 | 
|---|
| [2686] | 20 |  | 
|---|
| [3906] | 21 | Appel: | 
|---|
|  | 22 | #  Verification de DVList | 
|---|
|  | 23 | csh> tnt d | 
|---|
|  | 24 | #  Verification de NTuple | 
|---|
|  | 25 | csh> tnt n | 
|---|
|  | 26 | #  Verification de DataTable | 
|---|
|  | 27 | csh> tnt DT | 
|---|
|  | 28 | #  Verification de SwPPFDataTable | 
|---|
|  | 29 | csh> tnt SWDT | 
|---|
|  | 30 | ----------------------------------------------------------   */ | 
|---|
|  | 31 |  | 
|---|
| [720] | 32 | void test_dvl(); | 
|---|
|  | 33 | void test_ntuple(); | 
|---|
| [2686] | 34 | void test_DataTable() ; | 
|---|
| [2702] | 35 | void test_SwPPFDataTable() ; | 
|---|
| [720] | 36 |  | 
|---|
|  | 37 | int main(int narg, char *arg[]) | 
|---|
| [224] | 38 | { | 
|---|
| [768] | 39 | SophyaInit(); | 
|---|
| [720] | 40 | if (narg < 2) { | 
|---|
| [3572] | 41 | cout << " tnt/Erreur arg - Usage: tnt d/n/DT/SWDT \n" | 
|---|
|  | 42 | << " d:DVList n:NTuple DT,SWDT: SwPPF/DataTable test \n" << endl; | 
|---|
| [720] | 43 | exit(0); | 
|---|
|  | 44 | } | 
|---|
| [2832] | 45 | int rc = 0; | 
|---|
| [720] | 46 | try { | 
|---|
|  | 47 | if (*arg[1] == 'd')  test_dvl(); | 
|---|
|  | 48 | else if (*arg[1] == 'n')  test_ntuple(); | 
|---|
| [2702] | 49 | else if (strcmp(arg[1],"DT") == 0)  test_DataTable(); | 
|---|
|  | 50 | else if (strcmp(arg[1],"SWDT") == 0)  test_SwPPFDataTable(); | 
|---|
| [720] | 51 | } | 
|---|
|  | 52 | catch(PThrowable exc ) { | 
|---|
|  | 53 | cerr << "tnt-main() , Catched exception: \n" << exc.Msg() << endl; | 
|---|
| [2832] | 54 | rc = 97; | 
|---|
| [720] | 55 | } | 
|---|
|  | 56 | catch(std::exception ex) { | 
|---|
|  | 57 | cerr << "tnt-main() , Catched exception ! " << (string)(ex.what()) << endl; | 
|---|
| [2832] | 58 | rc = 98; | 
|---|
| [720] | 59 | } | 
|---|
|  | 60 | catch(...) { | 
|---|
|  | 61 | cerr << "tnt-main() , Catched ... ! " << endl; | 
|---|
| [2832] | 62 | rc = 99; | 
|---|
| [720] | 63 | } | 
|---|
| [2832] | 64 | return rc; | 
|---|
| [720] | 65 | } | 
|---|
| [224] | 66 |  | 
|---|
| [720] | 67 | /*  ***** Test de NTuple simple ***** */ | 
|---|
|  | 68 | void test_ntuple() | 
|---|
|  | 69 | { | 
|---|
| [3572] | 70 | const char * names[3] = {"XPos", "YPos", "Val"}; | 
|---|
| [720] | 71 | int i,j, k; | 
|---|
|  | 72 | float xnt[3]; | 
|---|
| [224] | 73 |  | 
|---|
| [720] | 74 | cout << "======= test_ntuple:  Testing NTuple ======= " << endl; | 
|---|
| [224] | 75 |  | 
|---|
| [720] | 76 | cout << "Creation Ntuple avec X,Y,Val ... " << endl; | 
|---|
|  | 77 | NTuple  nt1(3, names, 20); | 
|---|
| [224] | 78 |  | 
|---|
| [720] | 79 | k = 0; | 
|---|
|  | 80 | for(j=0; j<8; j++) | 
|---|
|  | 81 | for(i=0; i<12; i++) | 
|---|
|  | 82 | { xnt[0] = i+0.5;  xnt[1] = j+0.5;  xnt[2] = k; | 
|---|
|  | 83 | nt1.Fill(xnt); k++; } | 
|---|
|  | 84 |  | 
|---|
| [1161] | 85 | nt1.Info().Comment() = "NTuple de Test - Cree par tnt.cc"; | 
|---|
|  | 86 | nt1.Info()["Version"] = SophyaVersion(); | 
|---|
| [720] | 87 | nt1.Show(cout); | 
|---|
|  | 88 | nt1.Print(0, 5); | 
|---|
|  | 89 | nt1.Print(18, 5); | 
|---|
|  | 90 | nt1.Print(94, 5); | 
|---|
|  | 91 |  | 
|---|
|  | 92 | string fn = "nt.ppf"; | 
|---|
|  | 93 | { | 
|---|
|  | 94 | cout << "Ecriture NTuple ds nt.ppf ... \n" << endl; | 
|---|
|  | 95 | ObjFileIO<NTuple> fio(&nt1); | 
|---|
|  | 96 | fio.Write(fn); | 
|---|
|  | 97 | } | 
|---|
|  | 98 |  | 
|---|
|  | 99 | { | 
|---|
|  | 100 | cout << "Lecture NTuple (nt2) ds nt.ppf ... \n" << endl; | 
|---|
| [2702] | 101 | PInPersist fsi(fn); | 
|---|
|  | 102 | NTuple nt2; | 
|---|
|  | 103 | fsi >> nt2; | 
|---|
|  | 104 | nt2.Show(cout); | 
|---|
|  | 105 | nt2.Print(0, 5); | 
|---|
|  | 106 | nt2.Print(18, 5); | 
|---|
|  | 107 | nt2.Print(94, 5); | 
|---|
| [720] | 108 | } | 
|---|
|  | 109 |  | 
|---|
|  | 110 |  | 
|---|
|  | 111 | } | 
|---|
|  | 112 |  | 
|---|
|  | 113 | /*  ***** Test de dvlist ***** */ | 
|---|
|  | 114 | void test_dvl() | 
|---|
| [583] | 115 | { | 
|---|
| [720] | 116 | DVList dvl; | 
|---|
|  | 117 |  | 
|---|
| [1161] | 118 | cout << "\n ======= test_dvl:  Testing MuTyV ======= " << endl; | 
|---|
|  | 119 | MuTyV zvs = " ( 1.41 -2.71) "; | 
|---|
|  | 120 | MuTyV dvs = "434.898"; | 
|---|
|  | 121 | MuTyV fvu = 314.1596; | 
|---|
|  | 122 | MuTyV ivu = 7654321; | 
|---|
|  | 123 | cout << " float->string: fvu= " << fvu << " (string)fvu=" << (string)fvu << endl; | 
|---|
|  | 124 | cout << " int->string: ivu= " << ivu << " (string)ivu=" << (string)ivu << endl; | 
|---|
| [1343] | 125 | complex<double> zzd = zvs; | 
|---|
| [1161] | 126 | cout << "String->complex<double>: zvs = " << zvs | 
|---|
| [1343] | 127 | << " (complex<double>)zvs= " << zzd << endl; | 
|---|
| [1161] | 128 | cout << "String->double: dvs = " << dvs | 
|---|
| [2828] | 129 | << " (double)dvs= " << (double)dvs << endl; | 
|---|
|  | 130 | TimeStamp ts; | 
|---|
|  | 131 | MuTyV tv = ts; | 
|---|
|  | 132 | cout << "MuTyV=TimeStamp->String: tv = " << tv | 
|---|
|  | 133 | << " ->double= " << (double)tv << " ->TimeStamp:" | 
|---|
|  | 134 | << TimeStamp((double)tv).ToString() << endl; | 
|---|
| [2832] | 135 | tv = "1995-09-23T15:20:32"; | 
|---|
|  | 136 | string tts = (string)tv; | 
|---|
|  | 137 | cout << "MuTyV=TimeStamp tv=" << tv << " ->TimeStamp(tv)=" | 
|---|
|  | 138 | << TimeStamp(tts) << endl; | 
|---|
| [1161] | 139 |  | 
|---|
|  | 140 | cout << "\n\n ======= test_dvl:  Testing DVList ======= " << endl; | 
|---|
| [720] | 141 | dvl.SetI("Var XXX", 12345); | 
|---|
|  | 142 | dvl.SetI("IV1-80", 80); | 
|---|
|  | 143 | dvl.SetI("IV2-330", 330); | 
|---|
|  | 144 |  | 
|---|
|  | 145 | dvl.SetD("DV1-0.2", 0.2); | 
|---|
|  | 146 | dvl.SetD("DV2-4.5", 4.5); | 
|---|
| [1082] | 147 | dvl.SetZ("ZV", complex<r_8>(2.0,-1.44)); | 
|---|
| [720] | 148 |  | 
|---|
|  | 149 | dvl.SetI("IVV3-783", 783); | 
|---|
|  | 150 | dvl("IVV3-783-O") =  7783; | 
|---|
|  | 151 | // dvl["Avec[]"] =  "operateur [] !"; | 
|---|
|  | 152 | dvl.SetD("DVV3", 3.141592652141592652); | 
|---|
|  | 153 | dvl.SetComment("DVV3", "Comment for DVV3, r_8 type variable"); | 
|---|
|  | 154 | dvl("DVV3avec()") =  44.555e-8; | 
|---|
|  | 155 |  | 
|---|
|  | 156 | dvl.SetS("Blanc_White", "123.456Ma premiere chaine"); | 
|---|
|  | 157 | dvl.SetI("IntegerValue", 55777); | 
|---|
|  | 158 | dvl.SetComment("IntegerValue", "This variable has a comment"); | 
|---|
|  | 159 | dvl.Comment() = "This is a test DVL produced by the program tdvl.cc \n Using SOPHYA , Feb 2000"; | 
|---|
| [1161] | 160 |  | 
|---|
|  | 161 | dvl["Sinf"] = "inf 0985"; | 
|---|
| [2828] | 162 | dvl["ToDay"] = ts; | 
|---|
| [720] | 163 | dvl.Print(); | 
|---|
|  | 164 |  | 
|---|
| [1161] | 165 |  | 
|---|
| [720] | 166 | double d = dvl("DV2-4.5"); | 
|---|
|  | 167 | float f = dvl("DVV3"); | 
|---|
|  | 168 | int i = dvl("IVV3-783"); | 
|---|
| [1082] | 169 | complex<r_8> z = dvl("ZV"); | 
|---|
| [720] | 170 |  | 
|---|
|  | 171 | printf("\n \n Essai1 (IVV3 DVV3 DV2= ) %d  %.20g  %g \n", i, f, (float)d); | 
|---|
| [1082] | 172 | printf("\n \n Essai ZV= (%.2g  %g I) \n", z.real(), z.imag()); | 
|---|
| [720] | 173 | cout << "Test Comment/IntegerValue: " << dvl.GetComment("IntegerValue") << endl; | 
|---|
|  | 174 | cout << "Test Comment/DVV3: " << dvl.GetComment("DVV3") << endl; | 
|---|
|  | 175 |  | 
|---|
|  | 176 | cout << "Test string recup  " << (string)(dvl["Blanc_White"]) << endl; | 
|---|
|  | 177 | cout << "Test string recup(int=80)  " << (string)(dvl["IV1-80"]) << endl; | 
|---|
|  | 178 | dvl("DVV3") = (double)3.141592652141592652; | 
|---|
|  | 179 | cout << "Test string recup(double=Pi..i)  " << (string)(dvl["DVV3"]) << endl; | 
|---|
|  | 180 |  | 
|---|
|  | 181 | { | 
|---|
|  | 182 | cout << " Writing DVList in file PPF dvl.ppf " << endl; | 
|---|
|  | 183 | POutPersist os("dvl.ppf"); | 
|---|
|  | 184 | os << dvl ; | 
|---|
|  | 185 | } | 
|---|
|  | 186 |  | 
|---|
|  | 187 | cout << "-------------------------- \n\n" | 
|---|
|  | 188 | << " reading DVList from file dvl.ppf ... \n" << endl; | 
|---|
|  | 189 |  | 
|---|
|  | 190 | DVList dvlr("dvl.ppf"); | 
|---|
|  | 191 | double df1 = (double)( dvlr["DVV3"] ); | 
|---|
|  | 192 | double df2 = (double)3.141592652141592652 - df1; | 
|---|
| [1082] | 193 | cout << " Test Precision : Pi-Pi= " << df2  << "DVV3= " << df1 << endl; | 
|---|
| [720] | 194 |  | 
|---|
|  | 195 | cout << dvlr; | 
|---|
|  | 196 |  | 
|---|
| [583] | 197 | } | 
|---|
| [2686] | 198 | void test_DataTable() | 
|---|
|  | 199 | { | 
|---|
|  | 200 | cout << "======= test_DataTable:  simple DataTable test ======= " << endl; | 
|---|
|  | 201 | DataTable dt(64); | 
|---|
|  | 202 | dt.AddIntegerColumn("line"); | 
|---|
| [2733] | 203 | dt.AddStringColumn("sline"); | 
|---|
| [2686] | 204 | dt.AddDoubleColumn("x"); | 
|---|
|  | 205 | dt.AddFloatColumn("f_sin"); | 
|---|
|  | 206 | dt.AddFloatColumn("f_cos"); | 
|---|
|  | 207 | dt.AddDoubleColumn("f_sinxcos"); | 
|---|
|  | 208 | dt.AddDoubleColumn("f_x2"); | 
|---|
| [2828] | 209 | dt.AddComplexColumn("cmplx_cos_sin"); | 
|---|
|  | 210 | dt.AddDoubleComplexColumn("dcmplx_cos_sin"); | 
|---|
| [2832] | 211 | dt.AddDateTimeColumn("datime"); | 
|---|
| [2686] | 212 | MuTyV rec[10]; | 
|---|
| [2832] | 213 | TimeStamp ts("01/3/2005","0:0:0"); | 
|---|
|  | 214 | TimeStamp ts2(0.); | 
|---|
|  | 215 |  | 
|---|
| [2686] | 216 | cout << " 1/ First 1000 lines .... " << endl; | 
|---|
|  | 217 | for(int k = 0; k<1000; k++) { | 
|---|
|  | 218 | rec[0] = k; | 
|---|
| [2733] | 219 | string sline = "L-"; | 
|---|
|  | 220 | sline += (string)rec[0]; | 
|---|
|  | 221 | rec[1] = sline; | 
|---|
| [2686] | 222 | double x = M_PI*k/100.; | 
|---|
|  | 223 | double fx = sin(x)*cos(x); | 
|---|
| [2828] | 224 | double sx = sin(x); | 
|---|
|  | 225 | double cx = cos(x); | 
|---|
| [2733] | 226 | rec[2] = x; | 
|---|
| [2828] | 227 | rec[3] = sx; | 
|---|
|  | 228 | rec[4] = cx; | 
|---|
| [2733] | 229 | rec[5] = fx; | 
|---|
|  | 230 | rec[6] = x*x; | 
|---|
| [2828] | 231 | rec[7] = complex<r_4>(cx, sx); | 
|---|
|  | 232 | rec[8] = complex<r_8>(cx, sx); | 
|---|
| [2832] | 233 | ts2.Set(ts.ToDays()+(double)k/24.); | 
|---|
|  | 234 | rec[9] = ts2; | 
|---|
| [2686] | 235 | dt.AddLine(rec); | 
|---|
|  | 236 | } | 
|---|
|  | 237 | cout << "1.b/ Use of = operator to make copy of dt " << endl; | 
|---|
|  | 238 | DataTable dtc1; | 
|---|
|  | 239 | dtc1 = dt; | 
|---|
| [224] | 240 |  | 
|---|
| [2686] | 241 | dt.Show(); | 
|---|
|  | 242 | cout << " 2/ Lines 1000-2000  .... " << endl; | 
|---|
|  | 243 | for(int k = 1000; k<2000; k++) { | 
|---|
|  | 244 | rec[0] = k; | 
|---|
| [2733] | 245 | string sline = "L-"; | 
|---|
|  | 246 | sline += (string)rec[0]; | 
|---|
|  | 247 | rec[1] = sline; | 
|---|
| [2686] | 248 | double x = M_PI*k/100.; | 
|---|
|  | 249 | double fx = sin(x)*cos(x); | 
|---|
| [2828] | 250 | double sx = sin(x); | 
|---|
|  | 251 | double cx = cos(x); | 
|---|
| [2733] | 252 | rec[2] = x; | 
|---|
| [2828] | 253 | rec[3] = sx; | 
|---|
|  | 254 | rec[4] = cx; | 
|---|
| [2733] | 255 | rec[5] = fx; | 
|---|
|  | 256 | rec[6] = x*x; | 
|---|
| [2828] | 257 | rec[7] = complex<r_4>(cx, sx); | 
|---|
|  | 258 | rec[8] = complex<r_8>(cx, sx); | 
|---|
| [2832] | 259 | ts2.Set(ts.ToDays()+(double)k/24.); | 
|---|
|  | 260 | rec[9] = ts2; | 
|---|
| [2686] | 261 | dt.AddLine(rec); | 
|---|
|  | 262 | } | 
|---|
|  | 263 | cout << "2.b/ dt.Show();  : " << endl; | 
|---|
|  | 264 | dt.Show(); | 
|---|
|  | 265 | cout << "2.c/ dtc1.Show();  : " << endl; | 
|---|
|  | 266 | dtc1.Show(); | 
|---|
|  | 267 | cout << "2.d/  dt.LineHeaderToString() dt.LineToString(k)   : " << endl; | 
|---|
| [2832] | 268 | cout << dt.LineHeaderToString() << endl; | 
|---|
| [2686] | 269 | for(int k = 0; k<1500; k+=75) | 
|---|
|  | 270 | cout << "Line[" << k << "] " << dt.LineToString(k) << endl ; | 
|---|
|  | 271 | { | 
|---|
|  | 272 | cout << "3/ Writing DataTable dt to PPF stream dtable.ppf " << endl; | 
|---|
|  | 273 | POutPersist po("dtable.ppf"); | 
|---|
|  | 274 | po << dt; | 
|---|
|  | 275 | } | 
|---|
|  | 276 | { | 
|---|
|  | 277 | cout << "4/ Reading DataTable dtr from PPF stream dtable.ppf " << endl; | 
|---|
|  | 278 | PInPersist pi("dtable.ppf"); | 
|---|
|  | 279 | DataTable dtr; | 
|---|
|  | 280 | pi >> dtr; | 
|---|
|  | 281 | cout << "4.b/ cout << dtr; " << endl; | 
|---|
|  | 282 | cout << dtr; | 
|---|
|  | 283 | cout << "4.c/  dtr.LineHeaderToString() dtr.LineToString(k)   : " << endl; | 
|---|
| [2832] | 284 | cout << dtr.LineHeaderToString() << endl; | 
|---|
| [2686] | 285 | for(int k = 0; k<1500; k+=75) | 
|---|
|  | 286 | cout << "Line[" << k << "] " << dtr.LineToString(k) << endl ; | 
|---|
|  | 287 |  | 
|---|
|  | 288 | } | 
|---|
| [2832] | 289 | { | 
|---|
|  | 290 | cout << "5/ Reading DataTable dtr from text file dtable.txt " << endl; | 
|---|
|  | 291 | { | 
|---|
|  | 292 | cout << "5.a Writing lines to file dtable.txt " << endl; | 
|---|
|  | 293 | ofstream os("dtable.txt"); | 
|---|
|  | 294 | dt.Print(os,0,450); | 
|---|
|  | 295 | } | 
|---|
|  | 296 | cout << "5.b CopyStructure + FillFromASCIIFile from dtable.txt " << endl; | 
|---|
|  | 297 | ifstream is("dtable.txt"); | 
|---|
|  | 298 | DataTable dtr; | 
|---|
|  | 299 | dtr.CopyStructure(dt); | 
|---|
|  | 300 | dtr.FillFromASCIIFile(is); | 
|---|
|  | 301 | cout << dtr; | 
|---|
|  | 302 | cout << "5.c/  dtr.LineHeaderToString() dtr.LineToString(k)   : " << endl; | 
|---|
|  | 303 | cout << dtr.LineHeaderToString() << endl; | 
|---|
|  | 304 | for(int k = 0; k<10; k++) | 
|---|
|  | 305 | cout << "Line[" << k << "] " << dtr.LineToString(k) << endl ; | 
|---|
|  | 306 | for(int k = 50; k<300; k+=25) | 
|---|
|  | 307 | cout << "Line[" << k << "] " << dtr.LineToString(k) << endl ; | 
|---|
|  | 308 |  | 
|---|
|  | 309 | } | 
|---|
| [2848] | 310 | cout << "6./Test with DataTableRow object " << endl; | 
|---|
|  | 311 | DataTable dtrow(64); | 
|---|
|  | 312 | dtrow.AddDoubleColumn("x"); | 
|---|
|  | 313 | dtrow.AddFloatColumn("f_cos"); | 
|---|
|  | 314 | dtrow.AddStringColumn("sline"); | 
|---|
|  | 315 | dtrow.AddIntegerColumn("line"); | 
|---|
| [2852] | 316 | dtrow.AddDateTimeColumn("datime"); | 
|---|
| [2686] | 317 |  | 
|---|
| [2848] | 318 | DataTableRow row = dtrow.EmptyRow(); | 
|---|
|  | 319 | for(int k = 0; k<25; k++) { | 
|---|
|  | 320 | MuTyV mtk = k; | 
|---|
|  | 321 | string sline = "L-"; | 
|---|
|  | 322 | sline += (string)mtk; | 
|---|
|  | 323 | row["sline"] = sline; | 
|---|
|  | 324 | row["line"] = k; | 
|---|
|  | 325 | double x = M_PI*k/25.; | 
|---|
|  | 326 | double cx = cos(x); | 
|---|
|  | 327 | row[0] = x; | 
|---|
|  | 328 | row[1] = cx; | 
|---|
| [2852] | 329 | ts2.Set(ts.ToDays()+(double)k); | 
|---|
|  | 330 | row["datime"] = ts2; | 
|---|
| [2848] | 331 | dtrow.AddRow(row); | 
|---|
|  | 332 | } | 
|---|
|  | 333 | cout << dtrow << endl; | 
|---|
|  | 334 | cout << dtrow.LineHeaderToString() << endl; | 
|---|
|  | 335 | for(int k = 0; k<25; k+=3) { | 
|---|
|  | 336 | dtrow.GetRow(k, row); | 
|---|
|  | 337 | cout << "k=" << k << " GetRow():   " << row << endl; | 
|---|
|  | 338 | cout << " ...LineToString(): " << dtrow.LineToString(k) << endl; | 
|---|
|  | 339 | } | 
|---|
|  | 340 | cout << endl; | 
|---|
| [2686] | 341 | cout << "============ FIN  test_DataTable ============== " << endl; | 
|---|
|  | 342 | } | 
|---|
|  | 343 |  | 
|---|
| [2702] | 344 | void test_SwPPFDataTable() | 
|---|
|  | 345 | { | 
|---|
|  | 346 | cout << "======= test_SwPPFDataTable():  simple SwPPFDataTable test ======= " << endl; | 
|---|
|  | 347 | { | 
|---|
|  | 348 | POutPersist po("swdtable.ppf"); | 
|---|
|  | 349 | SwPPFDataTable dt(po, 64); | 
|---|
|  | 350 | dt.AddIntegerColumn("line"); | 
|---|
| [2832] | 351 | dt.AddStringColumn("sline"); | 
|---|
| [2702] | 352 | dt.AddDoubleColumn("x"); | 
|---|
|  | 353 | dt.AddFloatColumn("f_sin"); | 
|---|
|  | 354 | dt.AddFloatColumn("f_cos"); | 
|---|
|  | 355 | dt.AddDoubleColumn("f_sinxcos"); | 
|---|
|  | 356 | dt.AddDoubleColumn("f_x2"); | 
|---|
| [2828] | 357 | dt.AddComplexColumn("cmplx_cos_sin"); | 
|---|
|  | 358 | dt.AddDoubleComplexColumn("dcmplx_cos_sin"); | 
|---|
| [2832] | 359 | dt.AddDateTimeColumn("datime"); | 
|---|
| [2702] | 360 | MuTyV rec[10]; | 
|---|
| [2832] | 361 | TimeStamp ts("01/3/2005","0:0:0"); | 
|---|
|  | 362 | TimeStamp ts2(0.); | 
|---|
| [2702] | 363 | cout << " 1/ First 1000 lines .... " << endl; | 
|---|
|  | 364 | for(int k = 0; k<1000; k++) { | 
|---|
|  | 365 | rec[0] = k; | 
|---|
| [2832] | 366 | string sline = "L-"; | 
|---|
|  | 367 | sline += (string)rec[0]; | 
|---|
|  | 368 | rec[1] = sline; | 
|---|
| [2702] | 369 | double x = M_PI*k/100.; | 
|---|
|  | 370 | double fx = sin(x)*cos(x); | 
|---|
| [2828] | 371 | double sx = sin(x); | 
|---|
|  | 372 | double cx = cos(x); | 
|---|
| [2832] | 373 | rec[2] = x; | 
|---|
|  | 374 | rec[3] = sx; | 
|---|
|  | 375 | rec[4] = cx; | 
|---|
|  | 376 | rec[5] = fx; | 
|---|
|  | 377 | rec[6] = x*x; | 
|---|
|  | 378 | rec[7] = complex<r_4>(cx, sx); | 
|---|
|  | 379 | rec[8] = complex<r_8>(cx, sx); | 
|---|
|  | 380 | ts2.Set(ts.ToDays()+(double)k/24.); | 
|---|
|  | 381 | rec[9] = ts2; | 
|---|
| [2702] | 382 | dt.AddLine(rec); | 
|---|
|  | 383 | } | 
|---|
|  | 384 | cout << "1.b/ Use of = operator to make copy of dt " << endl; | 
|---|
|  | 385 | SwPPFDataTable dtc1; | 
|---|
|  | 386 | dtc1 = dt; | 
|---|
|  | 387 | dt.Show(); | 
|---|
|  | 388 | cout << " 2/ Lines 1000-2000  .... " << endl; | 
|---|
|  | 389 | for(int k = 1000; k<2000; k++) { | 
|---|
|  | 390 | rec[0] = k; | 
|---|
| [2832] | 391 | string sline = "L-"; | 
|---|
|  | 392 | sline += (string)rec[0]; | 
|---|
|  | 393 | rec[1] = sline; | 
|---|
| [2702] | 394 | double x = M_PI*k/100.; | 
|---|
|  | 395 | double fx = sin(x)*cos(x); | 
|---|
| [2832] | 396 | double sx = sin(x); | 
|---|
|  | 397 | double cx = cos(x); | 
|---|
|  | 398 | rec[2] = x; | 
|---|
|  | 399 | rec[3] = sx; | 
|---|
|  | 400 | rec[4] = cx; | 
|---|
|  | 401 | rec[5] = fx; | 
|---|
|  | 402 | rec[6] = x*x; | 
|---|
|  | 403 | rec[7] = complex<r_4>(cx, sx); | 
|---|
|  | 404 | rec[8] = complex<r_8>(cx, sx); | 
|---|
|  | 405 | ts2.Set(ts.ToDays()+(double)k/24.); | 
|---|
|  | 406 | rec[9] = ts2; | 
|---|
| [2702] | 407 | dt.AddLine(rec); | 
|---|
|  | 408 | } | 
|---|
|  | 409 | cout << "2.b/ dt.Show();  : " << endl; | 
|---|
|  | 410 | dt.Show(); | 
|---|
|  | 411 | cout << "2.c/ dtc1.Show();  : " << endl; | 
|---|
|  | 412 | dtc1.Show(); | 
|---|
|  | 413 | cout << "3/ Writing SwPPFDataTable dt to PPF stream swdtable.ppf " << endl; | 
|---|
|  | 414 | po << dt; | 
|---|
|  | 415 | } | 
|---|
|  | 416 | { | 
|---|
|  | 417 | cout << "4/ Reading SwPPFDataTable dtr from PPF stream swdtable.ppf " << endl; | 
|---|
|  | 418 | PInPersist pi("swdtable.ppf"); | 
|---|
|  | 419 | SwPPFDataTable dtr; | 
|---|
|  | 420 | pi >> dtr; | 
|---|
|  | 421 | cout << "4.b/ cout << dtr; " << endl; | 
|---|
|  | 422 | cout << dtr; | 
|---|
|  | 423 | cout << "4.c/  dtr.LineHeaderToString() dtr.LineToString(k)   : " << endl; | 
|---|
| [2832] | 424 | cout << dtr.LineHeaderToString() << endl; | 
|---|
| [2702] | 425 | for(int k = 0; k<1500; k+=75) | 
|---|
|  | 426 | cout << "Line[" << k << "] " << dtr.LineToString(k) << endl ; | 
|---|
|  | 427 | } | 
|---|
|  | 428 |  | 
|---|
|  | 429 | cout << "============ FIN  test_SwPPFDataTable() ======== ======= " << endl; | 
|---|
|  | 430 | } | 
|---|
|  | 431 |  | 
|---|
|  | 432 |  | 
|---|
|  | 433 |  | 
|---|
|  | 434 |  | 
|---|