[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:36:24 CET 2007


 AHHH nevermind i was accessing the entry 1,i where i
should be accessing 0,j 

send buttons should have a childproof safety lock

--- Charlls Quarra <charlls_quarra at yahoo.com.ar>
escribió:

>> 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 
> 
> _______________________________________________
> GiNaC-list mailing list
> GiNaC-list at ginac.de
> https://www.cebix.net/mailman/listinfo/ginac-list
> 



	

	
		
__________________________________________________ 
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 



More information about the GiNaC-list mailing list