|
From: | Gabriel Nützi |
Subject: | Fwd: Re: [Toon-members] std::vector overload to use with TooN ( Dynamic Matrix assembling) |
Date: | Wed, 26 May 2010 01:05:54 +0200 |
(sorry, wrong email) Hello! I have no the following problem with TooN: I am on Ubuntu 10, when I compile the follwing code: std::vector< Vector<6,double> > A; A.assign(7,makeVector(1,2,3,4,5,6)); Matrix<Dynamic,Dynamic,double,Reference::ColMajor> B(&(A[0][0]),6,7); cout << B<<endl; Output B: 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 5 5 5 6 6 6 6 6 6 6 This is fine! but replace the first line with : std::vector< Vector<Dynamic,double> > A; Output B: 1 0.145192 2.0225e-316 1 6.92627e-310 0 0 2 3.21143e-322 2.0223e-316 0 6.92619e-310 0 1.8941e-316 3 3.17437e-320 0 0 0 0 1.30354e-76 4 2.02236e-316 3.21143e-322 0 1.754e+97 0 0 5 1.95573e-316 0 0 0 0 7.72779e+228 6 2.02102e-316 0 1.9812e-321 0 2.122e-314 0 Which is completey nonsense, only because the definition of std:vector is Dynamic? Why is this like that (on OS X this does not happen?) Does anyone has a clue why this is that way? Thanks in Advance!!! Gabriel -------- Original-Nachricht -------- > Datum: Sun, 23 May 2010 13:49:18 +0100 (BST) > Von: "E. Rosten" <address@hidden> > An: "Gabriel Nützi" <address@hidden> > CC: address@hidden > Betreff: Re: [Toon-members] std::vector overload to use with TooN ( Dynamic Matrix assembling) > 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
-- GMX.ch - Schweizer FreeMail-Dienst mit über 800.000 Mitgliedern E-Mail & mehr! Kostenlos: http://portal.gmx.net/de/go/chfreemail -- GMX.ch - Schweizer FreeMail-Dienst mit über 800.000 Mitgliedern E-Mail & mehr! Kostenlos: http://portal.gmx.net/de/go/chfreemail |
[Prev in Thread] | Current Thread | [Next in Thread] |