Revision 211, 1.6 kB
(checked in by smidl, 16 years ago)
|
prejmenovani evalpdflog a evalcond
|
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 | #include <vector> |
---|
7 | using namespace itpp; |
---|
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 | { |
---|
15 | RV th = RV ( "{a b }"); |
---|
16 | RV r = RV ( "{r1 r2 }" ); |
---|
17 | |
---|
18 | cout << th << r << endl; |
---|
19 | |
---|
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"; |
---|
23 | |
---|
24 | cout << "Test to_mat"<<endl; |
---|
25 | // cout << ld << endl; |
---|
26 | mat L = ld.to_mat(); |
---|
27 | cout << L <<endl; |
---|
28 | |
---|
29 | cout << "Test opupdt" <<endl; |
---|
30 | cout << "w=1" <<endl; |
---|
31 | ldmat ldup = ld; |
---|
32 | ldup.opupdt(v,1); |
---|
33 | cout << ldup.to_mat()<<endl; |
---|
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; |
---|
40 | |
---|
41 | cout << "Test +="<<endl; |
---|
42 | ldmat ld2x = ld; |
---|
43 | ld2x+=ld; |
---|
44 | cout << ld.to_mat() <<endl << ld2x.to_mat() <<endl; |
---|
45 | |
---|
46 | cout << "Test *="<<endl; |
---|
47 | ld2x = ld; |
---|
48 | ld2x*=2; |
---|
49 | cout << ld.to_mat() <<endl << ld2x.to_mat() <<endl; |
---|
50 | |
---|
51 | cout << "Test ldinv()"<<endl; |
---|
52 | ldmat Il = ld; |
---|
53 | ld.inv(Il); // |
---|
54 | mat I = Il.to_mat()*ld.to_mat(); |
---|
55 | cout << "ld:" << endl << Il.to_mat() << "eye:" << endl<< I <<endl; |
---|
56 | getchar(); |
---|
57 | |
---|
58 | cout << "Test ldform()"<<endl; |
---|
59 | mat V = "1 2; 2 13"; |
---|
60 | ldmat lV(V); |
---|
61 | ldmat ilV(V); |
---|
62 | lV.inv(ilV); |
---|
63 | cout << "ld:" << lV << "eye:"<< V*(ilV.to_mat()) <<endl; |
---|
64 | |
---|
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 | |
---|
71 | |
---|
72 | //Exit program: |
---|
73 | getchar(); |
---|
74 | return 0; |
---|
75 | |
---|
76 | } |
---|