bridge/class-master/depend/pari/src/basemath/alglin1.c
/* assume dim A >= 1, A invertible + upper triangular  */
assume dim A >= 1, A invertible + upper triangular
assume dim A > = 1 A invertible + upper triangular
static GEN
gen_matinv_upper_ind(GEN A, long index, void *E, const struct bb_field *ff)
{
  long n = lg(A) - 1, i, j;
  GEN u = cgetg(n + 1, t_COL);
  for (i = n; i > index; i--)
    gel(u, i) = ff->s(E, 0);
  gel(u, i) = ff->inv(E, gcoeff(A, i, i));
  for (i--; i > 0; i--) {
    pari_sp av = avma;
    GEN m = ff->neg(E, ff->mul(E, gcoeff(A, i, i + 1), gel(u, i + 1)));
    for (j = i + 2; j <= n; j++)
      m = ff->add(E, m, ff->neg(E, ff->mul(E, gcoeff(A, i, j), gel(u, j))));
    gel(u, i) = gerepileupto(av, ff->red(E, ff->mul(E, m, ff->inv(E, gcoeff(A, i, i)))));
  }
  return u;
}
static GEN gen_matinv_upper_ind ( GEN A , long index , void * E , const struct bb_field * ff ) { long n = lg ( A ) - 1 , i , j ; GEN u = cgetg ( n + 1 , t_COL ) ; for ( i = n ; i > index ; i -- ) gel ( u , i ) = ff -> s ( E , 0 ) ; gel ( u , i ) = ff -> inv ( E , gcoeff ( A , i , i ) ) ; for ( i -- ; i > 0 ; i -- ) { pari_sp av = avma ; GEN m = ff -> neg ( E , ff -> mul ( E , gcoeff ( A , i , i + 1 ) , gel ( u , i + 1 ) ) ) ; for ( j = i + 2 ; j <= n ; j ++ ) m = ff -> add ( E , m , ff -> neg ( E , ff -> mul ( E , gcoeff ( A , i , j ) , gel ( u , j ) ) ) ) ; gel ( u , i ) = gerepileupto ( av , ff -> red ( E , ff -> mul ( E , m , ff -> inv ( E , gcoeff ( A , i , i ) ) ) ) ) ; } return u ; }
assume dim A >= 1, A invertible + upper triangular
assume dim A > = 1 A invertible + upper triangular