int load_cl(int l_size ,int* l_values){
	
	double* cls_data = malloc( sizeof(double)*MAXLINES*2);
	int* cl_len = malloc( sizeof(int));
	load_two(cls_data_file, cls_data, cl_len);
	
	int cl_size = *cl_len;
	
	double cl_raw[cl_size];
	double c_raw[cl_size];
	double pt,clpt;
	
	int i,j;
	
	j=0;
	cl_raw[0] = 0;
	c_raw[0] = 0;
	for (i=0; i<cl_size; i++){
		cl_raw[i] = cls_data[j++];
		c_raw[i] = cls_data[j++]*cl_raw[i]*(cl_raw[i]+1);
// 		printf("%d\t%e\t%e\n", i, cl_raw[i], c_raw[i]);
	}
	
	if (l_values[l_size-1]>cl_raw[cl_size-1]){
		printf("Cls do not contain enough l's, max data %d max cl: %d\n", l_values[l_size-1], (int)cl_raw[cl_size-1]);
		return 1;
		exit;
	}
	
	gsl_spline* spcl =  gsl_spline_alloc (gsl_interp_cspline, cl_size);
	gsl_interp_accel* acccl = gsl_interp_accel_alloc();
	
	gsl_spline_init(spcl,cl_raw,c_raw,cl_size);
	
	for (i=0; i<l_size; i++){
		pt = (double)l_values[i];
		cl[i] = 0;
		if(pt!=0){
			clpt = gsl_spline_eval(spcl,pt,acccl);
			cl[i] = clpt/(pt*(pt+1));
		}
	}
	
	gsl_spline_free(spcl);
	gsl_interp_accel_free(acccl);
	
	return 0;
}
示例#2
0
文件: trento.c 项目: amurtet/pd-dis
void trento_load(t_trento *x, t_symbol *msg, int argc, t_atom *argv)
{
  t_symbol *name1;
  t_symbol *name2;
  x->loadcomplete = 1;
  if(argc!=2) {
    pd_error(x,"load takes 2 arguments, not %d",argc);
    return;
  }
  name1 = atom_getsymbolarg(0,argc,argv);
  name2 = atom_getsymbolarg(1,argc,argv);
  if(!load_two(x,name1,name2))
    return;
  x->loadcomplete = 0;
  x->name1 = name1;
  x->name2 = name2;
}
示例#3
0
void MethodLiveness::BasicBlock::compute_gen_kill_single(ciBytecodeStream *instruction) {
  int localNum;

  // We prohibit _gen and _kill from having locals in common.  If we
  // know that one is definitely going to be applied before the other,
  // we could save some computation time by relaxing this prohibition.

  switch (instruction->cur_bc()) {
    case Bytecodes::_nop:
    case Bytecodes::_goto:
    case Bytecodes::_goto_w:
    case Bytecodes::_aconst_null:
    case Bytecodes::_new:
    case Bytecodes::_iconst_m1:
    case Bytecodes::_iconst_0:
    case Bytecodes::_iconst_1:
    case Bytecodes::_iconst_2:
    case Bytecodes::_iconst_3:
    case Bytecodes::_iconst_4:
    case Bytecodes::_iconst_5:
    case Bytecodes::_fconst_0:
    case Bytecodes::_fconst_1:
    case Bytecodes::_fconst_2:
    case Bytecodes::_bipush:
    case Bytecodes::_sipush:
    case Bytecodes::_lconst_0:
    case Bytecodes::_lconst_1:
    case Bytecodes::_dconst_0:
    case Bytecodes::_dconst_1:
    case Bytecodes::_ldc2_w:
    case Bytecodes::_ldc:
    case Bytecodes::_ldc_w:
    case Bytecodes::_iaload:
    case Bytecodes::_faload:
    case Bytecodes::_baload:
    case Bytecodes::_caload:
    case Bytecodes::_saload:
    case Bytecodes::_laload:
    case Bytecodes::_daload:
    case Bytecodes::_aaload:
    case Bytecodes::_iastore:
    case Bytecodes::_fastore:
    case Bytecodes::_bastore:
    case Bytecodes::_castore:
    case Bytecodes::_sastore:
    case Bytecodes::_lastore:
    case Bytecodes::_dastore:
    case Bytecodes::_aastore:
    case Bytecodes::_pop:
    case Bytecodes::_pop2:
    case Bytecodes::_dup:
    case Bytecodes::_dup_x1:
    case Bytecodes::_dup_x2:
    case Bytecodes::_dup2:
    case Bytecodes::_dup2_x1:
    case Bytecodes::_dup2_x2:
    case Bytecodes::_swap:
    case Bytecodes::_iadd:
    case Bytecodes::_fadd:
    case Bytecodes::_isub:
    case Bytecodes::_fsub:
    case Bytecodes::_imul:
    case Bytecodes::_fmul:
    case Bytecodes::_idiv:
    case Bytecodes::_fdiv:
    case Bytecodes::_irem:
    case Bytecodes::_frem:
    case Bytecodes::_ishl:
    case Bytecodes::_ishr:
    case Bytecodes::_iushr:
    case Bytecodes::_iand:
    case Bytecodes::_ior:
    case Bytecodes::_ixor:
    case Bytecodes::_l2f:
    case Bytecodes::_l2i:
    case Bytecodes::_d2f:
    case Bytecodes::_d2i:
    case Bytecodes::_fcmpl:
    case Bytecodes::_fcmpg:
    case Bytecodes::_ladd:
    case Bytecodes::_dadd:
    case Bytecodes::_lsub:
    case Bytecodes::_dsub:
    case Bytecodes::_lmul:
    case Bytecodes::_dmul:
    case Bytecodes::_ldiv:
    case Bytecodes::_ddiv:
    case Bytecodes::_lrem:
    case Bytecodes::_drem:
    case Bytecodes::_land:
    case Bytecodes::_lor:
    case Bytecodes::_lxor:
    case Bytecodes::_ineg:
    case Bytecodes::_fneg:
    case Bytecodes::_i2f:
    case Bytecodes::_f2i:
    case Bytecodes::_i2c:
    case Bytecodes::_i2s:
    case Bytecodes::_i2b:
    case Bytecodes::_lneg:
    case Bytecodes::_dneg:
    case Bytecodes::_l2d:
    case Bytecodes::_d2l:
    case Bytecodes::_lshl:
    case Bytecodes::_lshr:
    case Bytecodes::_lushr:
    case Bytecodes::_i2l:
    case Bytecodes::_i2d:
    case Bytecodes::_f2l:
    case Bytecodes::_f2d:
    case Bytecodes::_lcmp:
    case Bytecodes::_dcmpl:
    case Bytecodes::_dcmpg:
    case Bytecodes::_ifeq:
    case Bytecodes::_ifne:
    case Bytecodes::_iflt:
    case Bytecodes::_ifge:
    case Bytecodes::_ifgt:
    case Bytecodes::_ifle:
    case Bytecodes::_tableswitch:
    case Bytecodes::_ireturn:
    case Bytecodes::_freturn:
    case Bytecodes::_if_icmpeq:
    case Bytecodes::_if_icmpne:
    case Bytecodes::_if_icmplt:
    case Bytecodes::_if_icmpge:
    case Bytecodes::_if_icmpgt:
    case Bytecodes::_if_icmple:
    case Bytecodes::_lreturn:
    case Bytecodes::_dreturn:
    case Bytecodes::_if_acmpeq:
    case Bytecodes::_if_acmpne:
    case Bytecodes::_jsr:
    case Bytecodes::_jsr_w:
    case Bytecodes::_getstatic:
    case Bytecodes::_putstatic:
    case Bytecodes::_getfield:
    case Bytecodes::_putfield:
    case Bytecodes::_invokevirtual:
    case Bytecodes::_invokespecial:
    case Bytecodes::_invokestatic:
    case Bytecodes::_invokeinterface:
    case Bytecodes::_invokedynamic:
    case Bytecodes::_newarray:
    case Bytecodes::_anewarray:
    case Bytecodes::_checkcast:
    case Bytecodes::_arraylength:
    case Bytecodes::_instanceof:
    case Bytecodes::_athrow:
    case Bytecodes::_areturn:
    case Bytecodes::_monitorenter:
    case Bytecodes::_monitorexit:
    case Bytecodes::_ifnull:
    case Bytecodes::_ifnonnull:
    case Bytecodes::_multianewarray:
    case Bytecodes::_lookupswitch:
      // These bytecodes have no effect on the method's locals.
      break;

    case Bytecodes::_return:
      if (instruction->method()->intrinsic_id() == vmIntrinsics::_Object_init) {
        // return from Object.init implicitly registers a finalizer
        // for the receiver if needed, so keep it alive.
        load_one(0);
      }
      break;


    case Bytecodes::_lload:
    case Bytecodes::_dload:
      load_two(instruction->get_index());
      break;

    case Bytecodes::_lload_0:
    case Bytecodes::_dload_0:
      load_two(0);
      break;

    case Bytecodes::_lload_1:
    case Bytecodes::_dload_1:
      load_two(1);
      break;

    case Bytecodes::_lload_2:
    case Bytecodes::_dload_2:
      load_two(2);
      break;

    case Bytecodes::_lload_3:
    case Bytecodes::_dload_3:
      load_two(3);
      break;

    case Bytecodes::_iload:
    case Bytecodes::_iinc:
    case Bytecodes::_fload:
    case Bytecodes::_aload:
    case Bytecodes::_ret:
      load_one(instruction->get_index());
      break;

    case Bytecodes::_iload_0:
    case Bytecodes::_fload_0:
    case Bytecodes::_aload_0:
      load_one(0);
      break;

    case Bytecodes::_iload_1:
    case Bytecodes::_fload_1:
    case Bytecodes::_aload_1:
      load_one(1);
      break;

    case Bytecodes::_iload_2:
    case Bytecodes::_fload_2:
    case Bytecodes::_aload_2:
      load_one(2);
      break;

    case Bytecodes::_iload_3:
    case Bytecodes::_fload_3:
    case Bytecodes::_aload_3:
      load_one(3);
      break;

    case Bytecodes::_lstore:
    case Bytecodes::_dstore:
      store_two(localNum = instruction->get_index());
      break;

    case Bytecodes::_lstore_0:
    case Bytecodes::_dstore_0:
      store_two(0);
      break;

    case Bytecodes::_lstore_1:
    case Bytecodes::_dstore_1:
      store_two(1);
      break;

    case Bytecodes::_lstore_2:
    case Bytecodes::_dstore_2:
      store_two(2);
      break;

    case Bytecodes::_lstore_3:
    case Bytecodes::_dstore_3:
      store_two(3);
      break;

    case Bytecodes::_istore:
    case Bytecodes::_fstore:
    case Bytecodes::_astore:
      store_one(instruction->get_index());
      break;

    case Bytecodes::_istore_0:
    case Bytecodes::_fstore_0:
    case Bytecodes::_astore_0:
      store_one(0);
      break;

    case Bytecodes::_istore_1:
    case Bytecodes::_fstore_1:
    case Bytecodes::_astore_1:
      store_one(1);
      break;

    case Bytecodes::_istore_2:
    case Bytecodes::_fstore_2:
    case Bytecodes::_astore_2:
      store_one(2);
      break;

    case Bytecodes::_istore_3:
    case Bytecodes::_fstore_3:
    case Bytecodes::_astore_3:
      store_one(3);
      break;

    case Bytecodes::_wide:
      fatal("Iterator should skip this bytecode");
      break;

    default:
      tty->print("unexpected opcode: %d\n", instruction->cur_bc());
      ShouldNotReachHere();
      break;
  }
}
示例#4
0
文件: trento.c 项目: amurtet/pd-dis
void trento_granule(t_trento *x, t_symbol *msg, int argc, t_atom *argv)
{
  t_garray *buf;
  t_word *samples;
  float perc; // percentuage 
  int grainsize; // time for each slice
  int period; // period
  int frames,inc_frames1,inc_frames2;
  int i,j,rnd;
  int nop; // number of periods
  int nos; // number of slices
  float *win; // window
  int overlap; // overlap parameter
  int maxsize; // maxsize for size and period
  int silence; // frames left to silence
  if(argc!=3) {
    pd_error(x,"load takes 3 arguments, not %d",argc);
    return;
  }
  if(x->loadcomplete!=0) {
    pd_error(x,"you have to load before granulate!");
    return;
  }
  perc = atom_getfloatarg(0,argc,argv);
  grainsize = atom_getintarg(1,argc,argv);
  period = atom_getintarg(2,argc,argv);
  if((perc<0.0) || (perc>1.0)) {
    pd_error(x,"perc must be [0,1] instead of %f",perc);
    return;
  }
  if(!attach_array(x))
    return;
  frames = x->b_frames;
  maxsize = frames * 1000 / x->sr;
  if(grainsize<0 || grainsize>maxsize) {
    pd_error(x,"grainsize must be [0,%d] instead of %d",maxsize,grainsize);
    return;
  }
  if(period<0) {
    pd_error(x,"period must be [0,%d] instead of %d",maxsize,period);
    return;
  }
  if(!load_two(x,x->name1,x->name2))
    return;
  if(!clear(x))
    return;
  grainsize *= 0.001*x->sr;
  period *= 0.001*x->sr;
  buf = x->buffy;
  nop = (int) frames / period;
  nos = frames / grainsize;
  samples = x->b_samples;
  inc_frames1 = x->inc_frames1;
  inc_frames2 = x->inc_frames2;
  overlap = period - grainsize;
  win = getbytes(grainsize*sizeof(float));
  for(i=0;i<grainsize;i++)
    win[i] = sin(i*pi/grainsize);
  if(overlap<=0) {
    for(j=0;j<nop;j++) {
      rnd = rand();
      for(i=0;i<grainsize;i++) 
	samples[(j*period+i)%frames].w_float +=
	  win[i]*((1.f-perc)*x->inc_samples1[(rnd+i)%inc_frames1].w_float +
		  perc*x->inc_samples2[(rnd+i)%inc_frames2].w_float);
    }
  }
  else {
    for(j=0;j<nop;j++) {
      rnd = rand();
      silence = rand()%overlap;
      for(i=0;i<period;i++)
	if(i<silence || i>(silence+grainsize))
	  samples[j*period+i].w_float = 0.f;
	else
      	  samples[j*period+i].w_float =
	    win[i-silence]*
	    ((1.f-perc)*x->inc_samples1[(rnd+i)%inc_frames1].w_float +
		    perc*x->inc_samples2[(rnd+i)%inc_frames2].w_float);
    }
  }
  trento_normalize(x);
  garray_redraw(x->buffy);
  x->graincomplete = 0;
  freebytes(win,frames);
}