X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flinal%2Fvector.h;h=c9b2a179fe5fd0ce595e4dda796b3c2d7b13ab5d;hb=9ab061034720c1c0db4e8bff5dae4191ccd2a26f;hp=152c26e66482e943e5837c5ddecc54fc9e7c2fde;hpb=5797fe0a5296952cb8f8643fdc6cabddee19a554;p=libs%2Fmath.git diff --git a/source/linal/vector.h b/source/linal/vector.h index 152c26e..c9b2a17 100644 --- a/source/linal/vector.h +++ b/source/linal/vector.h @@ -3,6 +3,7 @@ #include #include +#include namespace Msp { namespace LinAl { @@ -78,6 +79,11 @@ public: Vector(); Vector(const T *); + + /** Constructs a vector from an array of interleaved values. Intended for + use by Matrix row accessor. */ + Vector(const T *, unsigned); + Vector(T, T); Vector(T, T, T); Vector(T, T, T, T); @@ -113,6 +119,13 @@ inline Vector::Vector(const T *d) (*this)[i] = d[i]; } +template +inline Vector::Vector(const T *d, unsigned stride) +{ + for(unsigned i=0; i @@ -313,6 +326,20 @@ inline Vector cross(const Vector &v1, const Vector &v2) return Vector(v1.y*v2.z-v1.z*v2.y, v1.z*v2.x-v1.x*v2.z, v1.x*v2.y-v1.y*v2.x); } +template +inline std::ostream &operator<<(std::ostream &s, const Vector &v) +{ + s << "Vector" << N << '('; + for(unsigned i=0; i