Re: matrix<dense1D<double> > possible for representing rank-3 tensor?
Johan Seland <[email protected]> Thu, 15 Dec 2005 14:35:41 +0100
| Newsgroups | gmane.comp.lib.mtl.devel |
|---|---|
| Message-ID | <[email protected]> |
On 12/14/05, Peter Gottschling <[email protected]> wrote: Thanks. Using Blitz for my tensor multiplication, and MTL for calculating some LU-inverses did indeed do the trick! BTW. Is there any way to initialize a dense1D<T> with external data? > Hello Johan, > > There are tensors implemented in Blitz++ (http://www.oonumerics.org/ > blitz/). I suppose that you can write your algorithm in a better > way there then with a MTL hack. BTW, I don't say this to scare you > away for the rest of my life. > > Cheers, > Peter > > On Dec 14, 2005, at 9:54 AM, Johan Seland wrote: > > > Hello all MTLers. > > > > I am trying to implement a change of basis algorithm from trivariate > > power basis to trivariate Bernstein basis. I have it all up and > > running in Mathematica, so I think my algorithm is sound. > > > > However, it involves a rank-3 tensor, which I had hoped I could > > represent in MTL using matrix<dense1D<double>, rectangle<>, > > dense<internal>, column_major>? > > > > Is this a viable option, or would I run into all sorts of trouble? > > (I know I can't directly expect MTL to handle Matrix.Tensor products, > > and I am prepared to write these myself using slices (ie. MTL > > 2D-matrices) ) > > > > I am currently having problems passing references to this beast > > around. It seems like the caller always segfaults after my > > initialization function of this beast has returned. > > > > What I am trying to do is along these lines: > > > > template<typename T> > > T > > torus( T& A) { > > A.resize( 5, 5 ); > > > > for ( typename T::iterator i = A.begin(); > > i != A.end(); ++i ) > > for ( typename T::OneD::iterator j = (*i).begin(); > > j != (*i).end(); ++j ) { > > (*j).resize( 5 ); > > } > > A[.][.][.] = ... > > . > > . > > } > > > > calculateM() { > > matrix<dense1D<double>, rectangle<>, dense<internal>, > > column_major> A; > > torus(A); > > <-- SEGFAULTS here. > > } > > > > -- > > Help a man with his math problems and you get him off your back for > > a day. > > Teach a man math, and you scare him off for the rest of your life. > > > > Regards Johan Seland > > PhD Student > > Center of Mathematics for Applications > > University of Oslo > > > > _______________________________________________ > > This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/ > > > > ------------ > Peter Gottschling > Research Associate > Open Systems Laboratory > Indiana University > 301i Lindley Hall > Bloomington, IN 47405 > Tel.: +1 812 855-8898 Fax: +1 812 856 0853 > http://www.osl.iu.edu/~pgottsch > > > _______________________________________________ > This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/ > -- Help a man with his math problems and you get him off your back for a day. Teach a man math, and you scare him off for the rest of your life. Regards Johan Seland PhD Student Center of Mathematics for Applications University of Oslo _______________________________________________ This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/