Пример #1
0
void MeshNode::UpdateWorldBounds(){
	if(!initialized)	
		return;
		
	worldBounds_.center = mul1(transform_, mesh_->localBounds.center);
	float x, y, z;
	ExtractScaling(transform_,x,y,z);
	worldBounds_.radius = mesh_->localBounds.radius * max(max(x,y),z);
}
Пример #2
0
bigint* Classord(entry* kappa, lie_Index l)
{ lie_Index prev=0,i=0,j,n=0,k,f=1; bigint* x=copybigint(one,NULL);
  while (i<l && (k=kappa[i++])>0)
  { for (j=0; j<k; ++j) x=mul1(x,++n);
      /* extend $\Card\kappa!$ in numerator */
    div1(x,k); /* contribution to $k^{c_k(\kappa)}$ in denominator */
    if (k!=prev) { f=1; prev=k;}  /* this case applies the first time */
    else div1(x,++f); /* contribution to $c_k(\kappa)!$  in denominator */
  }
  return x;
}
Пример #3
0
bigint* n_tableaux(entry* lambda, lie_Index l)
{ lie_Index i,j,k=0; entry* h; bigint* res=copybigint(one,NULL);
  do  if (--l<=0) return one; 
  while (lambda[l]==0); /* find last non-zero part */
  h=mkintarray(lambda[0]); 
  for(j=0; j<lambda[0]; ++j) h[j]=0; /* accumulated column heigths */
  for(i=l; i>=0; --i)
    
    { entry li=lambda[i]-1;
      for(j=0; j<=li; ++j) res=mul1(res,++k); /* part of factorial */
      for(j=0; j<=li; ++j) div1(res,(++h[j])+li-j); /* divide by hook lengths */
    }
  freearr(h); return res;
}
Пример #4
0
num treenum(ll i){
  num res,t;
  res.a[0]=0;
  res.a[1]=0;
  t.a[0]=0;
  t.a[1]=1;
  while(i!=0){
    if(i%2==1){
      res=add(&res,&t);
    }
    t=mul1(&t,3);
    i/=2;
  }
  return res;
}
Пример #5
0
void test_vector_ifft() {
	logMsg("playing IFFT crossfade...");
	IFFT vox1, vox2;

	vox1.set_bin_mag_phase(2, 0.25, 0);
	vox1.set_bin_mag_phase(4, 0.25, 0);
	vox2.set_bin_mag_phase(6, 0.25, 0);
	vox2.set_bin_mag_phase(8, 0.25, 0);
	LineSegment env1(3, 1, 0);	// fade out
	LineSegment env2(3, 0, 1);	// fade in
	MulOp mul1(vox1, env1);	
	MulOp mul2(vox2, env2);
	AddOp add3(mul1, mul2);	
	run_test(add3);
	logMsg("IFFT crossfade done.");
}
Пример #6
0
local bigint* simp_worder(bigint* num, simpgrp* g)
{ lie_Index i,r=g->lierank; bigint* result=num;

  i=r;  while (i>1) result=mul1(result,i--);
  switch (g->lietype)
  {	 case 'A':  result=mul1(result,r+1); 
  break; case 'B':
	 case 'C':  for (i=0; i<r; ++i) result = mul1(result,2); 
  break; case 'D':  for (i=1; i<r; ++i) result = mul1(result,2); 
  break; case 'E':  result = mul1(result,r==6 ? 72 : r==7 ? 576 : 17280); 
  break; case 'F':  result = mul1(result,48); 
  break; case 'G':  result = mul1(result,6);
  }
  return result;
}
Пример #7
0
/* Sum of digits of 1000! */
void eu020(char *ans) {
  const int N = 100;
  char fact[1000];

  memset(fact, 0, sizeof(fact));
  fact[0] = 1;

  for (int i = 2; i < N; i++) {
    mul1(fact, i, 1000);
  }

  int t = 0;
  for (int i = 0; i < 1000; i++) {
    t += fact[i];
  }
  sprintf(ans, "%d", t);
}
Пример #8
0
void test_mixer_with_sines() {
	Sine vox1(431);				// create 4 scaled sine waves
	MulOp mul1(vox1, 0.3);
	Sine vox2(540);
	MulOp mul2(vox2, 0.1);
	Sine vox3(890);
	MulOp mul3(vox3, 0.3);
	Sine vox4(1280);
	MulOp mul4(vox4, 0.01);
	Mixer mix(2);				// create a stereo mixer
	mix.add_input(mul1);			// add them to the mixer
	mix.add_input(mul2);
	mix.add_input(mul3);
	mix.add_input(mul4);
	logMsg("playing mix of 4 sines...");
	run_test(mix);
	logMsg("mix done.");
}
Пример #9
0
void CVisVector::CrossProd( const CVisVector & v1, const CVisVector & v2 )
{
    CVisEqualFixpoint mul1( MTRX_FRACTBITS );
    CVisEqualFixpoint mul2( MTRX_FRACTBITS );

    mul1.Mult( v1.m_fparyStore[1], v2.m_fparyStore[2] );
    mul2.Mult( v1.m_fparyStore[2], v2.m_fparyStore[1] );
    m_fparyStore[0].Sub(  mul1, mul2 );

    mul1.Mult( v1.m_fparyStore[2], v2.m_fparyStore[0] );
    mul2.Mult( v1.m_fparyStore[0], v2.m_fparyStore[2] );
    m_fparyStore[1].Sub(  mul1, mul2 );

    mul1.Mult( v1.m_fparyStore[0], v2.m_fparyStore[1] );
    mul2.Mult( v1.m_fparyStore[1], v2.m_fparyStore[0] );
    m_fparyStore[2].Sub(  mul1, mul2 );

    m_fparyStore[3] = 0;
}
Пример #10
0
bigint* fac(lie_Index n)
{ bigint* f=copybigint(one,NULL); while (n>1) f=mul1(f,n--); return f; }
Пример #11
0
 virtual void exec()
 {
   USE(READ, n, tsteps);
   T DX(static_cast<T>(1.0) / n);
   T DY(static_cast<T>(1.0) / n);
   T DT(static_cast<T>(1.0) / tsteps);
   T B1(static_cast<T>(2.0));
   T B2(static_cast<T>(1.0));
   T mul1(B1 * DT / (DX * DX));
   T mul2(B2 * DT / (DY * DY));
   T a(-mul1 / static_cast<T>(2.0));
   T b(static_cast<T>(1.0) + mul1);
   T c(a);
   T d(-mul2 / static_cast<T>(2.0));
   T e(static_cast<T>(1.0) + mul2);
   T f(d);
   USE(READWRITE, v, u, p, q);
   using exec_pol = NestedPolicy<ExecList<omp_parallel_for_exec, simd_exec>,
                                 Tile<TileList<tile_fixed<16>, tile_none>>>;
   for (int t = 0; t < tsteps; ++t) {
     forall<omp_parallel_for_exec>(1, n - 1, [=](int i) {
       v->at(0, i) = static_cast<T>(1.0);
       p->at(i, 0) = static_cast<T>(0.0);
       q->at(i, 0) = v->at(0, i);
       v->at(n - 1, i) = static_cast<T>(1.0);
     });
     forallN<exec_pol>(
       RangeSegment{1, n - 1},
       RangeSegment{1, n - 1},
       [=](int i, int j) {
         p->at(i, j) = -c / (a * p->at(i, j - 1) + b);
         q->at(i, j) = (-d * u->at(j, i - 1) + (1.0 + 2.0 * d) * u->at(j, i)
                        - f * u->at(j, i + 1)
                        - a * q->at(i, j - 1))
                       / (a * p->at(i, j - 1) + b);
       });
     forallN<exec_pol>(
       RangeSegment{1, n - 1},
       RangeSegment{2, n},
       [=](int i, int j_) {
         int j = n - j_;
         v->at(j, i) = p->at(i, j) * v->at(j + 1, i) + q->at(i, j);
       });
     forall<omp_parallel_for_exec>(1, n - 1, [=](int i) {
       u->at(i, 0) = static_cast<T>(1.0);
       p->at(i, 0) = static_cast<T>(0.0);
       q->at(i, 0) = u->at(i, 0);
       u->at(i, n - 1) = static_cast<T>(1.0);
     });
     forallN<exec_pol>(
       RangeSegment{1, n - 1},
       RangeSegment{1, n - 1},
       [=](int i, int j) {
         p->at(i, j) = -f / (d * p->at(i, j - 1) + e);
         q->at(i, j) =
           (-a * v->at(i - 1, j)
            + (static_cast<T>(1.0) + static_cast<T>(2.0) * a) * v->at(i, j)
            - c * v->at(i + 1, j)
            - d * q->at(i, j - 1))
           / (d * p->at(i, j - 1) + e);
       });
     forallN<exec_pol>(
       RangeSegment{1, n - 1},
       RangeSegment{2, n},
       [=](int i, int j_) {
         int j = n - j_;
         u->at(i, j) = p->at(i, j) * u->at(i, j + 1) + q->at(i, j);
       });
   }
 }