16namespace layer1_foundations {
17namespace linear_algebra {
21 int f_special,
int f_complete,
int *base_cols,
22 int f_P,
int *P,
int m,
int n,
int Pn,
int verbose_level)
27 int f_v = (verbose_level >= 1);
30 int rank, i, j, k, jj;
31 int pivot, pivot_inv = 0, a, b, c, z, f;
35 cout <<
"linear_algebra::Gauss_int" << endl;
38 cout <<
"Gauss algorithm for matrix:" << endl;
43 for (j = 0; j < n; j++) {
45 cout <<
"searching for pivot element in column j=" << j << endl;
48 for (k = i; k < m; k++) {
51 cout <<
"i=" << i <<
" pivot found in "
52 << k <<
"," << j << endl;
56 for (jj = j; jj < n; jj++) {
57 Algo.
int_swap(A[i * n + jj], A[k * n + jj]);
60 for (jj = 0; jj < Pn; jj++) {
61 Algo.
int_swap(P[i * Pn + jj], P[k * Pn + jj]);
71 cout <<
"no pivot found" << endl;
77 cout <<
"row " << i <<
" pivot in row "
78 << k <<
" colum " << j << endl;
88 cout <<
"pivot=" << pivot << endl;
93 cout <<
"pivot=" << pivot <<
" pivot_inv="
98 for (jj = j; jj < n; jj++) {
99 A[i * n + jj] =
F->
mult(A[i * n + jj], pivot_inv);
102 for (jj = 0; jj < Pn; jj++) {
103 P[i * Pn + jj] =
F->
mult(P[i * Pn + jj], pivot_inv);
107 cout <<
"pivot=" << pivot <<
" pivot_inv=" << pivot_inv
108 <<
" made to one: " << A[i * n + j] << endl;
118 cout <<
"doing elimination in column " << j <<
" from row "
119 << i + 1 <<
" to row " << m - 1 <<
":" << endl;
121 for (k = i + 1; k < m; k++) {
123 cout <<
"k=" << k << endl;
130 f =
F->
mult(z, pivot_inv);
138 cout <<
"eliminating row " << k << endl;
140 for (jj = j + 1; jj < n; jj++) {
150 cout << A[k * n + jj] <<
" ";
154 for (jj = 0; jj < Pn; jj++) {
167 cout <<
"A=" << endl;
173 cout <<
"A=" << endl;
177 cout <<
"P=" << endl;
187 for (i = rank - 1; i >= 0; i--) {
196 pivot = A[i * n + j];
200 for (k = i - 1; k >= 0; k--) {
206 for (jj = j + 1; jj < n; jj++) {
210 a =
F->
mult(a, pivot_inv);
218 for (jj = 0; jj < Pn; jj++) {
222 a =
F->
mult(a, pivot_inv);
237 cout <<
"the rank is " << rank << endl;
240 cout <<
"linear_algebra::Gauss_int done" << endl;
245int linear_algebra::Gauss_int_with_pivot_strategy(
int *A,
246 int f_special,
int f_complete,
int *pivot_perm,
248 int (*find_pivot_function)(
int *A,
int m,
int n,
int r,
249 int *pivot_perm,
void *data),
250 void *find_pivot_data,
255 int f_v = (verbose_level >= 1);
258 int rank, i, j, k, jj;
259 int pivot, pivot_inv = 0, a, b, c, z, f, pi;
263 cout <<
"linear_algebra::Gauss_int_with_pivot_strategy" << endl;
266 cout <<
"linear_algebra::Gauss_int_with_pivot_strategy "
267 "Gauss algorithm for matrix:" << endl;
271 for (i = 0; i < m; i++) {
273 cout <<
"i=" << i << endl;
276 j = (*find_pivot_function)(A, m, n, i, pivot_perm, find_pivot_data);
287 for (k = i; k < m; k++) {
295 cout <<
"linear_algebra::Gauss_int_with_pivot_strategy "
296 "no pivot found in column " << j << endl;
302 cout <<
"row " << i <<
" pivot in row " << k
303 <<
" colum " << j << endl;
312 for (jj = 0; jj < n; jj++) {
313 Algo.
int_swap(A[i * n + jj], A[k * n + jj]);
320 pivot = A[i * n + j];
322 cout <<
"pivot=" << pivot << endl;
326 cout <<
"pivot=" << pivot <<
" pivot_inv=" << pivot_inv << endl;
330 for (jj = 0; jj < n; jj++) {
331 A[i * n + jj] =
F->
mult(A[i * n + jj], pivot_inv);
334 cout <<
"pivot=" << pivot <<
" pivot_inv=" << pivot_inv
335 <<
" made to one: " << A[i * n + j] << endl;
345 cout <<
"doing elimination in column " << j <<
" from row "
346 << i + 1 <<
" down to row " << m - 1 <<
":" << endl;
348 for (k = i + 1; k < m; k++) {
350 cout <<
"k=" << k << endl;
357 f =
F->
mult(z, pivot_inv);
365 cout <<
"eliminating row " << k << endl;
367 for (jj = 0; jj < n; jj++) {
377 cout << A[k * n + jj] <<
" ";
384 cout <<
"A=" << endl;
390 cout <<
"A=" << endl;
397 for (i = rank - 1; i >= 0; i--) {
403 pivot = A[i * n + j];
407 for (k = i - 1; k >= 0; k--) {
413 for (jj = 0; jj < n; jj++) {
417 a =
F->
mult(a, pivot_inv);
431 cout <<
"the rank is " << rank << endl;
434 cout <<
"linear_algebra::Gauss_int_with_pivot_strategy done" << endl;
439int linear_algebra::Gauss_int_with_given_pivots(
int *A,
440 int f_special,
int f_complete,
int *pivots,
int nb_pivots,
445 int f_v = (verbose_level >= 1);
449 int pivot, pivot_inv = 0, a, b, c, z, f;
453 cout <<
"linear_algebra::Gauss_int_with_given_pivots" << endl;
456 cout <<
"linear_algebra::Gauss_int_with_given_pivots "
457 "Gauss algorithm for matrix:" << endl;
464 for (i = 0; i < nb_pivots; i++) {
466 cout <<
"i=" << i << endl;
472 for (k = i; k < m; k++) {
480 cout <<
"linear_algebra::Gauss_int_with_given_pivots "
481 "no pivot found in column " << j << endl;
487 cout <<
"row " << i <<
" pivot in row " << k
488 <<
" colum " << j << endl;
497 for (jj = 0; jj < n; jj++) {
498 Algo.
int_swap(A[i * n + jj], A[k * n + jj]);
505 pivot = A[i * n + j];
507 cout <<
"pivot=" << pivot << endl;
511 cout <<
"pivot=" << pivot <<
" pivot_inv=" << pivot_inv << endl;
515 for (jj = 0; jj < n; jj++) {
516 A[i * n + jj] =
F->
mult(A[i * n + jj], pivot_inv);
519 cout <<
"pivot=" << pivot <<
" pivot_inv=" << pivot_inv
520 <<
" made to one: " << A[i * n + j] << endl;
530 cout <<
"doing elimination in column " << j <<
" from row "
531 << i + 1 <<
" down to row " << m - 1 <<
":" << endl;
533 for (k = i + 1; k < m; k++) {
535 cout <<
"k=" << k << endl;
542 f =
F->
mult(z, pivot_inv);
550 cout <<
"eliminating row " << k << endl;
552 for (jj = 0; jj < n; jj++) {
562 cout << A[k * n + jj] <<
" ";
569 cout <<
"A=" << endl;
574 cout <<
"A=" << endl;
580 for (i = nb_pivots - 1; i >= 0; i--) {
586 pivot = A[i * n + j];
590 for (k = i - 1; k >= 0; k--) {
596 for (jj = 0; jj < n; jj++) {
600 a =
F->
mult(a, pivot_inv);
616 cout <<
"linear_algebra::Gauss_int_with_given_pivots done" << endl;
623int linear_algebra::RREF_search_pivot(
int *A,
int m,
int n,
624 int &i,
int &j,
int *base_cols,
int verbose_level)
627 int f_v = (verbose_level >= 1);
628 int f_vv = (verbose_level >= 2);
633 cout <<
"linear_algebra::RREF_search_pivot" << endl;
636 cout <<
"linear_algebra::RREF_search_pivot matrix:" << endl;
642 cout <<
"j=" << j << endl;
645 for (k = i; k < m; k++) {
648 cout <<
"i=" << i <<
" pivot found in "
649 << k <<
"," << j << endl;
653 for (jj = j; jj < n; jj++) {
654 Algo.
int_swap(A[i * n + jj], A[k * n + jj]);
663 cout <<
"no pivot found" << endl;
669 cout <<
"row " << i <<
" pivot in row "
670 << k <<
" colum " << j << endl;
678void linear_algebra::RREF_make_pivot_one(
int *A,
int m,
int n,
679 int &i,
int &j,
int *base_cols,
int verbose_level)
682 int f_v = (verbose_level >= 1);
683 int f_vv = (verbose_level >= 2);
684 int pivot, pivot_inv;
688 cout <<
"linear_algebra::RREF_make_pivot_one" << endl;
690 pivot = A[i * n + j];
692 cout <<
"pivot=" << pivot << endl;
697 cout <<
"pivot=" << pivot <<
" pivot_inv="
698 << pivot_inv << endl;
701 for (jj = j; jj < n; jj++) {
702 A[i * n + jj] =
F->
mult(A[i * n + jj], pivot_inv);
705 cout <<
"pivot=" << pivot <<
" pivot_inv=" << pivot_inv
706 <<
" made to one: " << A[i * n + j] << endl;
709 cout <<
"linear_algebra::RREF_make_pivot_one done" << endl;
714void linear_algebra::RREF_elimination_below(
int *A,
int m,
int n,
715 int &i,
int &j,
int *base_cols,
int verbose_level)
718 int f_v = (verbose_level >= 1);
719 int f_vv = (verbose_level >= 2);
720 int k, jj, z, f, a, b, c;
723 cout <<
"linear_algebra::RREF_elimination_below" << endl;
725 for (k = i + 1; k < m; k++) {
727 cout <<
"k=" << k << endl;
737 cout <<
"eliminating row " << k << endl;
739 for (jj = j + 1; jj < n; jj++) {
749 cout << A[k * n + jj] <<
" ";
755 cout <<
"linear_algebra::RREF_elimination_below done" << endl;
759void linear_algebra::RREF_elimination_above(
int *A,
int m,
int n,
760 int i,
int *base_cols,
int verbose_level)
763 int f_v = (verbose_level >= 1);
764 int j, k, jj, z, a, b, c;
767 cout <<
"linear_algebra::RREF_elimination_above" << endl;
772 for (k = i - 1; k >= 0; k--) {
778 for (jj = j + 1; jj < n; jj++) {
788 cout <<
"linear_algebra::RREF_elimination_above done" << endl;
catch all class for algorithms
void int_swap(int &x, int &y)
field_theory::finite_field * F
#define Int_vec_print_integer_matrix(A, B, C, D)
#define Int_vec_print_integer_matrix_width(A, B, C, D, E, F)
#define Int_vec_print(A, B, C)
int Gauss_int(int *A, int f_special, int f_complete, int *base_cols, int f_P, int *P, int m, int n, int Pn, int q, int *add_table, int *mult_table, int *negate_table, int *inv_table, int verbose_level)
the orbiter library for the classification of combinatorial objects