bridge/class-master/depend/pari/src/basemath/alglin1.c
/* solve L*X = A,  L lower triangular with ones on the diagonal
* (at least as many rows as columns) */
solve L*X = A,  L lower triangular with ones on the diagonal
(at least as many rows as columns)
solve L * X = A L lower triangular with ones on the diagonal ( at least as many rows as columns )
static GEN
Flm_rsolve_lower_unit(GEN L, GEN A, ulong p)
{
  long m = lg(L) - 1, m1, n;
  GEN L1, L11, L21, L22, A1, A2, X1, X2, X;
  pari_sp av = avma;
  if (m == 0) return zero_Flm(0, lg(A) - 1);
  if (m == 1) return rowslice(A, 1, 1);
  if (m == 2) return Flm_rsolve_lower_unit_2(L, A, p);
  m1 = (m + 1)/2;
  n = nbrows(L);
  L1 = vecslice(L, 1, m1);
  L11 = rowslice(L1, 1, m1);
  L21 = rowslice(L1, m1 + 1, n);
  A1 = rowslice(A, 1, m1);
  X1 = Flm_rsolve_lower_unit(L11, A1, p);
  A2 = rowslice(A, m1 + 1, n);
  A2 = Flm_sub(A2, Flm_mul(L21, X1, p), p);
  if (gc_needed(av, 1)) gerepileall(av, 2, &A2, &X1);
  L22 = matslice(L, m1+1,n, m1+1,m);
  X2 = Flm_rsolve_lower_unit(L22, A2, p);
  X = vconcat(X1, X2);
  if (gc_needed(av, 1)) X = gerepilecopy(av, X);
  return X;
}
static GEN Flm_rsolve_lower_unit ( GEN L , GEN A , ulong p ) { long m = lg ( L ) - 1 , m1 , n ; GEN L1 , L11 , L21 , L22 , A1 , A2 , X1 , X2 , X ; pari_sp av = avma ; if ( m == 0 ) return zero_Flm ( 0 , lg ( A ) - 1 ) ; if ( m == 1 ) return rowslice ( A , 1 , 1 ) ; if ( m == 2 ) return Flm_rsolve_lower_unit_2 ( L , A , p ) ; m1 = ( m + 1 ) / 2 ; n = nbrows ( L ) ; L1 = vecslice ( L , 1 , m1 ) ; L11 = rowslice ( L1 , 1 , m1 ) ; L21 = rowslice ( L1 , m1 + 1 , n ) ; A1 = rowslice ( A , 1 , m1 ) ; X1 = Flm_rsolve_lower_unit ( L11 , A1 , p ) ; A2 = rowslice ( A , m1 + 1 , n ) ; A2 = Flm_sub ( A2 , Flm_mul ( L21 , X1 , p ) , p ) ; if ( gc_needed ( av , 1 ) ) gerepileall ( av , 2 , & A2 , & X1 ) ; L22 = matslice ( L , m1 + 1 , n , m1 + 1 , m ) ; X2 = Flm_rsolve_lower_unit ( L22 , A2 , p ) ; X = vconcat ( X1 , X2 ) ; if ( gc_needed ( av , 1 ) ) X = gerepilecopy ( av , X ) ; return X ; }
solve L*X = A,  L lower triangular with ones on the diagonal
(at least as many rows as columns)
solve L * X = A L lower triangular with ones on the diagonal ( at least as many rows as columns )