#include namespace hyporo { // Constructors template inline VectorSpace::VectorSpace() {} template template inline VectorSpace::VectorSpace(const Args... components) : row { static_cast(components)... } {} // Member functions template inline sizet VectorSpace::size() { return NC; } // Member operators template inline C& VectorSpace::operator[](const sizet n) { return row[n]; } template inline VectorSpace& VectorSpace::operator*=(const scalar s) { for (C& v : row) v *= s; return *this; } template inline VectorSpace& VectorSpace::operator/=(const scalar s) { for (C& v : row) v /= s; return *this; } // Friend operators template std::ostream& operator<<(std::ostream& os, const VectorSpace& vs) { os << "("; for (sizet n = 0; n < NC; n++) { os << vs.row[n]; if (n != NC - 1) os << ", "; } os << ")"; return os; } // Global operators template inline VectorSpace operator-(const VectorSpace& vs) { VectorSpace nvs; for (sizet n = 0; n < NC; n++) nvs.row[n] = -vs.row[n]; return nvs; } template inline VectorSpace operator+(const VectorSpace& vs1, const VectorSpace& vs2) { VectorSpace nvs; for (sizet n = 0; n < NC; n++) nvs.row[n] = vs1.row[n] + vs2.row[n]; return nvs; } template inline VectorSpace operator-(const VectorSpace& vs1, const VectorSpace& vs2) { VectorSpace nvs; for (sizet n = 0; n < NC; n++) nvs.row[n] = vs1.row[n] - vs2.row[n]; return nvs; } template inline VectorSpace operator*(const scalar& s, const VectorSpace& vs) { VectorSpace nvs; for (sizet n = 0; n < NC; n++) nvs.row[n] = s * vs.row[n]; return nvs; } template inline VectorSpace operator*(const VectorSpace& vs, const scalar& s) { VectorSpace nvs; for (sizet n = 0; n < NC; n++) nvs.row[n] = vs.row[n] * s; return nvs; } template inline VectorSpace operator/(const VectorSpace& vs, const scalar& s) { VectorSpace nvs; for (sizet n = 0; n < NC; n++) nvs.row[n] = vs.row[n] / s; return nvs; } template inline bool operator==(const VectorSpace& vs1, const VectorSpace& vs2) { bool eq = true; for (sizet n = 0; n < NC; n++) if (!(eq &= (vs1.row[n] == vs2.row[n]))) break; return eq; } template inline bool operator!=(const VectorSpace& vs1, const VectorSpace& vs2) { return !(vs1 == vs2); } } // end namespace hyporo