BFComplex *ComplexPower_bf(BFComplex *t, BFComplex *xx, BFComplex *yy) { BFComplex tmp; bf_t e2x, siny, cosy; int saved; saved = save_stack(); e2x = alloc_stack(rbflength+2); siny = alloc_stack(rbflength+2); cosy = alloc_stack(rbflength+2); tmp.x = alloc_stack(rbflength+2); tmp.y = alloc_stack(rbflength+2); // 0 raised to anything is 0 if (is_bf_zero(xx->x) && is_bf_zero(xx->y)) { clear_bf(t->x); clear_bf(t->y); return (t); } cmplxlog_bf(t, xx); cplxmul_bf(&tmp, t, yy); exp_bf(e2x, tmp.x); sincos_bf(siny, cosy, tmp.y); mult_bf(t->x, e2x, cosy); mult_bf(t->y, e2x, siny); restore_stack(saved); return (t); }
void zoomoutbf(void) /* for ctl-enter, calc corners for zooming out */ { /* (xxmin,yymax), etc, are already set to zoombox corners; (sxmin,symax), etc, are still the screen's corners; use the same logic as plot_orbit stuff to first calculate current screen corners relative to the zoombox, as if the zoombox were a square with upper left (0,0) and width/depth 1; ie calc the current screen corners as if plotting them from the zoombox; then extend these co-ords from current real screen corners to get new actual corners */ bf_t savbfxmin,savbfymax,bfftemp; bf_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6,bfplotmx1,bfplotmx2,bfplotmy1,bfplotmy2; int saved; saved = save_stack(); savbfxmin = alloc_stack(rbflength+2); savbfymax = alloc_stack(rbflength+2); bfftemp = alloc_stack(rbflength+2); tmp1 = alloc_stack(rbflength+2); tmp2 = alloc_stack(rbflength+2); tmp3 = alloc_stack(rbflength+2); tmp4 = alloc_stack(rbflength+2); tmp5 = alloc_stack(rbflength+2); tmp6 = alloc_stack(rbflength+2); bfplotmx1 = alloc_stack(rbflength+2); bfplotmx2 = alloc_stack(rbflength+2); bfplotmy1 = alloc_stack(rbflength+2); bfplotmy2 = alloc_stack(rbflength+2); /* ftemp = (yymin-yy3rd)*(xx3rd-xxmin) - (xxmax-xx3rd)*(yy3rd-yymax); */ sub_bf(tmp1,bfymin,bfy3rd); sub_bf(tmp2,bfx3rd,bfxmin); sub_bf(tmp3,bfxmax,bfx3rd); sub_bf(tmp4,bfy3rd,bfymax); mult_bf(tmp5,tmp1,tmp2); mult_bf(tmp6,tmp3,tmp4); sub_bf(bfftemp,tmp5,tmp6); /* plotmx1 = (xx3rd-xxmin); */ ; /* reuse the plotxxx vars is safe */ copy_bf(bfplotmx1,tmp2); /* plotmx2 = (yy3rd-yymax); */ copy_bf(bfplotmx2,tmp4); /* plotmy1 = (yymin-yy3rd); */ copy_bf(bfplotmy1,tmp1); /* plotmy2 = (xxmax-xx3rd); */; copy_bf(bfplotmy2,tmp3); /* savxxmin = xxmin; savyymax = yymax; */ copy_bf(savbfxmin,bfxmin); copy_bf(savbfymax,bfymax); sub_bf(tmp1,bfsxmin,savbfxmin); sub_bf(tmp2,bfsymax,savbfymax); zmo_calcbf(tmp1,tmp2,bfxmin,bfymax,bfplotmx1,bfplotmx2,bfplotmy1, bfplotmy2,bfftemp); sub_bf(tmp1,bfsxmax,savbfxmin); sub_bf(tmp2,bfsymin,savbfymax); zmo_calcbf(tmp1,tmp2,bfxmax,bfymin,bfplotmx1,bfplotmx2,bfplotmy1, bfplotmy2,bfftemp); sub_bf(tmp1,bfsx3rd,savbfxmin); sub_bf(tmp2,bfsy3rd,savbfymax); zmo_calcbf(tmp1,tmp2,bfx3rd,bfy3rd,bfplotmx1,bfplotmx2,bfplotmy1, bfplotmy2,bfftemp); restore_stack(saved); }
BFComplex *cplxmul_bf(BFComplex *t, BFComplex *x, BFComplex *y) { bf_t tmp1; int saved; saved = save_stack(); tmp1 = alloc_stack(rbflength+2); mult_bf(t->x, x->x, y->x); mult_bf(t->y, x->y, y->y); sub_bf(t->x, t->x, t->y); mult_bf(tmp1, x->x, y->y); mult_bf(t->y, x->y, y->x); add_bf(t->y, tmp1, t->y); restore_stack(saved); return (t); }
/* big number declarations */ void calc_corner(bf_t target,bf_t p1,double p2,bf_t p3,double p4,bf_t p5) { bf_t btmp1, btmp2 ,btmp3; int saved; saved = save_stack(); btmp1 = alloc_stack(rbflength+2); btmp2 = alloc_stack(rbflength+2); btmp3 = alloc_stack(rbflength+2); /* use target as temporary variable */ floattobf(btmp3, p2); mult_bf(btmp1,btmp3,p3); mult_bf(btmp2,floattobf(target, p4),p5); add_bf(target,btmp1,btmp2); add_a_bf(target,p1); restore_stack(saved); }
static void _fastcall zmo_calcbf(bf_t bfdx, bf_t bfdy, bf_t bfnewx, bf_t bfnewy,bf_t bfplotmx1, bf_t bfplotmx2, bf_t bfplotmy1, bf_t bfplotmy2, bf_t bfftemp) { bf_t btmp1, btmp2, btmp3, btmp4, btempx, btempy ; bf_t btmp2a, btmp4a; int saved; saved = save_stack(); btmp1 = alloc_stack(rbflength+2); btmp2 = alloc_stack(rbflength+2); btmp3 = alloc_stack(rbflength+2); btmp4 = alloc_stack(rbflength+2); btmp2a = alloc_stack(rbflength+2); btmp4a = alloc_stack(rbflength+2); btempx = alloc_stack(rbflength+2); btempy = alloc_stack(rbflength+2); /* calc cur screen corner relative to zoombox, when zoombox co-ords are taken as (0,0) topleft thru (1,1) bottom right */ /* tempx = dy * plotmx1 - dx * plotmx2; */ mult_bf(btmp1,bfdy,bfplotmx1); mult_bf(btmp2,bfdx,bfplotmx2); sub_bf(btempx,btmp1,btmp2); /* tempy = dx * plotmy1 - dy * plotmy2; */ mult_bf(btmp1,bfdx,bfplotmy1); mult_bf(btmp2,bfdy,bfplotmy2); sub_bf(btempy,btmp1,btmp2); /* calc new corner by extending from current screen corners */ /* *newx = sxmin + tempx*(sxmax-sx3rd)/ftemp + tempy*(sx3rd-sxmin)/ftemp; */ sub_bf(btmp1,bfsxmax,bfsx3rd); mult_bf(btmp2,btempx,btmp1); /* show_three_bf("fact1",btempx,"fact2",btmp1,"prod ",btmp2,70); */ div_bf(btmp2a,btmp2,bfftemp); /* show_three_bf("num ",btmp2,"denom",bfftemp,"quot ",btmp2a,70); */ sub_bf(btmp3,bfsx3rd,bfsxmin); mult_bf(btmp4,btempy,btmp3); div_bf(btmp4a,btmp4,bfftemp); add_bf(bfnewx,bfsxmin,btmp2a); add_a_bf(bfnewx,btmp4a); /* *newy = symax + tempy*(sy3rd-symax)/ftemp + tempx*(symin-sy3rd)/ftemp; */ sub_bf(btmp1,bfsy3rd,bfsymax); mult_bf(btmp2,btempy,btmp1); div_bf(btmp2a,btmp2,bfftemp); sub_bf(btmp3,bfsymin,bfsy3rd); mult_bf(btmp4,btempx,btmp3); div_bf(btmp4a,btmp4,bfftemp); add_bf(bfnewy,bfsymax,btmp2a); add_a_bf(bfnewy,btmp4a); restore_stack(saved); }
int JuliabfFractal() { // new.x = tmpsqrx - tmpsqry + parm.x; sub_a_bf(bftmpsqrx, bftmpsqry); add_bf(bfnew.x, bftmpsqrx, bfparm.x); // new.y = 2 * bfold.x * bfold.y + parm.y; mult_bf(bftmp, bfold.x, bfold.y); // ok to use unsafe here double_a_bf(bftmp); add_bf(bfnew.y, bftmp, bfparm.y); return bigfltbailout(); }