bridge/class-master/depend/pari/src/basemath/arith1.c
/* a,b given by their factorizations. Return factorization of lcm(a,b).
 * Set A,B such that A*B = lcm(a, b), (A,B)=1, A|a, B|b */
a,b given by their factorizations.
a b given by their factorizations .
static GEN
split_lcm(GEN a, GEN Fa, GEN b, GEN Fb, GEN *pA, GEN *pB)
{
  GEN P = ZC_union_shallow(gel(Fa,1), gel(Fb,1));
  GEN A = gen_1, B = gen_1;
  long i, l = lg(P);
  GEN E = cgetg(l, t_COL);
  for (i=1; i<l; i++)
  {
    GEN p = gel(P,i);
    long va = Z_pval(a,p);
    long vb = Z_pval(b,p);
    if (va < vb)
    {
      B = mulii(B,powiu(p,vb));
      gel(E,i) = utoi(vb);
    }
    else
    {
      A = mulii(A,powiu(p,va));
      gel(E,i) = utoi(va);
    }
  }
  *pA = A;
  *pB = B; return mkmat2(P,E);
}
static GEN split_lcm ( GEN a , GEN Fa , GEN b , GEN Fb , GEN * pA , GEN * pB ) { GEN P = ZC_union_shallow ( gel ( Fa , 1 ) , gel ( Fb , 1 ) ) ; GEN A = gen_1 , B = gen_1 ; long i , l = lg ( P ) ; GEN E = cgetg ( l , t_COL ) ; for ( i = 1 ; i < l ; i ++ ) { GEN p = gel ( P , i ) ; long va = Z_pval ( a , p ) ; long vb = Z_pval ( b , p ) ; if ( va < vb ) { B = mulii ( B , powiu ( p , vb ) ) ; gel ( E , i ) = utoi ( vb ) ; } else { A = mulii ( A , powiu ( p , va ) ) ; gel ( E , i ) = utoi ( va ) ; } } * pA = A ; * pB = B ; return mkmat2 ( P , E ) ; }
a,b given by their factorizations.
a b given by their factorizations .