|
From: | Gabriel Nützi |
Subject: | [Toon-members] std::vector overload to use with TooN ( Dynamic Matrix assembling) |
Date: | Sat, 22 May 2010 12:24:15 +0200 |
Hello all I have a question , and I don't know how to solve this as good as possible: I have an iteration in which I always assemble new Matrices (m x 7) dynamically, so I do not know how big they become in each iteration, the size m varies, Is there a way of realizing this either with TooN or with overloads in std::vector< Vector<7> > efficiently The only way I can push rows in my Matrix dynamically is with std::vector .... I was searching for a way to make this compatible with TooN and efficient (I dont want to copy heaps of data around) ? But I ve come up so far only with a overload in std::vectors wrote the fallowing overload: //Specialized Template vor Vector<> template <int N1, int N2, typename P, typename B> Vector<Dynamic,P,B> operator*(const std::vector<Vector<N1,P,B> >& x, Vector<N2,P,B> &y) { Vector<Dynamic,P,B> v(x.size()); v= Zeros; for (int m=0; m< x.size();m++) { for (int n=0; n<y.size(); n++) { v[m] += x[m][n] * y[n]; } } return v; } Does anyone know why the error happens here: vector<Vector<3> > A; A.assign(3,makeVector(1,2,3)); Vector<> a = makeVector(2,2,2); Vector<> c = A * a ; Vector<> b = A * ( A * a ); // ERRRRROOOOOORRRRRR (but why)) Would be very helpful if anyone could tell me how I should do this to make it efficient , and why this ERROR happens? Thanks alot for your support! Gabriel |
[Prev in Thread] | Current Thread | [Next in Thread] |