bridge/class-master/depend/pari/src/graph/plotport.c
/* Uses highlevel plotting functions to implement splines as
   a low-level plotting function. */
Uses highlevel plotting functions to implement splines as
a low-level plotting function.
Uses highlevel plotting functions to implement splines as a low - level plotting function .
static void
rectsplines(long ne, double *x, double *y, long lx, long flag)
{
  long i, j;
  pari_sp av0 = avma;
  GEN X = pol_x(0), xa = cgetg(lx+1, t_VEC), ya = cgetg(lx+1, t_VEC);
  GEN tas, pol3;
  long param = flag & PLOT_PARAMETRIC;
  const long fl = param | PLOT_RECURSIVE | PLOT_NO_RESCALE | PLOT_NO_FRAME
                        | PLOT_NO_AXE_Y | PLOT_NO_AXE_X;
  if (lx < 4) pari_err(e_MISC, "Too few points (%ld) for spline plot", lx);
  for (i = 1; i <= lx; i++) {
    gel(xa,i) = dbltor(x[i-1]);
    gel(ya,i) = dbltor(y[i-1]);
  }
  if (param) {
    tas = new_chunk(4);
    for (j = 1; j <= 4; j++) gel(tas,j-1) = utoipos(j);
    pol3 = cgetg(3, t_VEC);
  }
  else
    tas = pol3 = NULL; 
  for (i = 0; i <= lx - 4; i++) {
    pari_sp av = avma;
    xa++; ya++;
    if (param) {
      gel(pol3,1) = polint_i(tas, xa, X, 4, NULL);
      gel(pol3,2) = polint_i(tas, ya, X, 4, NULL);
    } else {
      pol3 = polint_i(xa, ya, X, 4, NULL);
      tas = xa;
    }
    plotrecth((void*)pol3, &spline_eval, ne,
               i== 0 ? gel(tas,0) : gel(tas,1),
               i==lx-4 ? gel(tas,3) : gel(tas,2),
               fl, 2, DEFAULTPREC);
    avma = av;
  }
  avma = av0;
}
static void rectsplines ( long ne , double * x , double * y , long lx , long flag ) { long i , j ; pari_sp av0 = avma ; GEN X = pol_x ( 0 ) , xa = cgetg ( lx + 1 , t_VEC ) , ya = cgetg ( lx + 1 , t_VEC ) ; GEN tas , pol3 ; long param = flag & PLOT_PARAMETRIC ; const long fl = param | PLOT_RECURSIVE | PLOT_NO_RESCALE | PLOT_NO_FRAME | PLOT_NO_AXE_Y | PLOT_NO_AXE_X ; if ( lx < 4 ) pari_err ( e_MISC , " " , lx ) ; for ( i = 1 ; i <= lx ; i ++ ) { gel ( xa , i ) = dbltor ( x [ i - 1 ] ) ; gel ( ya , i ) = dbltor ( y [ i - 1 ] ) ; } if ( param ) { tas = new_chunk ( 4 ) ; for ( j = 1 ; j <= 4 ; j ++ ) gel ( tas , j - 1 ) = utoipos ( j ) ; pol3 = cgetg ( 3 , t_VEC ) ; } else tas = pol3 = NULL ; for ( i = 0 ; i <= lx - 4 ; i ++ ) { pari_sp av = avma ; xa ++ ; ya ++ ; if ( param ) { gel ( pol3 , 1 ) = polint_i ( tas , xa , X , 4 , NULL ) ; gel ( pol3 , 2 ) = polint_i ( tas , ya , X , 4 , NULL ) ; } else { pol3 = polint_i ( xa , ya , X , 4 , NULL ) ; tas = xa ; } plotrecth ( ( void * ) pol3 , & spline_eval , ne , i == 0 ? gel ( tas , 0 ) : gel ( tas , 1 ) , i == lx - 4 ? gel ( tas , 3 ) : gel ( tas , 2 ) , fl , 2 , DEFAULTPREC ) ; avma = av ; } avma = av0 ; }
Uses highlevel plotting functions to implement splines as
a low-level plotting function.
Uses highlevel plotting functions to implement splines as a low - level plotting function .
/* gcc -Wall */ /* Start with 3 points */