matrix<dense1D<double> > possible for representing rank-3 tensor?

Johan Seland <[email protected]> Wed, 14 Dec 2005 15:54:34 +0100
Newsgroups gmane.comp.lib.mtl.devel
Message-ID <[email protected]>
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/