|
From: | E. Rosten |
Subject: | Re: [Toon-members] std::vector overload to use with TooN ( Dynamic Matrix assembling) |
Date: | Sun, 23 May 2010 13:49:18 +0100 (BST) |
User-agent: | Alpine 2.00 (LSU 1167 2008-08-23) |
On Sat, 22 May 2010, Gabriel Nützi wrote:
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,
I knew this problem would come up sooner or later. The best current solution is to use a std::vector along with wrapMatrix (as suggested by an earlier email).
The bect actual solution, I think is to write a Resizable allocator for Matrix. I think we actually want 2 allocators: one with resizable rows and one with resizable columns, and with methods to append/resize only the relavent dimension.
There may also be a case for generically resizable matrices, bit it is not as clear cut.
-Ed
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
-- (You can't go wrong with psycho-rats.)(http://mi.eng.cam.ac.uk/~er258) /d{def}def/f{/Times s selectfont}d/s{11}d/r{roll}d f 2/m{moveto}d -1 r 230 350 m 0 1 179{ 1 index show 88 rotate 4 mul 0 rmoveto}for/s 12 d f pop 235 420 translate 0 0 moveto 1 2 scale show showpage
[Prev in Thread] | Current Thread | [Next in Thread] |