Hello All: I am working on generating some correlated sequences using Matrix Exponential techniques. there seems to be some problem with the way maple manages memory (or am i doing something wrong?). specifically, in the code below, i am calling a few functions inside a for loop but none recursively. so as the for loop progresses my stack (memory; seen as PF Usage in win XP) size should not really blow up. right? but in Maple 9.0 and 10.0 this below program would give a "Execution stopped: stack limit reached." exception after about 30000 executions(I am running on a WinXP machine , about 2.8GHz, with 512 MB RAM, also checked on a machine with 1 GB Ram; and another 1GB in page file size). But the same program seems to work alright on the same machines with Maple8 running (i uninstalled maple-9 and installed maple-8 in one case). I could go up to 300,000 iterations without any problem. And the memory would go from about 250MB (PF Usage) to about 800MB. So even in Maple 8 there is some stuff that is being dumped on the stack; i tried to run Garbage collector (gc()) function once every 500 iterations; it did not make any difference either. Can anyone please look into it? restart: with(linalg): with(LinearAlgebra): with(stats): Digits := 30; randomize(); lambda := 5.0; c := 1.0; Gamma := 0.0; #Fix Gamma for correlation decay slope P := 1/2 + (1/2)*(sqrt( (c^2 - 1)/(c^2 + 1) )); p := Matrix(1,2,[[P, (1-P)]]); B := Matrix(2,2,[[lambda*2*P, 0],[0, lambda*2*(1-P)]]); eps := Matrix(2,1,1); Iden := Matrix(2,2,shape=identity); V := B^(-1): Y := (1-Gamma)*eps.p + Gamma*Iden: L := B.Y; mean := (p.V.eps)[1,1]; var := 2*(p.(V^2).eps)[1,1] - ( (p.V.eps)[1,1] )^2; squaredCoeffOfVar := var/(mean^2); numerator := (p.(V^2).eps)[1,1] - ( (p.V.eps)[1,1])^2 ; var := 2*(p.(V^2).eps)[1,1] - ( (p.V.eps)[1,1] )^2; lag1CorrCoeff := (numerator/var)*(Gamma^1); #################################### TEMPMATRIX1 := convert(exponential(-B,t),Matrix).eps; for i from 1 to 100000 do uniformVariate := random[uniform](); fun := (p.TEMPMATRIX1)[1,1] = (1.0 - uniformVariate); nextIAT := fsolve(fun,t,0..infinity); ############# compute entrance vector for next event ########### pNew := p.convert(exponential(-B,nextIAT),Matrix).L ; pNewNormalized := pNew/(pNew.eps)[1,1]; p := pNewNormalized; if( is( (i mod 500)=0) ) then printf("Processing arrival: %f \n",i); fi; end do:

Please Wait...