bridge/class-master/depend/pari/src/basemath/base3.c
/* product of x and y in nf */
product of x and y in nf
product of x and y in nf
GEN
nfmul(GEN nf, GEN x, GEN y)
{
  GEN z;
  pari_sp av = avma;
  if (x == y) return nfsqr(nf,x);
  nf = checknf(nf);
  x = nf_to_scalar_or_basis(nf, x);
  y = nf_to_scalar_or_basis(nf, y);
  if (typ(x) != t_COL)
  {
    if (isintzero(x)) return gen_0;
    z = (typ(y) == t_COL)? RgC_Rg_mul(y, x): gmul(x,y); }
  else
  {
    if (typ(y) != t_COL)
    {
      if (isintzero(y)) return gen_0;
      z = RgC_Rg_mul(x, y);
    }
    else
    {
      GEN dx, dy;
      x = Q_remove_denom(x, &dx);
      y = Q_remove_denom(y, &dy);
      z = nfmuli(nf,x,y);
      dx = mul_denom(dx,dy);
      if (dx) z = ZC_Z_div(z, dx);
    }
  }
  return gerepileupto(av, z);
}
GEN nfmul ( GEN nf , GEN x , GEN y ) { GEN z ; pari_sp av = avma ; if ( x == y ) return nfsqr ( nf , x ) ; nf = checknf ( nf ) ; x = nf_to_scalar_or_basis ( nf , x ) ; y = nf_to_scalar_or_basis ( nf , y ) ; if ( typ ( x ) != t_COL ) { if ( isintzero ( x ) ) return gen_0 ; z = ( typ ( y ) == t_COL ) ? RgC_Rg_mul ( y , x ) : gmul ( x , y ) ; } else { if ( typ ( y ) != t_COL ) { if ( isintzero ( y ) ) return gen_0 ; z = RgC_Rg_mul ( x , y ) ; } else { GEN dx , dy ; x = Q_remove_denom ( x , & dx ) ; y = Q_remove_denom ( y , & dy ) ; z = nfmuli ( nf , x , y ) ; dx = mul_denom ( dx , dy ) ; if ( dx ) z = ZC_Z_div ( z , dx ) ; } } return gerepileupto ( av , z ) ; }
product of x and y in nf
product of x and y in nf