X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flinal%2Fvector.h;h=9a9d02822aebe554627178803b4c6bd4c2621ddc;hb=2feea51b078cc53663e411bf80e35044c1ef4a07;hp=9ef46fde412f22804535065d6dd59c10b11963e2;hpb=643aa7b2317f88463f66da11e595ebe0f6c9621d;p=libs%2Fmath.git diff --git a/source/linal/vector.h b/source/linal/vector.h index 9ef46fd..9a9d028 100644 --- a/source/linal/vector.h +++ b/source/linal/vector.h @@ -74,17 +74,25 @@ template class Vector: public VectorComponents { public: + typedef T ElementType; + 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); template Vector(const Vector &); - template - Vector(const Vector &, U); - template - explicit Vector(const Vector &); + + unsigned size() const { return N; } + + template + Vector slice(unsigned) const; Vector &operator*=(T); Vector &operator/=(T); @@ -110,6 +118,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 @@ -145,20 +160,44 @@ inline Vector::Vector(const Vector &v) } template -template -inline Vector::Vector(const Vector &v, U s) +inline Vector compose(const Vector &v, T s) { - for(unsigned i=0; i r; + for(unsigned i=0; i -template -inline Vector::Vector(const Vector &v) +inline Vector compose(T s, const Vector &v) { + Vector r; for(unsigned i=0; i +inline Vector compose(const Vector &v1, const Vector &v2) +{ + Vector r; + for(unsigned i=0; i +template +inline Vector Vector::slice(unsigned j) const +{ + Vector r; + for(unsigned i=0; i