$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mat2.cc
1 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #include <mln/algebra/mat.hh>
27 #include <mln/value/int_u8.hh>
28 
29 
30 int main()
31 {
32  using namespace mln;
33 
34  // FIXME: A test should not print!
35 
36  // const int
37  // tab1[18] = {3, 6, 5, 2, 4, 8,
38  // 5, 7, 4, 6, 9, 2,
39  // 2, 7, 1, 1, 5, 3},
40  // tab2[6] = {2, 5, 1, 0, 7, 2},
41  // tab3[6] = {3, 1, 6, 2, 1, 0};
42 
43  // algebra::mat<3,6,int> mat36 = make::mat<3,6,18>(tab1);
44  // algebra::mat<2,3,int> mat23_1 = make::mat<2,3,6>(tab2);
45  // algebra::mat<2,3,int> mat23_2 = make::mat<2,3,6>(tab3);
46 
47  // algebra::mat<2,3,float> mat23_3 = mat23_1 - mat23_2;
48 
49  // std::cout << mat23_3 << std::endl << mat23_3 * mat36 << std::endl;
50 
51  using algebra::vec;
52  vec<2,int> v = make::vec(5,1);
53 
54  using algebra::mat;
55  mat<2,2, vec<2,int> > mv;
56  mv.set_all(v);
57  // std::cout << mv << std::endl;
58 
59  {
60  mat<2,2,float> tmp = mv * mv;
61  // std::cout << tmp << std::endl;
62  tmp(0,0) = 0;
63  }
64  {
65  vec<2, vec<2,float> > tmp = mv * v;
66  // std::cout << (mv * v) << std::endl;
67  tmp[0] = v;
68  }
69  {
70  mat<2,2,float> tmp = value::scalar(v) * mv;
71  // std::cout << (value::scalar(v) * mv) << std::endl;
72  tmp(0,0) = 0;
73  }
74  {
75  vec<2, mat<2,2, vec<2,float> > > tmp = v * value::scalar(mv);
76  // std::cout << (v * value::scalar(mv)) << std::endl;
77  tmp[0](0,0) = v;
78  }
79  {
80  value::int_u8 i = 0;
81  mat<2,2, vec<2,int> > tmp = mv * i;
82  // std::cout << mv * i << std::endl;
83  tmp(0,0) = v;
84  }
85 
86 }