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