// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#ifndef VECTORN_H
#define VECTORN_H
#include
#include
#if MATH_CHECK_INDEXES
#include
#endif
template
class VectorN
{
public:
// trivial ctor
inline VectorN() {
memset(_v, 0, sizeof(T)*N);
}
inline T & operator[](uint8_t i) {
#if MATH_CHECK_INDEXES
assert(i >= 0 && i < N);
#endif
return _v[i];
}
inline const T & operator[](uint8_t i) const {
#if MATH_CHECK_INDEXES
assert(i >= 0 && i < N);
#endif
return _v[i];
}
// test for equality
bool operator ==(const VectorN &v) const {
for (uint8_t i=0; i operator -(void) const {
VectorN v2;
for (uint8_t i=0; i operator +(const VectorN &v) const {
VectorN v2;
for (uint8_t i=0; i operator -(const VectorN &v) const {
VectorN v2;
for (uint8_t i=0; i operator *(const T num) const {
VectorN v2;
for (uint8_t i=0; i operator /(const T num) const {
VectorN v2;
for (uint8_t i=0; i &operator +=(const VectorN &v) {
for (uint8_t i=0; i &operator -=(const VectorN &v) {
for (uint8_t i=0; i &operator *=(const T num) {
for (uint8_t i=0; i &operator /=(const T num) {
for (uint8_t i=0; i