[GiNaC-list] memory allocation, matrices

Marko Riedel mriedel at lsi.upc.edu
Sun Sep 10 01:47:28 CEST 2006


Hello there,

Richard B. Kreckel writes:
 > Hi!
 > 
 > Marko Riedel wrote:
 > 
 > >I'm going to ask a very basic question, namely if you can point me to
 > >a tutorial where GiNaC's memory managment is described. I read the
 > >tutorial from your website but I could not find any info on this.
 > >
 > >I am familiar with the retain/release mechanism of used by Cocoa and
 > >GNUstep, and the use of autorelease pools. If you could compare these
 > >concepts to their GiNaC equivalents, that would be of great help.
 > >E.g. in Objective C I can create a tree of objects and either free
 > >them myself or put them into an autorelease pool that will be emptied
 > >by the runloop. How would I do this in GiNaC?
 > >  
 > >
[...]
 > 
 > // ...
 > ex interesting_element;
 > {
 > GiNaC::matrix mybigmatrix(100,100);
 > // construct mybigmatrix
 > interesting_element = mybigmatrix(47,11);
 > }
 > // use interesting_element here...
 > 
 > At the closing brace, mybigmatrix goes out of scope. The destructor 
 > incurs derementing the refcount of all 10000 elements, which get deleted 
 > if their refcount reaches zero. The refcount of the element of interest, 
 > however, was two (at least). So it continues to exist and you can use it 
 > afterwards.
 > 

Thank you for the concise explanation. I plan on mixing Objective C
and C++ and this leads to another question. Suppose I store a GiNaC
object in an instance variable of an Objective C object. This
operation should increment the referene count of the GiNaC object,
right? Next suppose that the deallocation method of the Objective C
object is invoked. Now I need an explicit release of the GiNaC
object. How would I do this? Do GiNaC objects have a method that
retrieves the reference count?

 > >I would also like to know what the limitations of the linear equation
 > >solver are. How many variables can it handle? What are the time and
 > >space complexities of the solver in terms of the number of variables
 > >and the number of equations?
 > >  
 > >
 > 
 > Asking for complexity in symbolic algorithms in such a general way does 
 > not make sense. An algorithm which is O(n^2) over the integers does not 
 > have to be so in any integral domain. It may be O(d*n^2) over univariate 
 > polynomials of degree d or even much worse. You have to try it out in 
 > order to find the practical limitations in your particular case.
 > 

Do you have concrete experience with systems of equations whose
coefficients are univariate polynomials with integer coefficients?

Thanks!

Best regards,

Marko


More information about the GiNaC-list mailing list