Esempio n. 1
0
void l_cartographer(void)
{
    int i,j,x,y;
    print1("Ye Olde Mappe Shoppe.");
    print2("Map of the local area: 500Au. Buy it? [yn] ");
    if (ynq2()=='y') {
        if (Player.cash < 500)
            print3("Cursed be cheapskates! May you never find an aid station....");
        else {
            print3("You now have the local area mapped.");
            Player.cash -= 500;
            dataprint();
            switch(Villagenum) {
            case 1:
                x = 56;
                y = 5;
                break;
            default:
            case 2:
                x = 35;
                y = 11;
                break;
            case 3:
                x = 10;
                y = 40;
                break;
            case 4:
                x = 7;
                y = 6;
                break;
            case 5:
                x = 40;
                y = 43;
                break;
            case 6:
                x = 20;
                y = 41;
                break;
            }
            for(i=x-15; i<=x+15; i++)
                for(j=y-15; j<=y+15; j++)
                    if ((i>=0)&&(i<64)&&(j>=0)&&(j<64)) {
                        if (Country[i][j].current_terrain_type !=
                                Country[i][j].base_terrain_type) {
                            c_set(i, j, CHANGED);
                            Country[i][j].current_terrain_type =
                                Country[i][j].base_terrain_type;
                        }
                        c_set(i, j, SEEN);
                    }
        }
    }
    else print3("Don't blame me if you get lost....");
}
Esempio n. 2
0
  void tester::test<1>()
  {
    IDs::generator g_set("dummy", "dummy");
    IDs::generator g_wild;
    IDs::channel c_set(IDs::kMuSc, IDs::kSlow);
    IDs::channel c_wild;


    IDs::source tame(c_set, g_set);
    ensure("All fixed is not wild", !tame.isWildCard());
    ensure("All fixed is not wild chan", !tame.isWildCardChannel());
    ensure("All fixed is not wild gen", !tame.isWildCardGenerator());
    
    IDs::source gen_wild(c_set, g_wild);
    ensure("Generator wild is wild", gen_wild.isWildCard());
    ensure("Generator wild is not wild chan", !gen_wild.isWildCardChannel());
    ensure("Generator wild is wild gen", gen_wild.isWildCardGenerator());

    IDs::source chan_wild(c_wild, g_set);
    ensure("Channel wild is wild", chan_wild.isWildCard());
    ensure("Channel wild is wild chan", chan_wild.isWildCardChannel());
    ensure("Channel wild is not wild gen", !chan_wild.isWildCardGenerator());

    IDs::source all_wild(c_wild, g_wild);
    ensure("Doublely wild is wild", all_wild.isWildCard());    
    ensure("Doublely wild is wild chan", all_wild.isWildCardChannel());    
    ensure("Doublely wild is wild gen", all_wild.isWildCardGenerator());    
  }
Esempio n. 3
0
/*
 *  Draw a background.
 */
void c_bkgft1(float ypos, char *label, float yb, float yt) {

  c_set(0.,1.,0.,1.,0.,1.,0.,1.,1);

/*
 *   Plot the curve label using font 21 (Helvetica).
 */
  c_pcseti("fn",21);
  c_plchhq(0.17,ypos-0.2,label,0.03,0.,-1.0);

/*
 *  Draw a horizontal line at Y=0. using color index 2.
 */
  c_set(0.13,0.93,ypos-0.28,ypos,0.0,1., yb, yt, 1);
  gset_line_colr_ind(2);
  c_line(0.,0.,1.,0.); 
  c_sflush();
  gset_line_colr_ind(1);

/*
 *  Set Gridal parameters.
 *
 *
 *   Set lty to indicate that the Plotchar routine PLCHHQ should be used.
 */
  c_gaseti("lty",1);
  c_pcseti("fn",21);

/*
 *   Size and format for X axis labels.
 */
  c_gasetr("xls",0.02);
  c_gasetc("xlf","(f3.1)");

/*
 *   Size and format for X axis labels.
 */
  c_gasetr("yls",0.02);
  c_gasetc("ylf","(f5.1)");

/*
 *  Length of major tick marks for the X and Y axes.
 */
  c_gasetr("xmj",0.02);
  c_gasetr("ymj",0.02);
}
Esempio n. 4
0
void c_bkgft4(float xleft, float xright, float ybot, float ytop,
              float ypos_bot, float ypos_top, char *label, float lab_size,
              float lab_posx, float lab_posy, int zero_line) {
  c_set(0.,1.,0.,1.,0.,1.,0.,1.,1);
  c_pcseti("fn",21);
  c_plchhq(lab_posx,lab_posy,label,lab_size,0.,0.0);
  c_set(0.17,0.87,ypos_bot,ypos_top,xleft,xright, ybot, ytop, 1);
  if (zero_line != 0) {
     gset_line_colr_ind(2);
     c_line(xleft, 0., xright, 0.);
     c_sflush();
     gset_line_colr_ind(1);
  }
  c_gaseti("lty",1);
  c_pcseti("fn",21);
  c_gasetr("xls",0.02);
  c_gasetc("xlf","(f4.1)");
  c_gasetr("yls",0.02);
  c_gasetc("ylf","(f5.1)");
  c_gasetr("xmj",0.02);
  c_gasetr("ymj",0.02);
}
Esempio n. 5
0
File: scr.c Progetto: anylonen/omega
void drawvision(int x, int y)
{
  static int oldx = -1,oldy = -1;
  int i,j,c;

  if (Current_Environment != E_COUNTRYSIDE) {
    if (Player.status[BLINDED]) {
      drawspot(oldx,oldy);
      drawspot(x,y);
      drawplayer();
    }
    else {
      if (Player.status[ILLUMINATION] > 0) {
        for (i= -2;i<3;i++)
          for (j= -2;j<3;j++)
            if (inbounds(x+i,y+j))
              if (view_los_p(x+i,y+j,Player.x,Player.y))
                dodrawspot(x+i,y+j);
      }
      else {
        for (i= -1;i<2;i++)
          for (j= -1;j<2;j++)
            if (inbounds(x+i,y+j))
              dodrawspot(x+i,y+j);
      }
      drawplayer();
      drawmonsters(FALSE); /* erase all monsters */
      drawmonsters(TRUE);  /* draw those now visible */
    }
    if ((! gamestatusp(FAST_MOVE)) || (! optionp(JUMPMOVE)))
      omshowcursor(Player.x,Player.y);
    oldx = x;
    oldy = y;
  }
  else {
    for (i= -1;i<2;i++)
      for (j= -1;j<2;j++)
        if (inbounds(x+i,y+j)) {
          c_set(x+i, y+j, SEEN);
          if (!offscreen(x+i,y+j)) {
            wmove(Levelw,screenmody(y+j),screenmodx(x+i));
            c = Country[x+i][y+j].current_terrain_type;
            if (optionp(SHOW_COLOUR))
              wattrset(Levelw, CHARATTR(c));
            waddch(Levelw,(c&0xff));
          }
        }
    drawplayer();
    omshowcursor(Player.x,Player.y);
  }
}
Esempio n. 6
0
File: scr.c Progetto: anylonen/omega
/* draw everything whether visible or not */
void drawscreen(void)
{
  int i,j;
  if (Current_Environment == E_COUNTRYSIDE)
    for (i=0;i<COUNTRY_WIDTH;i++)
      for(j=0;j<COUNTRY_LENGTH;j++)
        c_set(i, j, SEEN);
  else for (i=0;i<Level->level_width;i++)
    for(j=0;j<Level->level_length;j++)
      lset(i,j,SEEN);
  if (Current_Environment == E_CITY)
    for (i = 0; i < NUMCITYSITES; i++)
      CitySiteList[i][0] = 1;
  show_screen();
}
Esempio n. 7
0
void small_conducting_Mie(double x,struct c_complex m,double*mu,
long nangles,struct c_complex*s1,
struct c_complex*s2,double*qext,double*qsca,
double*qback,double*g)

/*:31*/
#line 448 "./mie.w"


{
struct c_complex ahat1,ahat2,bhat1,bhat2;
struct c_complex ss1;
double x2,x3,x4,muj,angle;
long j;

if((s1==NULL)||(s2==NULL))nangles= 0;

m.re+= 0.0;
x2= x*x;
x3= x2*x;
x4= x2*x2;

ahat1= c_div(c_set(0.0,2.0/3.0*(1.0-0.2*x2)),c_set(1.0-0.5*x2,2.0/3.0*x3));
bhat1= c_div(c_set(0.0,(x2-10.0)/30.0),c_set(1+0.5*x2,-x3/3.0));
ahat2= c_set(0.0,x2/30.);
bhat2= c_set(0.0,-x2/45.);

*qsca= 6.0*x4*(c_norm(ahat1)+c_norm(bhat1)+
(5.0/3.0)*(c_norm(ahat2)+c_norm(bhat2)));
*qext= *qsca;
*g= 6.0*x4*(ahat1.im*(ahat2.im+bhat1.im)+
bhat2.im*(5.0/9.0*ahat2.im+bhat1.im)+
ahat1.re*bhat1.re)/(*qsca);

ss1.re= 1.5*x2*(ahat1.re-bhat1.re);
ss1.im= 1.5*x2*(ahat1.im-bhat1.im-(5.0/3.0)*(ahat2.im+bhat2.im));
*qback= 4*c_norm(ss1);

x3*= 1.5;
ahat1.re*= x3;
ahat1.im*= x3;
bhat1.re*= x3;
bhat1.im*= x3;
ahat2.im*= x3*(5.0/3.0);
bhat2.im*= x3*(5.0/3.0);
for(j= 0;j<nangles;j++){
muj= mu[j];
angle= 2.0*muj*muj-1.0;
s1[j].re= ahat1.re+(bhat1.re)*muj;
s1[j].im= ahat1.im+(bhat1.im+ahat2.im)*muj+bhat2.im*angle;;
s2[j].re= bhat1.re+(ahat1.re)*muj;
s2[j].im= bhat1.im+(ahat1.im+bhat2.im)*muj+ahat2.im*angle;
}
}
Esempio n. 8
0
/* check to see if too much tunneling has been done in this level */
void tunnelcheck(void)
{
    if ((Level->depth == 0 && Current_Environment != E_DLAIR) ||
            Current_Environment == E_ASTRAL)
        return;
    Level->tunnelled++;
    if ((Level->tunnelled) > (Level->level_length)/4)
        mprint("Dust and stone fragments fall on you from overhead.");
    if ((Level->tunnelled) >(Level->level_length)/2)
        mprint("You hear groaning and creaking noises.");
    if ((Level->tunnelled) > (3*(Level->level_length))/4)
        mprint("The floor trembles and you hear a loud grinding screech.");
    if ((Level->tunnelled) > Level->level_length) {
        mprint("With a scream of tortured stone, the entire dungeon caves in!!!");
        gain_experience(5000);
        if (Player.status[SHADOWFORM]) {
            change_environment(E_COUNTRYSIDE);
            switch (Country[Player.x][Player.y].base_terrain_type)
            {
            case CASTLE:
            case STARPEAK:
            case CAVES:
            case VOLCANO:
                Country[Player.x][Player.y].current_terrain_type = MOUNTAINS;
                break;
            case DRAGONLAIR:
                Country[Player.x][Player.y].current_terrain_type = DESERT;
                break;
            case MAGIC_ISLE:
                Country[Player.x][Player.y].current_terrain_type = CHAOS_SEA;
                break;
            case PALACE:
                Country[Player.x][Player.y].current_terrain_type = JUNGLE;
                break;
            }
            Country[Player.x][Player.y].base_terrain_type =
                Country[Player.x][Player.y].current_terrain_type;
            c_set(Player.x, Player.y, CHANGED);
            print1("In your shadowy state, you float back up to the surface.");
            return;
        }
        mprint("You are flattened into an unpleasant jellylike substance.");
        p_death("dungeon cave-in");
    }
}
Esempio n. 9
0
void c_drwft4(int n, float x[], float y[], int m, 
              float xo[], float yo[], float u[], float xd[], float yd[])
{
  int i;

  Gcolr_rep rgb;
  Gpoint plist[IDIM];
  Gpoint_list pmk;

/*
 *  Open GKS, open and activate a workstation.
 */
  gopen_gks("stdout",0);
  gopen_ws(WKID, NULL, IWTYPE);
  gactivate_ws(WKID);

/*
 * Define a color table
 */
  rgb.rgb.red = rgb.rgb.green = rgb.rgb.blue = 1.;
  gset_colr_rep(WKID,0,&rgb);
  rgb.rgb.red = rgb.rgb.green = rgb.rgb.blue = 0.;
  gset_colr_rep(WKID,1,&rgb);
  rgb.rgb.red = 1.;
  rgb.rgb.green = rgb.rgb.blue = 0.;
  gset_colr_rep(WKID,2,&rgb);
  rgb.rgb.red = rgb.rgb.green = 0.;
  rgb.rgb.blue = 1.;
  gset_colr_rep(WKID,3,&rgb);

/*
 * Graph the interpolated function values and mark the original
 * input data points.
 */
  c_bkgft4(0.,40.,0.,40.,0.15,0.85,"Demo for c_ftkurv",0.03,0.5,0.93,0);
  c_gridal(4,5,4,5,1,1,10,0.,0.);
  c_curve(xo,yo,m);

/*
 *  Mark the input data points.
 */
  for (i = 0; i < n; i++) {
    plist[i].x = x[i];
    plist[i].y = y[i];
  }
  gset_marker_size(2.);
  gset_marker_colr_ind(3);
  pmk.num_points = n;
  pmk.points = plist;
  gpolymarker(&pmk);
  c_frame();

/*
 *  Plot the first derivatives.
 */
  c_set(0.,1.,0.,1.,0.,1.,0.,1.,1);
  c_pcseti("fn",21);
  c_plchhq(0.5,0.95,"Derivatives from c_ftkurvd",0.035,0.,0.);
  c_bkgft4(0.,1.,-80.,80.,0.55,0.87,"dx/du",0.030,0.65,0.82,1);
  c_gridal(5,5,4,5,1,1,10,0.,-80.);
  c_curve(u,xd,m);
  c_bkgft4(0.,1.,-40.,80.,0.1,0.42,"dy/du",0.030,0.39,0.37,1);
  c_gridal(5,5,3,5,1,1,10,0.,-40.);
  c_curve(u,yd,m);
  c_frame();

/*
 *  Deactivate and close workstation, close GKS.
 */
  gdeactivate_ws(WKID);
  gclose_ws(WKID);
  gclose_gks();
}
Esempio n. 10
0
File: overlap.c Progetto: IMSoP/CDex
void offset_adjust_settings(cdrom_paranoia *p, void(*callback)(long,int)){
  if(p->stage2.offpoints>=10){
    /* drift: look at the average offset value.  If it's over one
       sector, frob it.  We just want a little hysteresis [sp?]*/
    long av=(p->stage2.offpoints?p->stage2.offaccum/p->stage2.offpoints:0);
    
    if(abs(av)>p->dynoverlap/4){
      av=(av/MIN_SECTOR_EPSILON)*MIN_SECTOR_EPSILON;
      
      if(callback)(*callback)(ce(p->root.vector),PARANOIA_CB_DRIFT);
      p->dyndrift+=av;
      
      /* Adjust all the values in the cache otherwise we get a
	 (potentially unstable) feedback loop */
      {
	c_block *c=c_first(p);
	v_fragment *v=v_first(p);

	while(v && v->one){
	  /* safeguard beginning bounds case with a hammer */
	  if(fb(v)<av || cb(v->one)<av){
	    v->one=NULL;
	  }else{
	    fb(v)-=av;
	  }
	  v=v_next(v);
	}
	while(c){
	  long adj=min(av,cb(c));
	  c_set(c,cb(c)-adj);
	  c=c_next(c);
	}
      }

      p->stage2.offaccum=0;
      p->stage2.offmin=0;
      p->stage2.offmax=0;
      p->stage2.offpoints=0;
      p->stage2.newpoints=0;
      p->stage2.offdiff=0;
    }
  }

  if(p->stage1.offpoints>=10){
    /* dynoverlap: we arbitrarily set it to 4x the running difference
       value, unless min/max are more */

    p->dynoverlap=(p->stage1.offpoints?p->stage1.offdiff/
		   p->stage1.offpoints*3:CD_FRAMEWORDS);

    if(p->dynoverlap<-p->stage1.offmin*1.5)
      p->dynoverlap= - (long)( (double)p->stage1.offmin * 1.5 );
						     
    if(p->dynoverlap<p->stage1.offmax*1.5)
      p->dynoverlap = (long)( (double)p->stage1.offmax * 1.5 );

    if(p->dynoverlap<MIN_SECTOR_EPSILON)p->dynoverlap=MIN_SECTOR_EPSILON;
    if(p->dynoverlap>MAX_SECTOR_OVERLAP*CD_FRAMEWORDS)
      p->dynoverlap=MAX_SECTOR_OVERLAP*CD_FRAMEWORDS;
    			     
    if(callback)(*callback)(p->dynoverlap,PARANOIA_CB_OVERLAP);

    if(p->stage1.offpoints>600){ /* bit of a bug; this routine is
				    called too often due to the overlap 
				    mesh alg we use in stage 1 */
      p->stage1.offpoints = (long)( (double)p->stage1.offpoints / 1.2 );
      p->stage1.offaccum = (long)( (double)p->stage1.offaccum / 1.2);
      p->stage1.offdiff = (long)( (double) p->stage1.offdiff / 1.2 );
    }
    p->stage1.offmin=0;
    p->stage1.offmax=0;
    p->stage1.newpoints=0;
  }
}
Esempio n. 11
0
main()
{
    int i;
    Gasfs iasf;
    int lnd1[20],lnd2[16],lnd3[4],lnd4[4],lnd5[4],lnd6[4];
    extern void dfclrs();

    iasf.linetype = GASF_INDIV;
    iasf.linewidth = GASF_INDIV;
    iasf.line_colr_ind = GASF_INDIV;
    iasf.marker_type = GASF_INDIV;
    iasf.marker_size = GASF_INDIV;
    iasf.marker_colr_ind = GASF_INDIV;
    iasf.text_font_prec = GASF_INDIV;
    iasf.char_expan = GASF_INDIV;
    iasf.char_space = GASF_INDIV;
    iasf.text_colr_ind = GASF_INDIV;
    iasf.fill_int_style = GASF_INDIV;
    iasf.fill_style_ind = GASF_INDIV;
    iasf.fill_colr_ind = GASF_INDIV;

    for( i = 0; i < 20; i++ ) lnd1[i] = i+1;
    for( i = 0; i < 16; i++ ) lnd2[i] = i;
    for( i = 0; i < 4; i++ ) {
        lnd3[i] = i+12;
        lnd4[i] = i+8;
        lnd5[i] = i+4;
        lnd6[i] = i;
    }
/*
 * Open GKS.
 */
    gopen_gks("stdout",0);
    gopen_ws (WKID, NULL, IWTYPE);
    gactivate_ws(WKID);
/*
 * Set all the GKS aspect source flags to "individual".
 */
    gset_asfs(&iasf);
/*
 * Force solid fill.
 */
    gset_fill_int_style(GSTYLE_SOLID);
/*
 * Turn off the clipping indicator.
 */
    gset_clip_ind(GIND_NO_CLIP);
/*
 * Define color indices.
 */
    dfclrs();
/*
 * Set some parameter values.
 */
    c_pcsetr("CS - CONSTANT SPACING",1.25);
    c_lbsetr("WBL - WIDTH OF BOX LINES",4.);
    c_lbsetr("WFL - WIDTH OF FILL LINES",2.);
    c_lbsetr("WLB - WIDTH OF LABEL LINES",2.);
/*
 * Put the first label bar vertically along the left edge of the plotter
 * frame.  Use patterns.
 */
    c_sfseti("ANGLE OF FILL LINES",15);
    c_sfseti ("TYPE OF FILL",-4);
    c_lblbar(1,.05,.30,.05,.95,20,.3333,1.,lnd1,0,llb1,20,2);
/*
 * Put the second label bar vertically along the right edge.  Use solid
 * color fill.
 */
    c_sfseti("TYPE OF FILL",0);
    c_lblbar(1,.70,.95,.05,.95,16,.3333,1.,lnd2,0,llb2,17,1);
    c_lblbar(0,.35,.65,.05,.20,4,.5,.5,lnd3,1,llb3,4,1);
    c_lblbar(0,.35,.65,.20,.35,4,.5,.5,lnd4,1,llb4,4,1);
    c_lblbar(0,.35,.65,.35,.50,4,.5,.5,lnd5,1,llb5,4,1);
    c_lblbar(0,.35,.65,.50,.65,4,.5,.5,lnd6,1,llb6,4,1);
/*
 * Put a title on the plot.  We must first call SET to define the ranges
 * of the X and Y coordinates to be used.  The constant spacing feature
 * is turned off so that the title will look normal.
 */
    c_set(0.,1.,0.,1.,0.,1.,0.,1.,1);
    c_pcsetr("CS - CONSTANT SPACING",0.);
    c_plchhq(.5,.90,"THREE",.025,0.,0.);
    c_plchhq(.5,.85,"LABELBAR",.025,0.,0.);
    c_plchhq(.5,.80,"EXAMPLES",.025,0.,0.);
/*
 * Advance the frame.
 */    
    c_frame();
/*
 * Close GKS.
 */
    gdeactivate_ws (WKID);
    gclose_ws (WKID);
    gclose_gks();
}
Esempio n. 12
0
void Mie(double x,struct c_complex m,double*mu,long nangles,struct c_complex*s1,
struct c_complex*s2,double*qext,double*qsca,double*qback,double*g)

/*:34*/
#line 519 "./mie.w"


{
/*36:*/
#line 546 "./mie.w"

struct c_complex*D;
struct c_complex z1,an,bn,bnm1,anm1,qbcalc;
double*pi0,*pi1,*tau;
struct c_complex xi,xi0,xi1;
double psi,psi0,psi1;
double alpha,beta,factor;
long n,k,nstop,sign;
*qext= -1;
*qsca= -1;
*qback= -1;
*g= -1;

/*:36*/
#line 522 "./mie.w"


/*37:*/
#line 559 "./mie.w"

if(m.im> 0.0){
mie_error("This program requires m.im>=0",1);
return;
}
if(x<=0.0){
mie_error("This program requires positive sphere sizes",2);
return;
}
if(nangles<0){
mie_error("This program requires non-negative angle sizes",3);
return;
}
if(nangles<0){
mie_error("This program requires non-negative angle sizes",4);
return;
}
if((nangles> 0)&&(s1==NULL)){
mie_error("Space must be allocated for s1 if nangles!=0",5);
return;
}
if((nangles> 0)&&(s2==NULL)){
mie_error("Space must be allocated for s2if nangles!=0",6);
return;
}
if(x> 20000){
mie_error("Program not validated for spheres with x>20000",7);
return;
}

/*:37*/
#line 524 "./mie.w"

/*38:*/
#line 589 "./mie.w"

if((m.re==0)&&(x<0.1)){
small_conducting_Mie(x,m,mu,nangles,s1,s2,qext,qsca,qback,g);
return;
}

if((m.re> 0.0)&&(c_abs(m)*x<0.1)){
small_Mie(x,m,mu,nangles,s1,s2,qext,qsca,qback,g);
return;
}

/*:38*/
#line 525 "./mie.w"


/*40:*/
#line 616 "./mie.w"

nstop= floor(x+4.05*pow(x,0.33333)+2.0);

/*:40*/
#line 527 "./mie.w"


/*39:*/
#line 600 "./mie.w"

if(nangles> 0){
set_carray(s1,nangles,c_set(0.0,0.0));
set_carray(s2,nangles,c_set(0.0,0.0));

pi0= new_darray(nangles);
pi1= new_darray(nangles);
tau= new_darray(nangles);

set_darray(pi0,nangles,0.0);
set_darray(tau,nangles,0.0);
set_darray(pi1,nangles,1.0);
}

/*:39*/
#line 529 "./mie.w"

if(m.re> 0)
/*41:*/
#line 634 "./mie.w"

{
struct c_complex z;

z= c_smul(x,m);

D= new_carray(nstop+1);
if(D==NULL){
mie_error("Cannot allocate log array",8);
return;
}

if(fabs(m.im*x)<((13.78*m.re-10.8)*m.re+3.9))
Dn_up(z,nstop,D);
else
Dn_down(z,nstop,D);
}

/*:41*/
#line 531 "./mie.w"


/*42:*/
#line 671 "./mie.w"

psi0= sin(x);
psi1= psi0/x-cos(x);
xi0= c_set(psi0,cos(x));
xi1= c_set(psi1,cos(x)/x+sin(x));
*qsca= 0.0;
*g= 0.0;
*qext= 0.0;
sign= 1;
qbcalc= c_set(0.0,0.0);
anm1= c_set(0.0,0.0);
bnm1= c_set(0.0,0.0);

/*:42*/
#line 533 "./mie.w"


for(n= 1;n<=nstop;n++){
/*43:*/
#line 696 "./mie.w"

if(m.re==0.0){
an= c_sdiv(n*psi1/x-psi0,c_sub(c_smul(n/x,xi1),xi0));
bn= c_sdiv(psi1,xi1);
}else if(m.im==0.0){
z1.re= D[n].re/m.re+n/x;
an= c_sdiv(z1.re*psi1-psi0,c_sub(c_smul(z1.re,xi1),xi0));

z1.re= D[n].re*m.re+n/x;
bn= c_sdiv(z1.re*psi1-psi0,c_sub(c_smul(z1.re,xi1),xi0));
}else{
z1= c_div(D[n],m);
z1.re+= n/x;
an= c_div(c_set(z1.re*psi1-psi0,z1.im*psi1),c_sub(c_mul(z1,xi1),xi0));

z1= c_mul(D[n],m);
z1.re+= n/x;
bn= c_div(c_set(z1.re*psi1-psi0,z1.im*psi1),c_sub(c_mul(z1,xi1),xi0));
}

/*:43*/
#line 536 "./mie.w"

/*44:*/
#line 734 "./mie.w"

for(k= 0;k<nangles;k++){
factor= (2.0*n+1.0)/(n+1.0)/n;
tau[k]= n*mu[k]*pi1[k]-(n+1)*pi0[k];
alpha= factor*pi1[k];
beta= factor*tau[k];
s1[k].re+= alpha*an.re+beta*bn.re;
s1[k].im+= alpha*an.im+beta*bn.im;
s2[k].re+= alpha*bn.re+beta*an.re;
s2[k].im+= alpha*bn.im+beta*an.im;
}

for(k= 0;k<nangles;k++){
factor= pi1[k];
pi1[k]= ((2.0*n+1.0)*mu[k]*pi1[k]-(n+1.0)*pi0[k])/n;
pi0[k]= factor;
}

/*:44*/
#line 537 "./mie.w"

/*45:*/
#line 780 "./mie.w"

factor= 2.0*n+1.0;
*g+= (n-1.0/n)*(anm1.re*an.re+anm1.im*an.im+bnm1.re*bn.re+bnm1.im*bn.im);
*g+= factor/n/(n+1.0)*(an.re*bn.re+an.im*bn.im);
*qsca+= factor*(c_norm(an)+c_norm(bn));
*qext+= factor*(an.re+bn.re);
sign*= -1;
qbcalc.re+= sign*factor*(an.re-bn.re);
qbcalc.im+= sign*factor*(an.im-bn.im);

/*:45*/
#line 538 "./mie.w"

/*46:*/
#line 804 "./mie.w"

factor= (2.0*n+1.0)/x;
xi= c_sub(c_smul(factor,xi1),xi0);
xi0= xi1;
xi1= xi;

psi= factor*psi1-psi0;
psi0= psi1;
psi1= xi1.re;

anm1= an;
bnm1= bn;

/*:46*/
#line 539 "./mie.w"

}

/*47:*/
#line 817 "./mie.w"

*qsca*= 2/(x*x);
*qext*= 2/(x*x);
*g*= 4/(*qsca)/(x*x);
*qback= c_norm(qbcalc)/(x*x);

/*:47*/
#line 542 "./mie.w"

/*48:*/
#line 823 "./mie.w"

if(m.re> 0)free_carray(D);

if(nangles> 0){
free_darray(pi0);
free_darray(pi1);
free_darray(tau);
}

/*:48*/
#line 543 "./mie.w"

}