[GiNaC-list] write access to entries of submatrices [Was: multi index storage of expressions]

Charlls Quarra charlls_quarra at yahoo.com.ar
Tue Feb 20 13:44:54 CET 2007


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

> 
> On Mon, Feb 19, 2007 at 11:38:20PM -0300, Charlls
> Quarra wrote:
> > ( *(matrix*) & ex_to<matrix>(foo(0,1)) )(1,1) =
> 34;
> 
> Ugh, this is plain EVIL.
> 
> > im eager to find out what its the ginac-sanctioned
> way
> > to do it though
> 
> As I explained in the previous mail, there is no way
> to assign anything
> to references returned by ex_to<T>. If you really
> need multidimensional
> arrays (and vector<matrix> or vector<vector<vector
> <ex> > > are not
> good enough) then GiNaC is not proper tool for your
> task.

This morning i found a non-hacky (less-hacky?) way to
do it.
matrix foo(1 , 2);
	for (int i=0 ; i< 2 ; i++)
	{
		foo(0,i) = matrix(2,2);
	}
matrix sub = ex_to<matrix>(foo( 0, 1));
	sub( 1 , 1) = 34;
	foo( 0 , 1 ) = sub;
cout << "yes --> " << ex_to<matrix>( foo( 0 , 1 )
)(1,1) << endl;

if this is breaks refcounting too, then i guess one
should ask for a revision why is that matrix entries
behave like unidirectional membranes (you can put but
cannot change)

you make it sound quite final though, so i'll assume
you meant that there was no way to do it strictly thru
the ex_to<> interface, and no that there was no way to
do it "at all"

of course that this leaves unaswered how to perform
simple assignments like t3_idx( qi , qj , qk ) = foo
from the wrapper interface object... I guess ill have
to think about that some more

cheers



	

	
		
__________________________________________________ 
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