|
|
|
@ -64,95 +64,6 @@ public:
@@ -64,95 +64,6 @@ public:
|
|
|
|
|
inline void normalize() { |
|
|
|
|
(*this) /= norm(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Vector Operations |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
Vector<Type, M> operator+(const Vector<Type, M> &other) const |
|
|
|
|
{ |
|
|
|
|
Vector<Type, M> res; |
|
|
|
|
const Vector<Type, M> &self = *this; |
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < M; i++) { |
|
|
|
|
res(i) = self(i) + other(i); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Vector<Type, M> operator-(const Vector<Type, M> &other) const |
|
|
|
|
{ |
|
|
|
|
Vector<Type, M> res; |
|
|
|
|
const Vector<Type, M> &self = *this; |
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < M; i++) { |
|
|
|
|
res(i) = self(i) - other(i); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void operator+=(const Vector<Type, M> &other) |
|
|
|
|
{ |
|
|
|
|
Vector<Type, M> &self = *this; |
|
|
|
|
self = self + other; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void operator-=(const Vector<Type, M> &other) |
|
|
|
|
{ |
|
|
|
|
Vector<Type, M> &self = *this; |
|
|
|
|
self = self - other; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Scalar Operations |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
Vector<Type, M> operator*(Type scalar) const |
|
|
|
|
{ |
|
|
|
|
Vector<Type, M> res; |
|
|
|
|
const Vector<Type, M> &self = *this; |
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < M; i++) { |
|
|
|
|
res(i) = self(i) * scalar; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Vector<Type, M> operator/(Type scalar) const |
|
|
|
|
{ |
|
|
|
|
return (*this)*(Type(1.0)/scalar); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Vector<Type, M> operator+(Type scalar) const |
|
|
|
|
{ |
|
|
|
|
Vector<Type, M> res; |
|
|
|
|
const Vector<Type, M> &self = *this; |
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < M; i++) { |
|
|
|
|
res(i) = self(i) + scalar; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void operator*=(Type scalar) |
|
|
|
|
{ |
|
|
|
|
Vector<Type, M> &self = *this; |
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < M; i++) { |
|
|
|
|
self(i) = self(i) * scalar; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void operator/=(Type scalar) |
|
|
|
|
{ |
|
|
|
|
Vector<Type, M> &self = *this; |
|
|
|
|
self = self * (1.0f / scalar); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
}; // namespace matrix
|
|
|
|
|