copy and time cmd

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 518
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

copy and time cmd

Message par compsystems » lun. janv. 13, 2020 3:13 pm

Hi BP, Good morning

Porting the code to HP-prime, I observe that the time that Xcas throws does not approximate to deltalist(time(fract(320,240,10)))
Also the copy function res2:=copy(res1) in what differs of res2:=res1?

Code : Tout sélectionner

// hpprime: input mode, linear (algebraic)
function fract(X_,Y_,Nmax) // Mandelbrot fractal, not using symmetry.
  local x,y,z,c,j,w,h,res1,res2;
  //freeze;
  w:=2.7/X_;
  h:=-1.87/Y_;
  res1:=[]; 
  Y_:=Y_-1;
  for y from 0 to Y_ do
    c:=-2.1+i*(h*y+0.935);
    for x from 0 to X_-1 do
      z:=0;
      for j from 0 to Nmax-1 do
        if abs(z:=z^2+c)>2 then break; fi;
      od;
      res1.append(pixon(x,y,126*j+2079)); // hpprime: res1.append(pixon_p(x,y,126*j+2079));
      c:=c+w;
    od;
  od;
  return res1; // hpprime: comment on this line, 10 thousand elements maximum 
ffunction
:;
deltalist(time(fract(320,240,10)))

Code : Tout sélectionner

function fract1(X_,Y_,Nmax)
  local x,y,z,c,j,w,h,res1,res2;
  //freeze;
  w:=2.7/X_;
  h:=-1.87/Y_;
  res1:=makelist(-ceiling(X_*Y_/2)-1);   
  res2:=copy(res1);
  Y_:=Y_-1;
  for y from 0 to Y_/2 do
    c:=-2.1+i*(h*y+0.935);
    for x from 0 to X_-1 do
      z:=0;
      for j from 0 to Nmax-1 do
        if abs(z:=z^2+c)>2 then break; fi;
      od;
      res1.append(pixon(x,y,126*j+2079));  // hpprime: res1.append(pixon_p(x,y,126*j+2079)); 
      res2.append(pixon(x,Y_-y,126*j+2079));  // hpprime: res2.append(pixon_p(x,Y_-y,126*j+2079)); 
      c:=c+w;
    od;
  od;
  return res1,res2; // hpprime: comment on this line, 10 thousand elements maximum 
ffunction
deltalist(time(fract1(320,240,10)))

parisse
Messages : 5081
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: copy and time cmd

Message par parisse » lun. janv. 13, 2020 5:05 pm

Don't put the pixel in a list on calculators, the pixon_p or equivalent command does the job.

Répondre