21 #ifndef MIA_2D_VECTOR_HH
22 #define MIA_2D_VECTOR_HH
30 #include <type_traits>
83 template <
typename In>
95 return T(
x *
x +
y *
y);
100 return T(sqrt(
norm2()));
136 if ( a.
x == 0.0 || a.
y == 0.0)
137 throw std::invalid_argument(
"T2DVector<T>::operator /=: division by zero not allowed");
145 throw std::invalid_argument(
"T2DVector<T>::operator /=: division by zero not allowed");
188 return (
x == a.
x &&
y == a.
y);
193 return (! (*
this == a));
197 void print(std::ostream& os)
const {
214 is.clear(std::ios::badbit);
220 is.clear(std::ios::badbit);
230 is.clear(std::ios::badbit);
244 template <
typename T>
247 static const int size;
250 template <
typename T>
251 const int atomic_data<T2DVector<T> >::size = 2;
255 template <
typename T>
258 template <
typename T>
268 template <
typename T>
269 std::ostream& operator << (std::ostream& os, const T2DVector<T>& a)
282 template <
typename T>
296 template <
typename T>
312 template <
typename T,
typename S>
325 template <
typename T>
341 template <
typename T>
357 template <
typename T>
373 template <
typename T>
376 return b.
x * a.
x + b.
y * a.
y;
388 template <
typename T>
403 template <
typename T>
418 template <
typename T>
431 template <
typename T,
typename S>
434 return a.
x < b.x && a.y < b.y;
437 template <
typename T,
template <
typename>
class Vector>
441 return a.x * b.y - a.y * b.x;
453 template <
typename T>
460 template <
typename T>
463 return a.
y < b.
y || (a.
y == b.
y && a.
x < b.
x);
C2DTransformation::const_iterator operator+(C2DTransformation::const_iterator i, size_t delta)
Move an 2D transformation iterator forward by using its provided += operator don't use a reference to...
T2DVector< T > operator/(const T2DVector< T > &a, const T2DVector< T > &b)
A wrapper around the c-array to provide an STL like interface for iterators.
T value_type
typedef for generic access to the element type
T2DVector(const T2DVector< In > &in)
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
#define DEBUG_ASSERT_RELEASE_THROW(cond, msg...)
static const T2DVector< T > _0
a static for the value <0,0>.
void read(std::istream &is)
read the properly formatted 2D vector from a stream
T2DVector< unsigned int > C2DBounds
unsigned int valued 2D vector - used as 2D size parameter
T2DVector & operator+=(const T2DVector &a)
in place addition
F operator*(const typename TSparseSolver< F >::A_mult_x &A, const F &x)
T cross(const T2DVector< T > &a, const T2DVector< T > &b)
void print(std::ostream &os) const
print the vector to a stream with special formatting
T2DVector< T > operator-(const T2DVector< T > &a, const T2DVector< T > &b)
bool operator!=(const T2DVector &a) const
not equal operator
T2DVector & operator/=(const T2DVector &a)
in place element wise division of two 2D vectors
void fill(T v)
fill all the elements with the given value
T2DVector & operator-=(const T2DVector &a)
in place subtraction
T2DVector< float > C2DFVector
float valued 2D vector
static const T2DVector< T > _1
a static for the value <1,1>.
bool operator==(const T2DVector &a) const
Equal operator.
T dot(const T2DVector< T > &a, const T2DVector< T > &b)
std::istream & operator>>(std::istream &is, T2DVector< T > &a)
T2DVector< double > C2DDVector
double valued 2D vector
size_t size() const
returns the size of this vector, always 2
static return_type apply(const Vector< T > &a, const Vector< T > &b)
T2DVector & operator*=(double a)
in place multiplication with a scalar
#define NS_MIA_END
conveniance define to end the mia namespace