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