bridge/class-master/depend/pari/src/basemath/qfisom.c
/* computes the list of scalar product combinations of the vectors
 * in V.v with the basis-vectors in b */
computes the list of scalar product combinations of the vectors
in V.v with the basis-vectors in b
computes the list of scalar product combinations of the vectors in V . v with the basis - vectors in b
static GEN
scpvecs(GEN *pt_vec, long I, GEN b, long dep, struct qfauto *qf)
{
  long  i, j, nr, sign;
  GEN list, vec;
  GEN vecnr;
  GEN V = qf->V, F = qf->F, v = qf->v;
  long n = lg(V)-1;
  long dim = lg(gel(F,1))-1;
  long len = (lg(F)-1)*dep;
  list = mkmat(zero_Flv(len));
  vec  = mkmat(zero_Flv(dim));
  for (j = 1; j <= n; ++j)
  {
    GEN Vvj = gel(V,j);
    GEN scpvec = scpvector(Vvj, b, I, dep, v);
    if (zv_equal0(scpvec))
      nr = -1;
    else
    {
      sign = zv_canon(scpvec);
      nr = vecvecsmall_search(list,scpvec,0);
    }
    if (nr > 0)
    {
      vecnr = gel(vec,nr);
      for (i = 1; i <= dim; ++i)
        vecnr[i] += sign * Vvj[i];
    }
    else if (nr==0)
    {
      nr = vecvecsmall_search(list,scpvec,1);
      list=vec_insert(list,nr,scpvec);
      vec=vec_insert(vec,nr,sign < 0 ? zv_neg(Vvj) : zv_copy(Vvj));
    }
  }
  settyp(list,t_MAT);
  settyp(vec,t_MAT);
  *pt_vec = vec;
  return list;
}
static GEN scpvecs ( GEN * pt_vec , long I , GEN b , long dep , struct qfauto * qf ) { long i , j , nr , sign ; GEN list , vec ; GEN vecnr ; GEN V = qf -> V , F = qf -> F , v = qf -> v ; long n = lg ( V ) - 1 ; long dim = lg ( gel ( F , 1 ) ) - 1 ; long len = ( lg ( F ) - 1 ) * dep ; list = mkmat ( zero_Flv ( len ) ) ; vec = mkmat ( zero_Flv ( dim ) ) ; for ( j = 1 ; j <= n ; ++ j ) { GEN Vvj = gel ( V , j ) ; GEN scpvec = scpvector ( Vvj , b , I , dep , v ) ; if ( zv_equal0 ( scpvec ) ) nr = -1 ; else { sign = zv_canon ( scpvec ) ; nr = vecvecsmall_search ( list , scpvec , 0 ) ; } if ( nr > 0 ) { vecnr = gel ( vec , nr ) ; for ( i = 1 ; i <= dim ; ++ i ) vecnr [ i ] += sign * Vvj [ i ] ; } else if ( nr == 0 ) { nr = vecvecsmall_search ( list , scpvec , 1 ) ; list = vec_insert ( list , nr , scpvec ) ; vec = vec_insert ( vec , nr , sign < 0 ? zv_neg ( Vvj ) : zv_copy ( Vvj ) ) ; } } settyp ( list , t_MAT ) ; settyp ( vec , t_MAT ) ; * pt_vec = vec ; return list ; }
computes the list of scalar product combinations of the vectors
 in V.v with the basis-vectors in b
computes the list of scalar product combinations of the vectors in V . v with the basis - vectors in b
/* the first vector in the list is the 0-vector and is not counted */ /* scpvec is already in list */ /* scpvec is a new scalar product combination */