]> git.tdb.fi Git - libs/math.git/commitdiff
Fix a bug in the prefix version of vector compose function
authorMikko Rasa <tdb@tdb.fi>
Sun, 2 Jun 2019 11:40:29 +0000 (14:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 2 Jun 2019 16:13:09 +0000 (19:13 +0300)
source/linal/vector.h

index c9b2a179fe5fd0ce595e4dda796b3c2d7b13ab5d..767cc88da2d5b5518adc72b00d5f7f55582f8963 100644 (file)
@@ -174,9 +174,9 @@ template<typename T, unsigned N>
 inline Vector<T, N+1> compose(T s, const Vector<T, N> &v)
 {
        Vector<T, N+1> r;
+       r[0] = s;
        for(unsigned i=0; i<N; ++i)
-               r[i] = v[i];
-       r[N] = s;
+               r[i+1] = v[i];
        return r;
 }