SLAMflex SE  0.1.0
SLAMflex provides detection and tracking of dominant planes for smartphone devices. This plane can then be used to show AR content relative to the plane orientation. The detection of plane is performed in the field of view of the smartphone camera. In subsequent frames it is tracked. The interface returns the plane position and orientation.
diagmatrix.h
Go to the documentation of this file.
1 //-*- c++ -*-
2 //
3 // Copyright (C) 2009 Tom Drummond (twd20@cam.ac.uk),
4 // Ed Rosten (er258@cam.ac.uk)
5 //
6 // This file is part of the TooN Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
11 
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 // USA.
21 
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30 
31 
32 
33 namespace TooN {
34 
35 
55 template<int Size=Dynamic, typename Precision=DefaultPrecision, typename Base=Internal::VBase>
57 public:
60 
61  inline DiagonalMatrix() {}
62  inline DiagonalMatrix(int size_in) : my_vector(size_in) {}
63  inline DiagonalMatrix(Precision* data) : my_vector(data) {}
64  inline DiagonalMatrix(Precision* data, int size_in) : my_vector(data,size_in) {}
65  inline DiagonalMatrix(Precision* data_in, int size_in, int stride_in, Internal::Slicing)
66  : my_vector(data_in, size_in, stride_in, Internal::Slicing() ) {}
67 
68  // constructors to allow return value optimisations
69  // construction from 0-ary operator
71  template <class Op>
72  inline DiagonalMatrix(const Operator<Op>& op)
73  : my_vector (op)
74  {
75  op.eval(my_vector);
76  }
77 
78  // constructor from arbitrary vector
79  template<int Size2, typename Precision2, typename Base2>
81  : my_vector(from.size())
82  {
83  my_vector=from;
84  }
86 
87 
88 
90  Precision& operator[](int i){return my_vector[i];}
92  const Precision& operator[](int i) const {return my_vector[i];}
93 
96  return my_vector.as_slice();
97  }
98 
101  return my_vector.as_slice();
102  }
103 
106 };
107 
108 
109 template<int S1, typename P1, typename B1, int S2, typename P2, typename B2>
112  return diagmult(d.my_vector,v);
113 }
114 
115 template<int S1, typename P1, typename B1, int S2, typename P2, typename B2>
116 inline Vector<Internal::Sizer<S1,S2>::size, typename Internal::MultiplyType<P1,P2>::type>
118  return diagmult(v,d.my_vector);
119 }
120 
121 // perhaps not the safest way to do this as we're returning the same operator used to normally make vectors
122 template<int S1, typename P1, typename B1, int S2, typename P2, typename B2>
123 inline DiagonalMatrix<Internal::Sizer<S1,S2>::size, typename Internal::MultiplyType<P1,P2>::type>
125  SizeMismatch<S1,S2>::test(d1.my_vector.size(),d2.my_vector.size());
127 }
128 
129 template<int R, int C, int Size, typename P1, typename P2, typename B1, typename B2>
130 Matrix<R, C, typename Internal::MultiplyType<P1,P2>::type>
132  return diagmult(m,d.my_vector);
133 }
134 
135 template<int R, int C, typename P1, typename B1, int Size, typename P2, typename B2>
136 Matrix<R, C, typename Internal::MultiplyType<P1,P2>::type>
138 {
139  return diagmult(d.my_vector, m);
140 }
141 
142 }
Precision & operator[](int i)
Index the leading elements on the diagonal.
Definition: diagmatrix.h:90
DiagonalMatrix(const Operator< Op > &op)
my_vector constructed from a TooN::Operator
Definition: diagmatrix.h:72
Vector< Size, Precision, Base >::as_slice_type diagonal_slice()
Return the leading diagonal as a vector.
Definition: diagmatrix.h:95
Everything lives inside this namespace.
Definition: allocator.hh:48
DiagonalMatrix(Precision *data_in, int size_in, int stride_in, Internal::Slicing)
Definition: diagmatrix.h:65
static void test(int s1, int s2)
DiagonalMatrix(const Vector< Size2, Precision2, Base2 > &from)
Definition: diagmatrix.h:80
const Precision & operator[](int i) const
Index the leading elements on the diagonal.
Definition: diagmatrix.h:92
Vector< Size, Precision, Base > my_vector
The vector used to hold the leading diagonal.
Definition: diagmatrix.h:105
DiagonalMatrix(int size_in)
Definition: diagmatrix.h:62
DiagonalMatrix(Precision *data)
Definition: diagmatrix.h:63
DiagonalMatrix(Precision *data, int size_in)
Definition: diagmatrix.h:64
const Vector< Size, Precision, Base >::as_slice_type diagonal_slice() const
Return the leading diagonal as a vector.
Definition: diagmatrix.h:100
Vector< Internal::Sizer< S1, S2 >::size, typename Internal::MultiplyType< P1, P2 >::type > operator*(const DiagonalMatrix< S1, P1, B1 > &d, const Vector< S2, P2, B2 > &v)
Definition: diagmatrix.h:111
Vector< Internal::Sizer< S1, S2 >::size, typename Internal::MultiplyType< P1, P2 >::type > diagmult(const Vector< S1, P1, B1 > &v1, const Vector< S2, P2, B2 > &v2)
Definition: operators.hh:149