1 #ifndef RKSmallVector_H
2 #define RKSmallVector_H
9 template<
typename T,
int N>
18 for (
int i=0;
i<
N; ++
i) data_[
i] = d[
i];
24 for (
int i=0;
i<
N;
i++) data_[
i] = *begin++;
28 int dim()
const {
return N;}
40 for (
int i=0;
i<
N; ++
i) data_[
i] += v[
i];
46 for (
int i=0;
i<
N; ++
i) data_[
i] -= v[
i];
53 for (
int i=0;
i<
N; ++
i) data_[
i] += t*v[
i];
61 for (
int i=0;
i<
N; ++
i) r[
i] = -data_[
i];
67 for (
int i=0;
i<
N; ++
i) data_[
i] *= t;
72 for (
int i=0;
i<
N; ++
i) data_[
i] /= t;
79 for (
int i=0;
i<
N; ++
i) r[
i] = data_[
i]*data_[
i];
90 template <
class T,
int N>
91 inline std::ostream & operator<<( std::ostream& s, const RKSmallVector<T,N>&
v) {
93 for (
int i=0;
i<
N; ++
i)
s <<
"v[" <<
i <<
"] = " <<
v[
i] << std::endl;
98 template <
class T,
class U,
int N>
103 for (
int i=0;
i<
N; ++
i) r[
i] = a[
i]+b[
i];
106 template <
class T,
class U,
int N>
111 for (
int i=0;
i<
N; ++
i) r[
i] = a[
i]-b[
i];
118 template <
class T,
class Scal,
int N>
120 T t =
static_cast<T>(
s);
122 for (
int i=0;
i<
N; ++
i) r[
i] = t*v[
i];
125 template <
class T,
class Scal,
int N>
127 T t =
static_cast<T>(
s);
129 for (
int i=0;
i<
N; ++
i) r[
i] = t*v[
i];
136 template <
class T,
class Scal,
int N>
138 T t =
static_cast<T>(
s);
140 for (
int i=0;
i<
N; ++
i) r[
i] = v[
i]/t;
Basic3DVector & operator*=(T t)
Scaling by a scalar value (multiplication)
T dot(const RKSmallVector &v) const
Scalar product, or "dot" product, with a vector of same type.
MatrixMeschach operator+(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
MatrixMeschach operator-(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
RKSmallVector(Iter begin, Iter end)
const T & operator()(int i) const
access to values
Basic3DVector & operator-=(const Basic3DVector< U > &p)
RKSmallVector(const Scalar *d)
Construct from array.
Basic3DVector< long double > operator/(const Basic3DVector< long double > &v, S s)
RKSmallVector operator-() const
Unary minus, returns a vector with negated components.
const T & operator[](int i) const
Basic3DVector & operator/=(T t)
Scaling by a scalar value (division)
RKSmallVector & increment(const RKSmallVector< U, N > &v, const T &t)
Increment by another vector multiplied by a scalar.
MatrixMeschach operator*(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
Basic3DVector & operator+=(const Basic3DVector< U > &p)