Revision 254, 1.6 kB
(checked in by smidl, 16 years ago)
|
create namespace bdm
|
Rev | Line | |
---|
[1] | 1 | #include <itpp/itbase.h> |
---|
[15] | 2 | #include "../bdm/stat/libBM.h" |
---|
| 3 | #include "../bdm/math/libDC.h" |
---|
[37] | 4 | #include "../bdm/math/chmat.h" |
---|
[1] | 5 | |
---|
[170] | 6 | #include <vector> |
---|
[254] | 7 | using namespace bdm; |
---|
[1] | 8 | |
---|
| 9 | //These lines are needed for use of cout and endl |
---|
| 10 | using std::cout; |
---|
| 11 | using std::endl; |
---|
| 12 | |
---|
| 13 | int main() |
---|
| 14 | { |
---|
[162] | 15 | RV th = RV ( "{a b }"); |
---|
| 16 | RV r = RV ( "{r1 r2 }" ); |
---|
[1] | 17 | |
---|
[7] | 18 | cout << th << r << endl; |
---|
[1] | 19 | |
---|
[162] | 20 | ldmat ld = ldmat("1 0 0 0; 0.2 1 0 0; 0.1 -0.1 1 0; -0.9 0.3 -0.1 1", |
---|
| 21 | "3 4 5 6"); |
---|
| 22 | vec v = "1 -1 3 -1"; |
---|
[211] | 23 | |
---|
[7] | 24 | cout << "Test to_mat"<<endl; |
---|
| 25 | // cout << ld << endl; |
---|
[162] | 26 | mat L = ld.to_mat(); |
---|
| 27 | cout << L <<endl; |
---|
[7] | 28 | |
---|
| 29 | cout << "Test opupdt" <<endl; |
---|
[162] | 30 | cout << "w=1" <<endl; |
---|
[7] | 31 | ldmat ldup = ld; |
---|
| 32 | ldup.opupdt(v,1); |
---|
| 33 | cout << ldup.to_mat()<<endl; |
---|
[162] | 34 | cout << L + outer_product(v,v) <<endl; |
---|
| 35 | ldup = ld; |
---|
| 36 | cout << "w=0.1" <<endl; |
---|
| 37 | ldup.opupdt(v,0.1); |
---|
| 38 | cout << ldup.to_mat()<<endl; |
---|
| 39 | cout << L + 0.1*outer_product(v,v) <<endl; |
---|
[7] | 40 | |
---|
| 41 | cout << "Test +="<<endl; |
---|
| 42 | ldmat ld2x = ld; |
---|
| 43 | ld2x+=ld; |
---|
[162] | 44 | cout << ld.to_mat() <<endl << ld2x.to_mat() <<endl; |
---|
[7] | 45 | |
---|
[162] | 46 | cout << "Test *="<<endl; |
---|
| 47 | ld2x = ld; |
---|
| 48 | ld2x*=2; |
---|
| 49 | cout << ld.to_mat() <<endl << ld2x.to_mat() <<endl; |
---|
| 50 | |
---|
[7] | 51 | cout << "Test ldinv()"<<endl; |
---|
| 52 | ldmat Il = ld; |
---|
| 53 | ld.inv(Il); // |
---|
| 54 | mat I = Il.to_mat()*ld.to_mat(); |
---|
[101] | 55 | cout << "ld:" << endl << Il.to_mat() << "eye:" << endl<< I <<endl; |
---|
| 56 | getchar(); |
---|
[7] | 57 | |
---|
[18] | 58 | cout << "Test ldform()"<<endl; |
---|
[28] | 59 | mat V = "1 2; 2 13"; |
---|
[18] | 60 | ldmat lV(V); |
---|
[24] | 61 | ldmat ilV(V); |
---|
| 62 | lV.inv(ilV); |
---|
| 63 | cout << "ld:" << lV << "eye:"<< V*(ilV.to_mat()) <<endl; |
---|
[7] | 64 | |
---|
[37] | 65 | cout << "Test logdet()"<<endl; |
---|
| 66 | chmat chV(V); |
---|
| 67 | cout << "ch:" << chV.to_mat() <<endl; |
---|
| 68 | cout << "log(det(V)):"<< chV.logdet() <<endl; |
---|
| 69 | cout << "qform : " << chV.qform(ones(2)) <<endl; |
---|
| 70 | |
---|
[18] | 71 | |
---|
[5] | 72 | //Exit program: |
---|
[35] | 73 | getchar(); |
---|
[5] | 74 | return 0; |
---|
[1] | 75 | |
---|
| 76 | } |
---|