2d/matrix.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef __mia_2d_matrix_hh
22 #define __mia_2d_matrix_hh
23 
24 #include <mia/2d/vector.hh>
25 
27 
35 template <typename T>
36 struct T2DMatrix: public T2DVector< T2DVector<T> > {
37 
38  T2DMatrix();
39 
41  T2DMatrix(const T2DMatrix<T>& o);
42 
44  T2DMatrix(const T2DVector< T2DVector<T> >& o);
45 
50  T2DMatrix(const T2DVector< T >& x, const T2DVector< T >& y );
51 
54 
57 
61  T2DMatrix<T> transposed()const;
62 
63 
64  static const T2DMatrix _1;
65  static const T2DMatrix _0;
66 
67 };
68 
69 template <typename T>
71  T2DVector< T >(0,1));
72 
73 template <typename T>
75 
76 
77 template <typename T>
79  T2DVector<T2DVector<T> >(T2DVector<T>(), T2DVector<T>())
80 {
81 }
82 
83 template <typename T>
85  T2DVector<T2DVector<T> >(o.x, o.y)
86 {
87 }
88 
89 template <typename T>
91  T2DVector<T2DVector<T> >(o.x, o.y)
92 {
93 }
94 
95 template <typename T>
97  T2DVector<T2DVector<T> >(x, y)
98 {
99 }
100 
101 
102 template <typename T>
104 {
105  this->x = o.x;
106  this->y = o.y;
107  return *this;
108 }
109 
110 template <typename T>
112 {
113  this->x -= o.x;
114  this->y -= o.y;
115  return *this;
116 }
117 
118 template <typename T>
120 {
121  return T2DMatrix<T>(T2DVector< T >(this->x.x, this->y.x),
122  T2DVector< T >(this->y.y, this->y.y));
123 }
124 
132 template <typename T>
134 {
135  return T2DVector<T>(dot(m.x, x), dot(m.y, x));
136 }
137 
145 template <typename T>
147 {
148  return T2DVector<T>(m.x.x * x.x + m.y.x * x.y,
149  m.x.y * x.x + m.y.y * x.y);
150 }
151 
154 
156 
157 #endif
static const T2DMatrix _0
Definition: 2d/matrix.hh:65
static const T2DMatrix _1
Definition: 2d/matrix.hh:64
a 2D vector
Definition: 2d/vector.hh:46
T2DVector< T > y
second element
Definition: 2d/vector.hh:56
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
T2DMatrix< T > transposed() const
Definition: 2d/matrix.hh:119
A simple 2x2 matrix.
Definition: 2d/matrix.hh:36
T2DVector< T > operator*(const T2DVector< T > &x, const T2DMatrix< T > &m)
Definition: 2d/matrix.hh:133
T2DMatrix & operator-=(const T2DMatrix< T > &o)
element wise subtract operator
Definition: 2d/matrix.hh:111
double EXPORT_GSL dot(const gsl_vector *lhs, const gsl_vector *rhs)
T2DMatrix< float > C2DFMatrix
a simple 2x2 matrix
Definition: 2d/matrix.hh:153
T2DMatrix & operator=(const T2DMatrix< T > &o)
assignment operator
Definition: 2d/matrix.hh:103
T2DVector< T > x
first element
Definition: 2d/vector.hh:53
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36