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?
The objects behind a GiNaC::ex are generally trees, but you just deal with the top-level thing and everything else happens automatically. Its up to you whether to allocate that top-level thing on the stack or on the heap. It will maintain its subobjects on the heap, but you don't have to care about that.
Suppose I create a matrix of rational functions, a single entry of which I'm interested in retaining. I would like to free the matrix and retain that one function. Can you provide a code snippet that does this?
// ... 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.
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. Several alternative elimination algorithms are implemented. There is a crude heuristic that decides which one to pick. But, as any heuristic, it can fail. You can always override the heuristics and do your own experiments: <http://www.ginac.de/reference/classGiNaC_1_1solve__algo.html>. Generally, the Bareiss algorithm is superior to the other ones, but if there are many symbols, it gets bogged down early because it incurs huge GCD computations. We've had cases where the Gauss algorithm was superior when the elements were rational functions. Please, try which works best for your problem. Regards -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>