]> git.tdb.fi Git - libs/math.git/blobdiff - source/linal/vector.h
Add row and column accessors to Matrix
[libs/math.git] / source / linal / vector.h
index 152c26e66482e943e5837c5ddecc54fc9e7c2fde..9a9d02822aebe554627178803b4c6bd4c2621ddc 100644 (file)
@@ -78,6 +78,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 +118,13 @@ inline Vector<T, N>::Vector(const T *d)
                (*this)[i] = d[i];
 }
 
+template<typename T, unsigned N>
+inline Vector<T, N>::Vector(const T *d, unsigned stride)
+{
+       for(unsigned i=0; i<N; ++i)
+               (*this)[i] = d[i*stride];
+}
+
 /* The compiler won't instantiate these unless they are used.  Trying to use
 them on the wrong class results in an error. */
 template<typename T, unsigned N>