[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Toon-members] std::vector overload to use with TooN ( Dynamic Matri
From: |
Gerhard Reitmayr |
Subject: |
Re: [Toon-members] std::vector overload to use with TooN ( Dynamic Matrix assembling) |
Date: |
Sat, 22 May 2010 12:53:13 +0200 |
how about a Resizable matrix and a slice after it has been assembled ? you
would have to keep it around between iterations to avoid memory reallocation.
but it would be as efficient as a std::vector which also will reallocate and
copy the contents, if new elements are added and it exceeds the reserved size.
another way would be to take the std::vector contents and wrap with a matrix
using wrapMatrix (see internal/reference.hh). std::vector stores data in one
memory block so that should work fine.
cheers,
Gerhard
On 22 May 2010, at 12:24, 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,
>
> 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
>
> _______________________________________________
> Toon-members mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/toon-members
--
Gerhard Reitmayr
Institute for Computer Graphics and Vision
http://www.icg.tugraz.at/Members/gerhard
tel: ++43 316 873 5082