2d/matrix.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __mia_2d_matrix_hh
#define __mia_2d_matrix_hh
#include <mia/2d/vector.hh>
NS_MIA_BEGIN
template <typename T>
struct T2DMatrix: public T2DVector< T2DVector<T>> {
T2DMatrix();
T2DMatrix(const T2DMatrix<T>& o);
T2DMatrix(const T2DVector< T2DVector<T>>& o);
T2DMatrix(const T2DVector< T >& x, const T2DVector< T >& y );
T2DMatrix& operator = (const T2DMatrix<T>& o);
T2DMatrix& operator -= (const T2DMatrix<T>& o);
T2DMatrix<T> transposed()const;
static const T2DMatrix _1;
static const T2DMatrix _0;
};
template <typename T>
const T2DMatrix<T> T2DMatrix<T>::_1(T2DVector< T >(1, 0),
T2DVector< T >(0, 1));
template <typename T>
const T2DMatrix<T> T2DMatrix<T>::_0;
template <typename T>
T2DMatrix<T>::T2DMatrix():
T2DVector<T2DVector<T>>(T2DVector<T>(), T2DVector<T>())
{
}
template <typename T>
T2DMatrix<T>::T2DMatrix(const T2DMatrix<T>& o):
T2DVector<T2DVector<T>>(o.x, o.y)
{
}
template <typename T>
T2DMatrix<T>::T2DMatrix(const T2DVector< T2DVector<T>>& o):
T2DVector<T2DVector<T>>(o.x, o.y)
{
}
template <typename T>
T2DMatrix<T>::T2DMatrix(const T2DVector< T >& x, const T2DVector< T >& y ):
T2DVector<T2DVector<T>>(x, y)
{
}
template <typename T>
T2DMatrix<T>& T2DMatrix<T>::operator = (const T2DMatrix<T>& o)
{
this->x = o.x;
this->y = o.y;
return *this;
}
template <typename T>
T2DMatrix<T>& T2DMatrix<T>::operator -= (const T2DMatrix<T>& o)
{
this->x -= o.x;
this->y -= o.y;
return *this;
}
template <typename T>
T2DMatrix<T> T2DMatrix<T>::transposed()const
{
return T2DMatrix<T>(T2DVector< T >(this->x.x, this->y.x),
T2DVector< T >(this->y.y, this->y.y));
}
template <typename T>
T2DVector<T> operator * (const T2DVector<T>& x, const T2DMatrix<T>& m)
{
return T2DVector<T>(dot(m.x, x), dot(m.y, x));
}
template <typename T>
T2DVector<T> operator * (const T2DMatrix<T>& m, const T2DVector<T>& x )
{
return T2DVector<T>(m.x.x * x.x + m.y.x * x.y,
m.x.y * x.x + m.y.y * x.y);
}
typedef T2DMatrix<float> C2DFMatrix;
NS_MIA_END
#endif
C2DFMatrix
T2DMatrix< float > C2DFMatrix
a simple 2x2 matrix
Definition 2d/matrix.hh:153
operator*
T2DVector< T > operator*(const T2DVector< T > &x, const T2DMatrix< T > &m)
Definition 2d/matrix.hh:133
vector.hh
dot
T dot(const T2DVector< T > &a, const T2DVector< T > &b)
Definition 2d/vector.hh:437
T2DVector
a 2D vector
Definition 2d/vector.hh:47
T2DVector< T2DVector< T > >::T2DVector
T2DVector()
Definition 2d/vector.hh:65
T2DVector::y
T y
second element
Definition 2d/vector.hh:57
T2DVector::x
T x
first element
Definition 2d/vector.hh:54
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
T2DMatrix
A simple 2x2 matrix.
Definition 2d/matrix.hh:36
T2DMatrix::T2DMatrix
T2DMatrix(const T2DMatrix< T > &o)
copy constructor
Definition 2d/matrix.hh:84
T2DMatrix::T2DMatrix
T2DMatrix(const T2DVector< T2DVector< T > > &o)
construct the matrix from a 2D vector of 2D vectors
Definition 2d/matrix.hh:90
T2DMatrix::T2DMatrix
T2DMatrix(const T2DVector< T > &x, const T2DVector< T > &y)
Definition 2d/matrix.hh:96
T2DMatrix< float >::_1
static const T2DMatrix _1
Definition 2d/matrix.hh:64
T2DMatrix< float >::_0
static const T2DMatrix _0
Definition 2d/matrix.hh:65
T2DMatrix::operator-=
T2DMatrix & operator-=(const T2DMatrix< T > &o)
element wise subtract operator
Definition 2d/matrix.hh:111
T2DMatrix::transposed
T2DMatrix< T > transposed() const
Definition 2d/matrix.hh:119
T2DMatrix::operator=
T2DMatrix & operator=(const T2DMatrix< T > &o)
assignment operator
Definition 2d/matrix.hh:103
T2DMatrix::T2DMatrix
T2DMatrix()
Definition 2d/matrix.hh:78