Changeset 545
- Timestamp:
- 08/18/09 09:38:41 (15 years ago)
- Location:
- library
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r532 r545 189 189 } 190 190 191 void datalink::set_connection (const RV &rv, const RV &rv_up) { 192 downsize = rv._dsize(); 193 upsize = rv_up._dsize(); 194 v2v_up = rv.dataind (rv_up); 195 196 it_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 197 } 198 199 void datalink::set_connection (int ds, int us, const ivec &upind) { 200 downsize = ds; 201 upsize = us; 202 v2v_up = upind; 203 204 it_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 205 } 206 207 void datalink_m2e::set_connection (const RV &rv, const RV &rvc, const RV &rv_up) { 208 datalink::set_connection (rv, rv_up); 209 condsize = rvc._dsize(); 210 //establish v2c connection 211 rvc.dataind (rv_up, v2c_lo, v2c_up); 212 } 213 214 vec datalink_m2e::get_cond (const vec &val_up) { 215 vec tmp (condsize); 216 set_subvector (tmp, v2c_lo, val_up (v2c_up)); 217 return tmp; 218 } 219 220 void datalink_m2e::pushup_cond (vec &val_up, const vec &val, const vec &cond) { 221 it_assert_debug (downsize == val.length(), "Wrong val"); 222 it_assert_debug (upsize == val_up.length(), "Wrong val_up"); 223 set_subvector (val_up, v2v_up, val); 224 set_subvector (val_up, v2c_up, cond); 225 } 226 191 227 std::ostream &operator<< ( std::ostream &os, const RV &rv ) { 192 228 int id; -
library/bdm/base/bdmbase.h
r536 r545 557 557 //! Constructor 558 558 datalink() : downsize (0), upsize (0) { } 559 //! Conevnience constructor 559 560 //! Convenience constructor 560 561 datalink (const RV &rv, const RV &rv_up) { 561 562 set_connection (rv, rv_up); … … 563 564 564 565 //! set connection, rv must be fully present in rv_up 565 void set_connection (const RV &rv, const RV &rv_up) { 566 downsize = rv._dsize(); 567 upsize = rv_up._dsize(); 568 v2v_up = rv.dataind (rv_up); 569 570 it_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 571 } 566 void set_connection (const RV &rv, const RV &rv_up); 572 567 573 568 //! set connection using indices 574 void set_connection (int ds, int us, const ivec &upind) { 575 downsize = ds; 576 upsize = us; 577 v2v_up = upind; 578 579 it_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 580 } 569 void set_connection (int ds, int us, const ivec &upind); 581 570 582 571 //! Get val for myself from val of "Up" … … 610 599 //! Constructor 611 600 datalink_m2e() : condsize (0) { } 601 612 602 //! Set connection between vectors 613 void set_connection (const RV &rv, const RV &rvc, const RV &rv_up) { 614 datalink::set_connection (rv, rv_up); 615 condsize = rvc._dsize(); 616 //establish v2c connection 617 rvc.dataind (rv_up, v2c_lo, v2c_up); 618 } 603 void set_connection (const RV &rv, const RV &rvc, const RV &rv_up); 619 604 620 605 //!Construct condition 621 vec get_cond (const vec &val_up) { 622 vec tmp (condsize); 623 set_subvector (tmp, v2c_lo, val_up (v2c_up)); 624 return tmp; 625 } 606 vec get_cond (const vec &val_up); 607 626 608 //! Copy corresponding values to Up.condition 627 void pushup_cond (vec &val_up, const vec &val, const vec &cond) { 628 it_assert_debug (downsize == val.length(), "Wrong val"); 629 it_assert_debug (upsize == val_up.length(), "Wrong val_up"); 630 set_subvector (val_up, v2v_up, val); 631 set_subvector (val_up, v2c_up, cond); 632 } 609 void pushup_cond (vec &val_up, const vec &val, const vec &cond); 633 610 }; 634 611 -
library/tests/datalink_test.cpp
r493 r545 1 1 #include "../bdm/stat/exp_family.h" 2 #include "mat_checks.h" 2 3 #include "UnitTest++.h" 3 4 … … 26 27 CHECK_EQUAL ( exp_f[i], filtered ( i ) ); 27 28 } 29 30 datalink unnamed; 31 unnamed.set_connection ( 1, 2, ivec ( "0" ) ); 32 filtered = unnamed.pushdown ( vec ( "37 42" ) ); 33 CHECK_EQUAL ( vec ( "37" ), filtered ); 28 34 } 29 35 … … 48 54 CHECK_EQUAL ( 1, cond.size() ); 49 55 CHECK_EQUAL ( 66, cond ( 0 ) ); 56 57 vec big ( 4 ); 58 dl.pushup_cond ( big, vec ( "2 3 5" ), vec ( "7" ) ); 59 CHECK_EQUAL ( vec ( "2 3 5 7" ), big ); 50 60 } 51 61