bridge/class-master/depend/pari/src/basemath/alglin1.c
/* solve L*X = A,  L square lower triangular with ones on the diagonal */
solve L*X = A,  L square lower triangular with ones on the diagonal
solve L * X = A L square lower triangular with ones on the diagonal
static GEN
FlxqM_lsolve_lower_unit(GEN L, GEN A, GEN T, ulong p)
{
  long m = lg(L) - 1, m1;
  GEN L1, L2, L11, L21, L22, A1, A2, X1, X2, X;
  pari_sp av = avma;
  if (m <= 1) return A;
  if (m == 2) return FlxqM_lsolve_lower_unit_2(L, A, T, p);
  m1 = (m + 1)/2;
  L1 = vecslice(L, 1, m1);
  L2 = vecslice(L, m1 + 1, m);
  L11 = rowslice(L1, 1, m1);
  L21 = rowslice(L1, m1 + 1, m);
  L22 = rowslice(L2, m1 + 1, m);
  A1 = vecslice(A, 1, m1);
  A2 = vecslice(A, m1 + 1, m);
  X2 = FlxqM_lsolve_lower_unit(L22, A2, T, p);
  A1 = FlxM_sub(A1, FlxqM_mul(X2, L21, T, p), p);
  if (gc_needed(av, 1)) gerepileall(av, 3, &A1, &L11, &X2);
  X1 = FlxqM_lsolve_lower_unit(L11, A1, T, p);
  X = shallowconcat(X1, X2);
  if (gc_needed(av, 1)) X = gerepilecopy(av, X);
  return X;
}
static GEN FlxqM_lsolve_lower_unit ( GEN L , GEN A , GEN T , ulong p ) { long m = lg ( L ) - 1 , m1 ; GEN L1 , L2 , L11 , L21 , L22 , A1 , A2 , X1 , X2 , X ; pari_sp av = avma ; if ( m <= 1 ) return A ; if ( m == 2 ) return FlxqM_lsolve_lower_unit_2 ( L , A , T , p ) ; m1 = ( m + 1 ) / 2 ; L1 = vecslice ( L , 1 , m1 ) ; L2 = vecslice ( L , m1 + 1 , m ) ; L11 = rowslice ( L1 , 1 , m1 ) ; L21 = rowslice ( L1 , m1 + 1 , m ) ; L22 = rowslice ( L2 , m1 + 1 , m ) ; A1 = vecslice ( A , 1 , m1 ) ; A2 = vecslice ( A , m1 + 1 , m ) ; X2 = FlxqM_lsolve_lower_unit ( L22 , A2 , T , p ) ; A1 = FlxM_sub ( A1 , FlxqM_mul ( X2 , L21 , T , p ) , p ) ; if ( gc_needed ( av , 1 ) ) gerepileall ( av , 3 , & A1 , & L11 , & X2 ) ; X1 = FlxqM_lsolve_lower_unit ( L11 , A1 , T , p ) ; X = shallowconcat ( X1 , X2 ) ; if ( gc_needed ( av , 1 ) ) X = gerepilecopy ( av , X ) ; return X ; }
solve L*X = A,  L square lower triangular with ones on the diagonal
solve L * X = A L square lower triangular with ones on the diagonal