static Matrix from_columns(const Vector<T, M> *);
static Matrix from_rows(const Vector<T, N> *);
- T &element(unsigned, unsigned);
- const T &element(unsigned, unsigned) const;
- T &operator()(unsigned, unsigned);
- const T &operator()(unsigned, unsigned) const;
+ T &element(unsigned i, unsigned j) { return data[i+M*j]; }
+ const T &element(unsigned i, unsigned j) const { return data[i+M*j]; }
+ T &operator()(unsigned i, unsigned j) { return element(i, j); }
+ const T &operator()(unsigned i, unsigned j) const { return element(i, j); }
Matrix &operator*=(T);
Matrix &operator/=(T);
m(i, j) = v[i][j];
}
-template<typename T, unsigned M, unsigned N>
-inline T &Matrix<T, M, N>::element(unsigned i, unsigned j)
-{
- return data[i+M*j];
-}
-
-template<typename T, unsigned M, unsigned N>
-inline const T &Matrix<T, M, N>::element(unsigned i, unsigned j) const
-{
- return data[i+M*j];
-}
-
-template<typename T, unsigned M, unsigned N>
-inline T &Matrix<T, M, N>::operator()(unsigned i, unsigned j)
-{
- return element(i, j);
-}
-
-template<typename T, unsigned M, unsigned N>
-inline const T &Matrix<T, M, N>::operator()(unsigned i, unsigned j) const
-{
- return element(i, j);
-}
-
template<typename T, unsigned M, unsigned N>
inline Matrix<T, M, N> &Matrix<T, M, N>::operator*=(T s)
{
{
public:
SquareMatrix() { }
- SquareMatrix(const T *);
+ SquareMatrix(const T *d): Matrix<T, S, S>(d) { }
template<typename U>
- SquareMatrix(const Matrix<U, S, S> &);
+ SquareMatrix(const Matrix<U, S, S> &m): Matrix<T, S, S>(m) { }
static SquareMatrix identity();
SquareMatrix &invert();
};
-template<typename T, unsigned S>
-SquareMatrix<T, S>::SquareMatrix(const T *d):
- Matrix<T, S, S>(d)
-{ }
-
-template<typename T, unsigned S>
-template<typename U>
-SquareMatrix<T, S>::SquareMatrix(const Matrix<U, S, S> &m):
- Matrix<T, S, S>(m)
-{ }
-
template<typename T, unsigned S>
inline SquareMatrix<T, S> SquareMatrix<T, S>::identity()
{
template<typename U>
Vector(const Vector<U, N> &v);
- T &operator[](unsigned i);
- const T &operator[](unsigned i) const;
+ T &operator[](unsigned i) { return data[i]; }
+ const T &operator[](unsigned i) const { return data[i]; }
Vector &operator*=(T);
Vector &operator/=(T);
std::copy(v.data, v.data+N, data);
}
-template<typename T, unsigned N>
-T &Vector<T, N>::operator[](unsigned i)
-{
- return data[i];
-}
-
-template<typename T, unsigned N>
-const T &Vector<T, N>::operator[](unsigned i) const
-{
- return data[i];
-}
-
template<typename T, unsigned N>
inline Vector<T, N> &Vector<T, N>::operator*=(T s)
{
{
public:
Vector3() { }
- Vector3(const T *);
+ Vector3(const T *d): Vector<T, 3>(d) { }
Vector3(T, T, T);
template<typename U>
- Vector3(const Vector<U, 3> &);
+ Vector3(const Vector<U, 3> &v): Vector<T, 3>(v) { }
};
-template<typename T>
-inline Vector3<T>::Vector3(const T *d):
- Vector<T, 3>(d)
-{ }
-
template<typename T>
inline Vector3<T>::Vector3(T x, T y, T z)
{
this->data[2] = z;
}
-template<typename T>
-template<typename U>
-inline Vector3<T>::Vector3(const Vector<U, 3> &v):
- Vector<T, 3>(v)
-{ }
-
template<typename T>
inline T dot(const Vector<T, 3> &v1, const Vector<T, 3> &v2)
{