示例#1
0
文件: factor.c 项目: d4g33z/lie
object Factor(bigint* num)
{ num=copybigint(num,NULL); 
  if (num->size<0) { Printf("- "); num->size=-num->size; }
  { bigint* temp=mkbigint(num->size); _digit p; int i=0;
    if (num->size==0) { Printf("0"); goto quit; }
    for (p=2; p<=trial_limit; p+= inc[i++])
    { if (i==array_size(inc)) i=3; /* after |37-31| wrap to difference |11-7| */
      
      if (copybigint(num,temp),div1(temp,p)==0)
      { _index n; _digit pn=p; int e=1;  copybigint(temp,num);
        for (n=1; pn<=MaxDigit/p; ++n) pn*=p; /* highest $p^n$ fitting in |_digit| */
        for (; div1(temp,pn)==0; e+=n) copybigint(temp,num);
          /* find factors $p^n$ */
        if (n>1) /* then there might be some factors |p| left */
          for (copybigint(num,temp); div1(temp,p)==0; ++e) copybigint(temp,num);
            /* factors |p| */
        Printf("%ld",(long)p);  if (e>1) Printf("^%ld",(long)e);
        if (cmp1(num,1)==0) goto quit; /* last factor was found */
        Printf(" * ");
      }
    }
    printbigint(num,0); 
    if (num->size>2) Printf(" (Last factor need not be a prime)");
  quit:  Printf("\n");
    freemem(num); freemem(temp);
  }
  return (object) NULL;
}
示例#2
0
文件: symg.c 项目: nhatcher/lie
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
文件: 10428.c 项目: DavidToca/acm
int main()
{
	double r[16], x[16];
	poly_t p;
	int i, k, n, t;

	srand(53387);

	for (t = 1; scanf("%d", &n) == 1 && n > 0; t++) {
		for (i = p.n = n; i >= 0; i--)
			scanf("%lf", &p.a[i]);

		for (k = 0; k < n && (i = find(&p, x)) > 0;)
			while (i-- > 0)
				div1(&p, r[k++] = x[i]);

		qsort(r, k, sizeof(r[0]), &compare);

		printf("Equation %d:", t);
		for (i = 0; i < k; i++)
			printf(" %.4f", r[i]);
		printf("\n");
	}

	return 0;
}
示例#4
0
int main ()
{
  if (div1 (-(1 << 7)) != 1 << 7)
    abort ();
  if (div2 (-(1 << 15)) != 1 << 15)
    abort ();
  if (div3 (-(1 << 7), -1) != 1 << 7)
    abort ();
  if (div4 (-(1 << 15), -1) != 1 << 15)
    abort ();
  if (mod1 (-(1 << 7)) != 0)
    abort ();
  if (mod2 (-(1 << 15)) != 0)
    abort ();
  if (mod3 (-(1 << 7), -1) != 0)
    abort ();
  if (mod4 (-(1 << 15), -1) != 0)
    abort ();
  if (mod5 (0x50000000, 2) != 0)
    abort ();
  if (mod6 (0x50000000, 2) != 0)
    abort ();
  
  exit (0);
}
示例#5
0
文件: symg.c 项目: nhatcher/lie
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;
}