90 lines
3 KiB
Text
90 lines
3 KiB
Text
|
namespace cloonel {
|
||
|
///-------------------------------------------------------------------------
|
||
|
///-------------------------------------------------------------------------
|
||
|
template <typename T, uint32_t S>
|
||
|
Vector<T, S>::Vector (T parValue) :
|
||
|
m_mem {parValue}
|
||
|
{
|
||
|
}
|
||
|
|
||
|
///-------------------------------------------------------------------------
|
||
|
///-------------------------------------------------------------------------
|
||
|
template <typename T, uint32_t S>
|
||
|
template <typename U>
|
||
|
Vector<T, S>::Vector (const Vector<U, S>& parOther) {
|
||
|
for (uint32_t z = 0; z < S; ++z) {
|
||
|
m_mem[z] = parOther.m_mem[z];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
///-------------------------------------------------------------------------
|
||
|
///-------------------------------------------------------------------------
|
||
|
template <typename T, uint32_t S>
|
||
|
template <typename U>
|
||
|
const Vector<T, S>& Vector<T, S>::operator+= (const Vector<U, S>& parOther) {
|
||
|
for (uint32_t z = 0; z < S; ++z) {
|
||
|
m_mem[z] += parOther.m_mem[z];
|
||
|
}
|
||
|
return *this;
|
||
|
}
|
||
|
template <typename T, uint32_t S>
|
||
|
template <typename U>
|
||
|
const Vector<T, S>& Vector<T, S>::operator-= (const Vector<U, S>& parOther) {
|
||
|
for (uint32_t z = 0; z < S; ++z) {
|
||
|
m_mem[z] -= parOther.m_mem[z];
|
||
|
}
|
||
|
return *this;
|
||
|
}
|
||
|
template <typename T, uint32_t S>
|
||
|
template <typename U>
|
||
|
const Vector<T, S>& Vector<T, S>::operator*= (const Vector<U, S>& parOther) {
|
||
|
for (uint32_t z = 0; z < S; ++z) {
|
||
|
m_mem[z] *= parOther.m_mem[z];
|
||
|
}
|
||
|
return *this;
|
||
|
}
|
||
|
template <typename T, uint32_t S>
|
||
|
template <typename U>
|
||
|
const Vector<T, S>& Vector<T, S>::operator/= (const Vector<U, S>& parOther) {
|
||
|
for (uint32_t z = 0; z < S; ++z) {
|
||
|
m_mem[z] /= parOther.m_mem[z];
|
||
|
}
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
///-------------------------------------------------------------------------
|
||
|
///-------------------------------------------------------------------------
|
||
|
template <typename T, typename U, uint32_t S>
|
||
|
inline
|
||
|
Vector<typename std::common_type<T, U>::type, S> operator+ (const Vector<T, S>& parA, const Vector<U, S>& parB) {
|
||
|
typedef typename std::common_type<T, U>::type RetType;
|
||
|
Vector<RetType, S> retVal(parA);
|
||
|
parA += parB;
|
||
|
return retVal;
|
||
|
}
|
||
|
template <typename T, typename U, uint32_t S>
|
||
|
inline
|
||
|
Vector<typename std::common_type<T, U>::type, S> operator- (const Vector<T, S>& parA, const Vector<U, S>& parB) {
|
||
|
typedef typename std::common_type<T, U>::type RetType;
|
||
|
Vector<RetType, S> retVal(parA);
|
||
|
parA -= parB;
|
||
|
return retVal;
|
||
|
}
|
||
|
template <typename T, typename U, uint32_t S>
|
||
|
inline
|
||
|
Vector<typename std::common_type<T, U>::type, S> operator* (const Vector<T, S>& parA, const Vector<U, S>& parB) {
|
||
|
typedef typename std::common_type<T, U>::type RetType;
|
||
|
Vector<RetType, S> retVal(parA);
|
||
|
parA *= parB;
|
||
|
return retVal;
|
||
|
}
|
||
|
template <typename T, typename U, uint32_t S>
|
||
|
inline
|
||
|
Vector<typename std::common_type<T, U>::type, S> operator/ (const Vector<T, S>& parA, const Vector<U, S>& parB) {
|
||
|
typedef typename std::common_type<T, U>::type RetType;
|
||
|
Vector<RetType, S> retVal(parA);
|
||
|
parA /= parB;
|
||
|
return retVal;
|
||
|
}
|
||
|
} //namespace cloonel
|