bridge/class-master/depend/pari/src/basemath/base3.c
/* both x and y are RgV */
both x and y are RgV
both x and y are RgV
GEN
tablemul(GEN TAB, GEN x, GEN y)
{
  long i, j, k, N;
  GEN s, v;
  if (typ(x) != t_COL) return gmul(x, y);
  if (typ(y) != t_COL) return gmul(y, x);
  N = lg(x)-1;
  v = cgetg(N+1,t_COL);
  for (k=1; k<=N; k++)
  {
    pari_sp av = avma;
    GEN TABi = TAB;
    if (k == 1)
      s = gmul(gel(x,1),gel(y,1));
    else
      s = gadd(gmul(gel(x,1),gel(y,k)),
               gmul(gel(x,k),gel(y,1)));
    for (i=2; i<=N; i++)
    {
      GEN t, xi = gel(x,i);
      TABi += N;
      if (gequal0(xi)) continue;
      t = NULL;
      for (j=2; j<=N; j++)
      {
        GEN p1, c = gcoeff(TABi, k, j); 
        if (gequal0(c)) continue;
        p1 = gmul(c, gel(y,j));
        t = t? gadd(t, p1): p1;
      }
      if (t) s = gadd(s, gmul(xi, t));
    }
    gel(v,k) = gerepileupto(av,s);
  }
  return v;
}
GEN tablemul ( GEN TAB , GEN x , GEN y ) { long i , j , k , N ; GEN s , v ; if ( typ ( x ) != t_COL ) return gmul ( x , y ) ; if ( typ ( y ) != t_COL ) return gmul ( y , x ) ; N = lg ( x ) - 1 ; v = cgetg ( N + 1 , t_COL ) ; for ( k = 1 ; k <= N ; k ++ ) { pari_sp av = avma ; GEN TABi = TAB ; if ( k == 1 ) s = gmul ( gel ( x , 1 ) , gel ( y , 1 ) ) ; else s = gadd ( gmul ( gel ( x , 1 ) , gel ( y , k ) ) , gmul ( gel ( x , k ) , gel ( y , 1 ) ) ) ; for ( i = 2 ; i <= N ; i ++ ) { GEN t , xi = gel ( x , i ) ; TABi += N ; if ( gequal0 ( xi ) ) continue ; t = NULL ; for ( j = 2 ; j <= N ; j ++ ) { GEN p1 , c = gcoeff ( TABi , k , j ) ; if ( gequal0 ( c ) ) continue ; p1 = gmul ( c , gel ( y , j ) ) ; t = t ? gadd ( t , p1 ) : p1 ; } if ( t ) s = gadd ( s , gmul ( xi , t ) ) ; } gel ( v , k ) = gerepileupto ( av , s ) ; } return v ; }
both x and y are RgV
both x and y are RgV
/* m^{i,j}_k */