Changeset 2586 in Sophya for trunk/SophyaProg
- Timestamp:
- Jul 30, 2004, 3:29:35 PM (21 years ago)
- Location:
- trunk/SophyaProg/Tests
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/carrt.cc
r2582 r2586 290 290 else cout << "(13) OK Test (3*A).DivElt(B+2,C) OK " << endl; 291 291 292 a = 3; 293 b = 2; 294 int_4 sc = a.ScalarProduct(b); 295 if (prtlev > 0) cout << "(14) A=3, B=3, a.ScalarProduct(b)= " << sc << endl; 296 if (sc != nr*nc*6) { 297 cout << "(14) !!! ERROR Test a.ScalarProduct(b) sc " << sc << " !=" << nr*nc*6 << endl; 298 rc += 2048; 299 } 300 else cout << "(14) OK Test a.ScalarProduct(b) OK " << endl; 301 302 TMatrix<int_4> mx(nr, nc), mxc(nr,nc); 303 for(int ir=0; ir<nr; ir++) 304 for(int ic=0; ic<nc; ic++) mxc(ir, ic) = ir*1000+ic*6; 305 if (prtlev > 0) cout << "(15) mx.Row()/Column() operations MXC=" << mxc << endl; 306 307 TVector<int_4> cv(nr), rv(nc, BaseArray::RowVector); 308 cv = RegularSequence(0, 1); 309 rv = RegularSequence(0, 1); 310 for(int ir=0; ir<nr; ir++) { 311 mx.Row(ir) = rv*3; 312 mx.Row(ir) *= 2; 313 } 314 for(int ic=0; ic<nc; ic++) { 315 mx.Column(ic) += cv*1000; 316 } 317 TMatrix<int_4> mxd = mx-mxc; 318 if (prtlev > 0) { 319 cout << "(15) MX=" << mx << endl; 320 cout << "(15) MXD=" << mxd << endl; 321 } 322 getMinMax(mxd, min, max); 323 if ((min != 0) || (max != 0)) { 324 cout << "(15) !!! ERROR Test mx.Row()/Column() operations Min=" << min << " Max=" << max << endl; 325 rc += 8192; 326 } 327 else cout << "(15) OK Test mx.Row()/Column() operations OK " << endl; 328 329 a = RegularSequence(1, 1); 330 b = -a; 331 c = a+b; 332 if (prtlev > 0) { 333 cout << "(16) A = " << a << endl; 334 cout << "(16) B = ((? == -A)" << b << endl; 335 cout << "(16) C = A+B " << c << endl; 336 } 337 getMinMax(c, min, max); 338 if ((min != 0) || (max != 0)) { 339 cout << "(16) !!! ERROR Test B=-A Min=" << min << " Max=" << max << endl; 340 rc += 256; 341 } 342 else cout << "(16) OK Test B=-A OK " << endl; 343 292 344 return(rc); 293 345 } … … 297 349 cout << "\n -----> Testing TMatrix operation TMatrix<r_4>(nr=" << nr << ",nc=" 298 350 << nc << " ) " << endl; 299 cout << " -- --> ODO (Diff. Mem. Mapping) A,CC: CMemoryMapping AR,B,C: FortranMemoryMapping" << endl;351 cout << " --> ODO (Diff. Mem. Mapping) A,CC: CMemoryMapping AR,B,C: FortranMemoryMapping" << endl; 300 352 301 353 int rc = 0; … … 413 465 // Operation de type array +-*/ array 414 466 415 a = 10 ;416 b = 4 ;467 a = 10.; 468 b = 4.; 417 469 418 470 (3.f*a).SubElt(2.f*b,c); … … 490 542 } 491 543 else cout << "(17) OK Test (3*A).DivElt(B+2,CC) OK " << endl; 544 545 a = 3.1; 546 b = -2.2; 547 r_4 sc = a.ScalarProduct(b); 548 r_4 sce = 0.; 549 for(int kkk=0; kkk<nr*nc; kkk++) sce += -2.2*3.1; 550 if (prtlev > 0) cout << "(18) A=3, B=3, a.ScalarProduct(b)= " << sc << endl; 551 sc -= sce; 552 if ((fabs(sc) > 0.00001) || (fabs(sc) > 0.00001)) { 553 cout << "(18) !!! ERROR Test a.ScalarProduct(b) sc-" << sce 554 << " = " << sc << endl; 555 rc += 32768; 556 } 557 else cout << "(18) OK Test a.ScalarProduct(b) OK " << endl; 558 559 TMatrix<r_4> mx(nr, nc), mxc(nr,nc,BaseArray::FortranMemoryMapping); 560 for(int ir=0; ir<nr; ir++) 561 for(int ic=0; ic<nc; ic++) mxc(ir, ic) = ir*1000+ic*6; 562 if (prtlev > 0) cout << "(19) mx.Row()/Column() operations MXC=" << mxc << endl; 563 564 TVector<r_4> cv(nr), rv(nc, BaseArray::RowVector, BaseArray::FortranMemoryMapping); 565 cv = RegularSequence(0, 1); 566 rv = RegularSequence(0, 1); 567 for(int ir=0; ir<nr; ir++) { 568 mx.Row(ir) = rv*3.f; 569 mx.Row(ir) *= 2.f; 570 } 571 for(int ic=0; ic<nc; ic++) { 572 mx.Column(ic) += cv*1000.f; 573 } 574 TMatrix<r_4> mxd = mx-mxc; 575 if (prtlev > 0) { 576 cout << "(19) MX=" << mx << endl; 577 cout << "(19) MXD=" << mxd << endl; 578 } 579 getMinMax(mxd, min, max); 580 if ((fabs(min) > 0.0001) || (fabs(max) > 0.0001)) { 581 cout << "(19) !!! ERROR Test mx.Row()/Column() operations Min=" << min << " Max=" << max << endl; 582 rc += 65536; 583 } 584 else cout << "(19) OK Test mx.Row()/Column() operations OK " << endl; 585 586 a = RegularSequence(3.14, 1.3); 587 b = -a; 588 c = a+b; 589 if (prtlev > 0) { 590 cout << "(20) A = " << a << endl; 591 cout << "(20) B = ((? == -A)" << b << endl; 592 cout << "(16) C = A+B " << c << endl; 593 } 594 getMinMax(c, min, max); 595 if ((fabs(min) > 0.0001) || (fabs(max) > 0.0001)) { 596 cout << "(20) !!! ERROR Test B=-A Min=" << min << " Max=" << max << endl; 597 rc += 131072; 598 } 599 else cout << "(20) OK Test B=-A OK " << endl; 600 492 601 return(rc); 493 602 603 return(rc); 604 494 605 }
Note:
See TracChangeset
for help on using the changeset viewer.