00001 #include <TooN/TooN.h> 00002 using namespace std; 00003 using namespace TooN; 00004 00005 template<class M> void row(const M& m) 00006 { 00007 for(int r=0; r< m.num_rows(); r++) 00008 cout << m[r]; 00009 cout << endl; 00010 } 00011 00012 int main() 00013 { 00014 Vector<6> v = makeVector(1, 2, 3, 4, 5, 6); 00015 Vector<> u = v; 00016 00017 cout << v.slice<0,3>() << endl; 00018 cout << u.slice<0,3>() << endl << endl; 00019 00020 cout << v.slice<1,3>(1, 3) << endl; 00021 cout << u.slice<1,3>(1, 3) << endl; 00022 cout << v.slice<Dynamic,3>(1, 3) << endl; 00023 cout << u.slice<Dynamic,3>(1, 3) << endl; 00024 cout << v.slice<1,Dynamic>(1, 3) << endl; 00025 cout << u.slice<1,Dynamic>(1, 3) << endl; 00026 cout << v.slice<Dynamic,Dynamic>(1, 3) << endl; 00027 cout << u.slice<Dynamic,Dynamic>(1, 3) << endl << endl; 00028 00029 cout << v.slice(2, 3) << endl; 00030 cout << u.slice(2, 3) << endl << endl; 00031 00032 cout << project(v) << endl; 00033 cout << project(u) << endl; 00034 cout << project(v.slice<1,End<0> >()) << endl; 00035 cout << project(u.slice<1,End<0> >()) << endl; 00036 cout << unproject(v) << endl; 00037 cout << unproject(u) << endl; 00038 00039 cout << v.slice<1, End<0> >() << endl; 00040 cout << u.slice<1, End<0> >() << endl; 00041 cout << v.slice<1, End<-1> >() << endl; 00042 cout << u.slice<1, End<-1> >() << endl; 00043 cout << v.slice(2, End) << endl; 00044 cout << u.slice(2, End) << endl; 00045 cout << v.slice(2, End(-1)) << endl << endl; 00046 cout << u.slice(2, End(-1)) << endl << endl; 00047 00048 Vector<200> w = Zeros; 00049 00050 cout << w.slice<100,End<-99> >() << endl; 00051 00052 cout << endl << endl << endl; 00053 00054 Matrix<3> m = Data(1, 2, 3, 4, 5, 6, 7, 8, 9); 00055 Matrix<> n = m; 00056 00057 row(m.slice<0,1,2,2>()); 00058 row(n.slice<0,1,2,2>()); 00059 row(m.slice(0,1,2,2)); 00060 row(n.slice(0,1,2,2)); 00061 row(m.slice<0 ,1 ,2 ,2 >(0, 1, 2, 2)); 00062 row(n.slice<0 ,1 ,2 ,2 >(0, 1, 2, 2)); 00063 row(m.slice<0 ,1 ,2 ,Dynamic>(0, 1, 2, 2)); 00064 row(n.slice<0 ,1 ,2 ,Dynamic>(0, 1, 2, 2)); 00065 row(m.slice<0 ,1 ,Dynamic,2 >(0, 1, 2, 2)); 00066 row(n.slice<0 ,1 ,Dynamic,2 >(0, 1, 2, 2)); 00067 row(m.slice<0 ,1 ,Dynamic,Dynamic>(0, 1, 2, 2)); 00068 row(n.slice<0 ,1 ,Dynamic,Dynamic>(0, 1, 2, 2)); 00069 row(m.slice<0 ,Dynamic,2 ,2 >(0, 1, 2, 2)); 00070 row(n.slice<0 ,Dynamic,2 ,2 >(0, 1, 2, 2)); 00071 row(m.slice<0 ,Dynamic,2 ,Dynamic>(0, 1, 2, 2)); 00072 row(n.slice<0 ,Dynamic,2 ,Dynamic>(0, 1, 2, 2)); 00073 row(m.slice<0 ,Dynamic,Dynamic,2 >(0, 1, 2, 2)); 00074 row(n.slice<0 ,Dynamic,Dynamic,2 >(0, 1, 2, 2)); 00075 row(m.slice<0 ,Dynamic,Dynamic,Dynamic>(0, 1, 2, 2)); 00076 row(n.slice<0 ,Dynamic,Dynamic,Dynamic>(0, 1, 2, 2)); 00077 row(m.slice<Dynamic,1 ,2 ,2 >(0, 1, 2, 2)); 00078 row(n.slice<Dynamic,1 ,2 ,2 >(0, 1, 2, 2)); 00079 row(m.slice<Dynamic,1 ,2 ,Dynamic>(0, 1, 2, 2)); 00080 row(n.slice<Dynamic,1 ,2 ,Dynamic>(0, 1, 2, 2)); 00081 row(m.slice<Dynamic,1 ,Dynamic,2 >(0, 1, 2, 2)); 00082 row(n.slice<Dynamic,1 ,Dynamic,2 >(0, 1, 2, 2)); 00083 row(m.slice<Dynamic,1 ,Dynamic,Dynamic>(0, 1, 2, 2)); 00084 row(n.slice<Dynamic,1 ,Dynamic,Dynamic>(0, 1, 2, 2)); 00085 row(m.slice<Dynamic,Dynamic,2 ,2 >(0, 1, 2, 2)); 00086 row(n.slice<Dynamic,Dynamic,2 ,2 >(0, 1, 2, 2)); 00087 row(m.slice<Dynamic,Dynamic,2 ,Dynamic>(0, 1, 2, 2)); 00088 row(n.slice<Dynamic,Dynamic,2 ,Dynamic>(0, 1, 2, 2)); 00089 row(m.slice<Dynamic,Dynamic,Dynamic,2 >(0, 1, 2, 2)); 00090 row(n.slice<Dynamic,Dynamic,Dynamic,2 >(0, 1, 2, 2)); 00091 row(m.slice<Dynamic,Dynamic,Dynamic,Dynamic>(0, 1, 2, 2)); 00092 row(n.slice<Dynamic,Dynamic,Dynamic,Dynamic>(0, 1, 2, 2)); 00093 }