My Project
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
35template <typename T>
36struct T2DMatrix: public T2DVector< T2DVector<T>> {
37
38 T2DMatrix();
39
41 T2DMatrix(const T2DMatrix<T>& o);
42
45
50 T2DMatrix(const T2DVector< T >& x, const T2DVector< T >& y );
51
54
57
62
63
64 static const T2DMatrix _1;
65 static const T2DMatrix _0;
66
67};
68
69template <typename T>
71 T2DVector< T >(0, 1));
72
73template <typename T>
75
76
77template <typename T>
82
83template <typename T>
85 T2DVector<T2DVector<T>>(o.x, o.y)
86{
87}
88
89template <typename T>
94
95template <typename T>
97 T2DVector<T2DVector<T>>(x, y)
98{
99}
100
101
102template <typename T>
104{
105 this->x = o.x;
106 this->y = o.y;
107 return *this;
108}
109
110template <typename T>
112{
113 this->x -= o.x;
114 this->y -= o.y;
115 return *this;
116}
117
118template <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
132template <typename T>
134{
135 return T2DVector<T>(dot(m.x, x), dot(m.y, x));
136}
137
145template <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
T2DMatrix< float > C2DFMatrix
a simple 2x2 matrix
Definition 2d/matrix.hh:153
T2DVector< T > operator*(const T2DVector< T > &x, const T2DMatrix< T > &m)
Definition 2d/matrix.hh:133
T dot(const T2DVector< T > &a, const T2DVector< T > &b)
Definition 2d/vector.hh:437
a 2D vector
Definition 2d/vector.hh:47
T2DVector< T > y
second element
Definition 2d/vector.hh:57
T2DVector< T > x
first element
Definition 2d/vector.hh:54
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
A simple 2x2 matrix.
Definition 2d/matrix.hh:36
static const T2DMatrix _0
Definition 2d/matrix.hh:65
static const T2DMatrix _1
Definition 2d/matrix.hh:64
T2DMatrix & operator-=(const T2DMatrix< T > &o)
element wise subtract operator
Definition 2d/matrix.hh:111
T2DMatrix< T > transposed() const
Definition 2d/matrix.hh:119
T2DMatrix & operator=(const T2DMatrix< T > &o)
assignment operator
Definition 2d/matrix.hh:103