refactor PIMathMatrixT and fix pimathvector.h

This commit is contained in:
2020-10-22 16:13:39 +03:00
parent b46825a5a0
commit 7413c7252b
2 changed files with 68 additions and 92 deletions

View File

@@ -56,10 +56,14 @@ public:
return tv;
}
uint size() const {return Size;}
constexpr uint size() const {return Size;}
_CVector & fill(const Type & v) {PIMV_FOR c[i] = v; return *this;}
_CVector & move(const Type & v) {PIMV_FOR c[i] += v; return *this;}
_CVector & move(const _CVector & v) {PIMV_FOR c[i] += v[i]; return *this;}
_CVector & swapElements(uint f, uint s) {
piSwap<Type>(c[f], c[s]);
return *this;
}
Type lengthSqr() const {
Type tv(0);
PIMV_FOR tv += c[i] * c[i];
@@ -99,13 +103,15 @@ public:
bool isNull() const {PIMV_FOR if (c[i] != Type(0)) return false; return true;}
bool isOrtho(const _CVector & v) const {return ((*this) ^ v) == Type(0);}
Type & at(uint index) {return c[index];}
Type at(uint index) const {return c[index];}
Type & operator [](uint index) {return c[index];}
Type operator [](uint index) const {return c[index];}
const Type & operator [](uint index) const {return c[index];}
Type at(uint index) const {return c[index];}
_CVector & operator =(const Type & v) {PIMV_FOR c[i] = v; return *this;}
bool operator ==(const _CVector & v) const {PIMV_FOR if (c[i] != v[i]) return false; return true;}
bool operator !=(const _CVector & v) const {return !(*this == c);}
void operator +=(const _CVector & v) {PIMV_FOR c[i] += v[i];}
void operator -=(const _CVector & v) {PIMV_FOR c[i] -= v[i];}
void operator *=(const Type & v) {PIMV_FOR c[i] *= v;}
@@ -287,8 +293,8 @@ public:
PIMV_FOR c[i] += v[i];
return *this;
}
_CVector & swapElements(uint fe, uint se) {
piSwap<Type>(c[fe], c[se]);
_CVector & swapElements(uint f, uint s) {
piSwap<Type>(c[f], c[s]);
return *this;
}
Type lengthSqr() const {
@@ -340,12 +346,15 @@ public:
bool isValid() const {return !c.isEmpty();}
bool isOrtho(const _CVector & v) const {return dot(v) == Type(0);}
Type & at(uint index) {return c[index];}
Type at(uint index) const {return c[index];}
Type & operator [](uint index) {return c[index];}
Type operator [](uint index) const {return c[index];}
const Type & operator [](uint index) const {return c[index];}
Type at(uint index) const {return c[index];}
_CVector & operator =(const Type & v) {PIMV_FOR c[i] = v; return *this;}
bool operator ==(const _CVector & v) const {return c == v.c;}
bool operator !=(const _CVector & v) const {return c != v.c;}
void operator +=(const _CVector & v) {
assert(c.size() == v.size());
PIMV_FOR c[i] += v[i];