# [GiNaC-list] indexed objects are NOT arrays [Was: multi index storage of expressions]

Charlls Quarra charlls_quarra at yahoo.com.ar
Tue Feb 20 00:25:48 CET 2007

```--- Alexei Sheplyakov <varg at theor.jinr.ru> escribió:

> Hello,
>
> On Sun, Feb 18, 2007 at 12:02:25AM -0300, Charlls
> Quarra wrote:
> > Why am i trying to do this as an indexed object
> and
> > not with a matrix?
> >
> > well, because later, i would also want to make
> > computations with an object like
> >
> >  D( f_{i} ) / dx_{j} dx_{k}
>
> What about using vector (std::vector) of matrices
> (or GiNaC::lst
> of thereof)?

right now im trying to do something like this with
this recursive function whose purpose is to produce an
object that can be accessed
like  ex_to<matrix>( ex_to<matrix>(mat( i, j ))( k , l
) ) ( m , n ).. which at its time is wrapped with ()
operator of the correct size. However there is a
problem when constructing a matrix of 3 indices and
range 2. Concretely the assignment of the submatrices
obtained from the tail recursion fail:

matrix multi_index_matrix( int n , int range )
{
cout << " constructing matrix of " << n << " indices
of range " << range << endl;
if (n == 1)
{
return matrix( 1 , range );
//return;
}
if (n == 2)
{
cout << " matrix of " << range << "x" << range <<
endl;
return matrix( range , range );
//return;
}
if (n % 2 == 1)
{
// *put = matrix(1 , range);
matrix put( 1 , range );
cout << " top odd matrix " << endl;
for (int i=0; i < range; i++)
{
put( 1 , i ) = multi_index_matrix( n-1 , range );
cout << " done on index " << i << endl;
}
return put;
}
matrix put( range , range );
for (int i=0; i< range ; i++)
{
for (int j=0; j < range; j++)
{
put( i , j ) = multi_index_matrix( n - 2 , range );
}
}
return put;
};

int main()
{
matrix foo = multi_index_matrix( 3 , 2 );
cout << "done! " << endl;
}

__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

```