Beispiel #1
0
func_t *func_expand_mul1_add1(func_t *f)
{
  int i,j,k;
  func_t *h=NULL,*g=NULL;
  if(func_is_mul(f) && func_power(f)==1 && func_a_has_op_pow1(f,func_is_add)){
    // get terms without (add)^1
    g=func_clone(FR(f));
    func_args_rm_add_pow1(g);
    func_a_rm_null(g);
    g=func_mul_eval(g);
    // loop
    for(i=0; i<func_asize(f); i++){
      if(func_is_add(f->a[i]) && func_power(f->a[i])==1){
	if(func_is_add(g) && func_power(g)==1){
	  h=func_zero();
	  for(k=0; k<func_asize(g); k++){
	    for(j=0; j<func_asize(f->a[i]); j++){
	      h=func_add(h,func_expand(func_mul(FR(g->a[k]),FR(f->a[i]->a[j]))));
	    }
	  }
	}else{	  
	  h=func_zero();
	  for(j=0; j<func_asize(f->a[i]); j++){
	    h=func_add(h,func_expand(func_mul(FR(g),FR(f->a[i]->a[j]))));
	  }
	}
	g=func_del(g); g=h; h=NULL;
      }
    }
  }else{ FUNC_ERROR_ARG1("func_expand_mul1_add1",f); }
  f=func_del(f);
  return g;
}
Beispiel #2
0
void FindFuncsLT(){
	TGraph * FNegvsLT = new TGraph();
    FNegvsLT->SetName("FNegvsLT");
	double par[3] = {mtop, MW, mB};
	for(int i = 0; i<1000; i++){
	    double x[4] = {1, 0, i*0.001, 0};
		cout<<x[1]<<"\t"<<FNeg(x, par)<<endl;
		FNegvsLT->SetPoint(i, (i*0.001), FNeg(x, par));
	}
	FNegvsLT->SaveAs("FNegvsLT.C");

	TGraph * FPosvsLT = new TGraph();
    FPosvsLT->SetName("FPosvsLT");
	for(int i = 0; i<1000; i++){
	    double x[4] = {1, 0, i*0.001, 0};
		cout<<x[1]<<"\t"<<FR(x, par)<<endl;
		FPosvsLT->SetPoint(i, (i*0.001), FR(x, par));
	}
	FPosvsLT->SaveAs("FPosvsLT.C");



	TGraph * FZerovsLT = new TGraph();
    FZerovsLT->SetName("FZerovsLT");
	for(int i = 0; i<1000; i++){
	    double x[4] = {1, 0, i*0.001, 0};
		cout<<x[1]<<"\t"<<FZero(x, par)<<endl;
		FZerovsLT->SetPoint(i, (i*0.001), FZero(x, par));
	}
	FZerovsLT->SaveAs("FZerovsLT.C");
}
Beispiel #3
0
func_t *func_diff_tanh_pow1(func_t *f, int var)
{
  func_t *fx=NULL,*g=NULL,*gx=NULL;
  if(!func_is(f,"tanh") || func_power(f)!=1){ FUNC_ERROR_ARG1("func_diff_tanh",f); }
  g=f->a[0];
  gx=func_diff(FR(g),func_var1(var,1));
  fx=func_mul(func_pow_n(func_cosh(FR(g)),-2),gx);
  f=func_del(f);
  return fx;
}
Beispiel #4
0
func_t *func_diff_cos_pow1(func_t *f, int var)
{
  func_t *fx=NULL,*g=NULL,*gx=NULL;
  if(!func_is(f,"cos") || func_power(f)!=1){ FUNC_ERROR_ARG1("func_diff_cos",f); }
  g=f->a[0];
  gx=func_diff(FR(g),func_var1(var,1));
  fx=func_mul(func_mul(func_sin(FR(g)),func_bigint_int(-1,1)),gx);
  f=func_del(f);
  return fx;
}
Beispiel #5
0
func_t *func_diff_log_pow1(func_t *f, int var)
{
  func_t *fx=NULL,*g=NULL,*gx=NULL;
  if(!func_is(f,"log") || func_power(f)!=1){ FUNC_ERROR_ARG1("func_diff_log",f); }
  g=f->a[0];
  gx=func_diff(FR(g),func_var1(var,1));
  fx=func_div(gx,FR(g));
  f=func_del(f);
  return fx;
}
Beispiel #6
0
//h={q,r}
func_t *func_poly_div_r_and_q(func_t *f, func_t *g)
{
  func_t *h=NULL;
  h=func_list(2);
  h->a[0]=func_poly_div_q(FR(f),FR(g));
  h->a[1]=func_poly_div_r(FR(f),FR(g));
  f=func_del(f);
  g=func_del(g);
  return h;
}
Beispiel #7
0
func_t *func_diff_sqrt_pow1(func_t *f, int var)
{
  func_t *fx=NULL,*g=NULL,*gx=NULL;
  if(!func_is(f,"sqrt") || func_power(f)!=1){ FUNC_ERROR_ARG1("func_diff_sqrt",f); }
  g=f->a[0];
  gx=func_diff(FR(g),func_var1(var,1));
  fx=func_mul(func_div(gx,func_sqrt(FR(g))),func_bigint_int(1,2));
  f=func_del(f);
  return fx;
}
Beispiel #8
0
void func_add_args_collect(func_t *f, func_is_t *fis)
{
  int i,j;
  func_t *g=NULL;
  if(!func_is_add(f)){ FUNC_ERROR_ARG1("func_add_args_collect",f); }
  // convert args to split list
  for(i=0; i<func_asize(f); i++){
    g=func_mul_split_list(FR(func_aget(f,i)),fis);
    func_aset(f,i,FR(g));
    g=func_del(g);
  }
  // add a arg to same arg
  for(i=0; i<func_asize(f); i++){
    for(j=i+1; func_aget(f,i)!=NULL && !func_is_one(func_aget(func_aget(f,i),1)) && j<func_asize(f); j++){
      if(func_aget(f,j)!=NULL && func_cmp(func_aget(func_aget(f,i),1),func_aget(func_aget(f,j),1))==0){
	g=func_list(2);
	func_aset(g,0,func_add(FR(func_aget(func_aget(f,i),0)),FR(func_aget(func_aget(f,j),0))));
	func_aset(g,1,FR(func_aget(func_aget(f,i),1)));
	func_aset(f,i,FR(g));
	func_adel(f,j);
	g=func_del(g);
      }
    }
  }
  // convert list to mul
  for(i=0; i<func_asize(f); i++){
    if(func_aget(f,i)!=NULL){
      g=func_mul(FR(func_aget(func_aget(f,i),0)),FR(func_aget(func_aget(f,i),1)));
      func_aset(f,i,FR(g));
      g=func_del(g);
    }
  }
  func_a_rm_null(f);
}
Beispiel #9
0
func_t *func_poly_clone_coeff_ntarm(func_t *f,int n)
{
  func_t *a;
  if(!func_is_poly(f)){ return NULL; }
  a=func_poly_get_mono_ntarm(f,n);
  if(a==NULL){ return func_zero(); }
  if(func_is_number(a)){ return func_clone(FR(a)); }
  a=func_mono_get_coeff(a);
  if(a==NULL){ return func_one(); }
  return func_clone(FR(a));
}
Beispiel #10
0
func_t *func_diff_atanh_pow1(func_t *f, int var)
{
  func_t *fx=NULL,*g=NULL,*gx=NULL,*h=NULL;
  if(!func_is(f,"atanh") || func_power(f)!=1){ FUNC_ERROR_ARG1("func_diff_atanh",f); }
  g=f->a[0];
  gx=func_diff(FR(g),func_var1(var,1));
  h=func_pow_n(FR(g),2);
  h=func_sub(func_one(),h);
  fx=func_div(gx,h);
  f=func_del(f);
  return fx;
}
Beispiel #11
0
void func_a_insert(func_t *f, int n, func_t *g)
{
  int i,k;
  func_t **a;
  if(f==NULL){ FUNC_ERROR_ARG1("func_a_insert",f); }
  a=(func_t**)malloc(sizeof(func_t*)*(func_asize(f)+1));
  for(k=0,i=0; k<func_asize(f)+1; ){
    if(i==n){ a[k++]=g; a[k++]=FR(f->a[i++]); }
    else    { a[k++]=FR(f->a[i++]); }
  }
  func_a_replace(f,func_asize(f)+1,a);
}
Beispiel #12
0
func_t *func_poly_list_monic(func_t *f)
{
  int i;
  func_t *g=NULL;
  if(!(func_is_poly_list(f))){ FUNC_ERROR_ARG1("func_poly_list_monic",f); }
  g=func_clone(FR(f));
  for(i=0; i<func_asize(g); i++){
    func_aset(g,i,func_poly_monic(FR(g->a[i])));
  }
  f=func_del(f);
  return g;
}
Beispiel #13
0
func_t *func_diff_acosh_pow1(func_t *f, int var)
{
  func_t *fx=NULL,*g=NULL,*gx=NULL,*h=NULL;
  if(!func_is(f,"acosh") || func_power(f)!=1){ FUNC_ERROR_ARG1("func_diff_acosh",f); }
  g=f->a[0];
  gx=func_diff(FR(g),func_var1(var,1));
  h=func_pow_n(FR(g),2);
  h=func_add(h,func_bigint_int(-1,1));
  h=func_sqrt(h);
  fx=func_div(gx,h);
  f=func_del(f);
  return fx;
}
Beispiel #14
0
void func_add_args(func_t *f, func_is_t *fis, func_is_t *fin)
{
  int i,j;
  if(!func_is_add(f)){ FUNC_ERROR_ARG1("func_add_args",f); }
  for(i=0; i<func_asize(f); i++){
    for(j=0; fis(func_aget(f,i)) && j<func_asize(f); j++){
      if(i!=j && fin(func_aget(f,j))){
        func_aset(f,i,func_add(FR(func_aget(f,i)),FR(func_aget(f,j))));
	func_adel(f,j);
      }
    }
  }
  func_a_rm_null(f);
}
Beispiel #15
0
Enemy::Enemy(LPCWSTR _meshName, LPCWSTR _textureName, LPCWSTR _normalTexName,
	char* _attackSound, char* _deathSound, char* _getHitSound,
	D3DXVECTOR3 _startPosition, float _healthMax, float _radius, D3DXVECTOR3 _meshScale) :
	Follower(_meshName, _textureName, _normalTexName, _startPosition, _healthMax,
	_radius, _meshScale), mLoseSightPlayer(10.0f), mLoseSightFollower(10.0f)
{
	mState = PSTATE_WANDER;
	// TODO BUG: As far as I know, this is causing a memory every time an enemy is created
	FR(gSound->getSystem()->createSound(_attackSound, FMOD_DEFAULT, 0, &enemyAttack));
	FR(gSound->getSystem()->createSound(_deathSound, FMOD_DEFAULT, 0, &enemyDeath));
	FR(gSound->getSystem()->createSound(_getHitSound, FMOD_DEFAULT, 0, &enemyGetHit));
	// TODO: this needs to be moved to a point where the enemy begins to move or is still
	bIsMoving = true;
}
Beispiel #16
0
func_t *func_diff_pow_n(func_t *f, int var)
{
  func_t *fx=NULL,*g=NULL;
  if(!func_has_power(f) || func_power(f)==1){ FUNC_ERROR_ARG1("func_diff_pow_n",f); }
  g=func_clone(FR(f));
  func_set_power(g,1);
  g=func_diff(g,func_var1(var,1));
  fx=func_clone(FR(f));
  func_set_power(fx,func_power(fx)-1);
  fx=func_mul(func_bigint_int(func_power(f),1),fx);
  fx=func_mul(fx,g);
  f=func_del(f);
  return fx;
}
Beispiel #17
0
func_t *func_diff_mul_pow1(func_t *f, int var)
{
  int i;
  func_t *fx=NULL,*g=NULL;
  if(!func_is_mul(f) || func_power(f)!=1){ FUNC_ERROR_ARG1("func_diff_mul",f); }
  fx=func_zero();
  for(i=0; i<func_asize(f); i++){
    g=func_clone(FR(f));
    g->a[i]=func_del(g->a[i]);
    g=func_mul_eval(g);
    fx=func_add(fx,func_mul(g,func_diff(FR(f->a[i]),func_var1(var,1))));
  }
  f=func_del(f);
  return fx;
}
Beispiel #18
0
void lapackglue_geev(char jobvl, char jobvr, int n,
                     scalar *A, int fdA, scalar_complex *w,
                     scalar *VL, int fdVL, scalar *VR, int fdVR,
		     scalar *work, int lwork, real *rwork)
{
     int info;

#ifdef SCALAR_COMPLEX
     F(geev,GEEV) (&jobvl, &jobvr, &n, A, &fdA, w, VL, &fdVL, VR, &fdVR,
                   work, &lwork, rwork, &info);
#else
     int i;
     real *wr, *wi;
     CHK_MALLOC(wr, real, 2*n);
     wi = wr + n;
     (void) rwork; /* unused */
     FR(geev,GEEV) (&jobvl, &jobvr, &n, A, &fdA, wr, wi, VL, &fdVL, VR, &fdVR,
                   work, &lwork, &info);
     for (i = 0; i < n; ++i)
         CASSIGN_SCALAR(w[i], wr[i], wi[i]);
     free(wr);
#endif
     CHECK(info >= 0, "invalid argument in geev");
     CHECK(info <= 0, "failure to converge in geev");
}
Beispiel #19
0
Player::Player(LPCWSTR _meshName, LPCWSTR _textureName, LPCWSTR _normalTexName, 
	D3DXVECTOR3 _startPosition, float _healthMax, float _radius, D3DXVECTOR3 _meshScale) :
	Pawn(_meshName, _textureName, _normalTexName, _startPosition, _healthMax, _radius,
	_meshScale), 
	//starting with full ammo here, but that won't be the case in the actual game
	mAmmoSeeds(0), mAmmoSeedsMax(100), mAmmoFire(0), mAmmoFireMax(100), mScore(0),
	mLeftAttack(A_MELEE), mRightAttack(A_SEED)
{
	mSpeed = 400.0f;
	mAttackDelay = 0.9f;

	FR(gSound->getSystem()->createSound("Content/Audio/sndPlayerAttackFire.wav", FMOD_DEFAULT, 0, &playerAttackFire));
	FR(gSound->getSystem()->createSound("Content/Audio/sndPlayerAttackMelee.wav", FMOD_DEFAULT, 0, &playerAttackMelee));
	FR(gSound->getSystem()->createSound("Content/Audio/sndPlayerAttackSeed.wav", FMOD_DEFAULT, 0, &playerAttackSeed));
	FR(gSound->getSystem()->createSound("Content/Audio/sndPlayerDeath.wav", FMOD_DEFAULT, 0, &playerDeath)); //(for later use)
}
Beispiel #20
0
void GEMENI_charsent() {
	unsigned long r = s->log[s->lc];
	if (UCA0IFG & UCTXIFG) {
		s->nch++;
		switch (s->nch) {
			case 1:
				UCA0TXBUF = SL(r) << 5 |TL(r)<<4|KL(r)<<3|PL(r)<<2|WL(r)<<1|HL(r);
			break;
			case 2:
				UCA0TXBUF = RL(r)<<6 | AL(r)<<5 | OL(r)<<4 | STAR(r)<<3;
			break;
			case 3:
				UCA0TXBUF = ER(r)<<3 | UR(r)<<2 | FR(r)<<1 | RR(r);
			break;
			case 4:
				UCA0TXBUF = PR(r)<<6 | BR(r)<<5 | LR(r)<<4 | GR(r)<<3 | TR(r)<<2 | SR(r)<<1 | DRS(r);
			break;
			case 5:
				UCA0TXBUF = POUND(r)<<1 | ZRS(r);
			break;
			default:
				s->lc++;
				if (s->lc != s->nc-1) {

  					s->nch = 0;
  					UCA0TXBUF = 1 << 7; // first packet, no fn or '#'
				} else {
					s->flags &= ~CSEND;
				}

		}
	}
}
Beispiel #21
0
func_t *func_poly_monic(func_t *f)
{
  func_t *a=NULL;
  if(!(func_is_poly(f))){ FUNC_ERROR_ARG1("func_poly_monic",f); }
  a=func_poly_get_lc(f);
  if(a==NULL || func_is_one(a)){ return f; }  
  return func_expand(func_mul(func_inv(FR(a)),f));
}
Beispiel #22
0
func_t *func_set_eval(func_t *f)
{
  func_init();
  if(f==NULL || !func_is(f,"set") || func_asize(f)!=1){ FUNC_ERROR_ARG1("func_set_eval",f); }
  func_scope_set(0,FR(func_aget(f,0)));
  f=func_del(f);
  return f;
}
Beispiel #23
0
func_t *func_poly_lm_lcm(func_t *f, func_t *g)
{
  func_t *lcm=NULL,*f_lm=NULL,*g_lm=NULL;
  if(func_is_poly(f) && func_is_poly(g)){
    f_lm=func_poly_get_lm(f);
    g_lm=func_poly_get_lm(g);
    if     (f_lm!=NULL && g_lm!=NULL) { lcm=func_var_lcm(FR(f_lm),FR(g_lm)); }
    else if(f_lm==NULL && g_lm!=NULL) { lcm=FR(g_lm); }
    else if(f_lm!=NULL && g_lm==NULL) { lcm=FR(f_lm); }
    else                              { lcm=func_one(); }
  }
  f_lm=NULL;
  g_lm=NULL;
  f=func_del(f);
  g=func_del(g);
  return lcm;
}
Beispiel #24
0
func_t *func_def_any_eval(func_t *f)
{
  int i;
  func_t *g=NULL,*x=NULL;
  g=func_scope_find(0,func_op(f));
  if(func_is_def(g) && func_aget(g,0)!=NULL){
    g=FR(func_aget(g,0));
    if(func_asize(f)>0){
      x=func_list(func_asize(f));
      for(i=0; i<func_asize(f); i++){ func_aset(x,i,FR(func_aget(f,i))); }
      g=func_maps(g,0,FR(x));
    }
    f=func_del(f);
  }else{ g=f; }
  x=func_del(x);
  return g;
}
Beispiel #25
0
func_t *func_begin_eval(func_t *f)
{
  func_init();
  if      (f==NULL || !func_is(f,"begin"))                    { FUNC_ERROR_ARG1("func_begin_eval",f); }
  else if(func_asize(f)==0)                                   { func_scope_begin(NULL);        f=func_del(f); }
  else if(func_asize(f)==1 && func_is_strings(func_aget(f,0))){ func_scope_begin(FR(f->a[0])); f=func_del(f); }
  return f;
}
Beispiel #26
0
void Instruction::output_arglist(ofstream &fout)
{
  fout<<arglist.size()<<endl;
  FR(i,arglist)
    fout<<i->first<<' '<<i->second<<endl;
  // for(int i=0;i<arglist.size();++i)
  //   fout<<arglist[i].first<<' '<<arglist[i].second<<endl;
}
Beispiel #27
0
void func_args_arrange(func_t *f, int *I)
{
  int i,n;
  func_t **arg=NULL;
  n=func_asize(f);
  arg=(func_t**)malloc(sizeof(func_t*)*n);
  for(i=0; i<n; i++){ arg[i]=FR(f->a[I[i]]); }
  func_a_replace(f,n,arg);
}
Beispiel #28
0
void func_cvec_set(func_t *f, int i, func_t *g)
{
  func_t *a=NULL;
  if(f==NULL || func_ptype(f)!=FUNC_P_CVEC || f->p.rvec==NULL || i<0 || i>=f->p.rvec->n){ FUNC_ERROR_ARG2("func_cvec_set",f,g); }
  a=func_evalf(FR(g));
  if(func_is_real(a))        { ccopy_r(func_cvec_at(f,i),func_real_p(a)); }
  else if(func_is_complex(a)){ ccopy  (func_cvec_at(f,i),func_complex_p(a)); }
  else                       { FUNC_ERROR_ARG2("func_cvec_set",f,g); }
  a=func_del(a);
}
Beispiel #29
0
func_t *func_expand_add_pow_n(func_t *f)
{
  int i,j,k;
  func_t *g=NULL,*h=NULL;
  if(func_is_add(f) && func_power(f)>=2){
    g=func_clone(FR(f)); func_set_power(g,1);
    for(k=1; k<func_power(f); k++){
      h=func_zero();
      for(i=0; i<func_asize(g); i++){	
	for(j=0; j<func_asize(f); j++){
	  h=func_add(h,func_expand(func_mul(FR(g->a[i]),FR(f->a[j]))));
	}
      }
      g=func_del(g); g=h; h=NULL;
    }
  }else{ FUNC_ERROR_ARG1("func_expand_add_pow_n",f); }
  f=func_del(f);
  return g;
}
Beispiel #30
0
// r=mod(f,g), where f=g*q+r
func_t *func_poly_div_r(func_t *f, func_t *g)
{
  func_t *r=NULL,*neg=NULL,*a;
  if(func_is_poly(f) && func_is_poly(g)){
    neg=func_bigint_int(-1,1);
    r=FR(f);                                    // r=f
    while(func_is_poly(r) && func_poly_can_div(r,g)) {
      a=func_div(FR(func_poly_get_lt(r)),
		 FR(func_poly_get_lt(g))); // a=LT(r)/LT(g)
      a=func_mul(FR(neg),a);                    // a=(-1)*LT(r)/LT(g)
      a=func_expand(func_mul(a,FR(g)));         // a=((-1)*LT(r)/LT(g))*g
      r=func_add(r,a);                                   // r-=(LT(r)/LT(g))*g
    }
  }
  f=func_del(f);
  g=func_del(g);
  neg=func_del(neg);
  return r;
}