Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346/****************************************************************************1**2*A echelonise_matrix.c ANUPQ source Eamonn O'Brien3**4*Y Copyright 1995-2001, Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany5*Y Copyright 1995-2001, School of Mathematical Sciences, ANU, Australia6**7*/89#include "pq_defs.h"10#include "pga_vars.h"1112/* left echelonise mod p the matrix a, which has the supplied dimensions;13set up its definition set both as a subset and as a bit string */1415int echelonise_matrix(int **a,16int nmr_rows,17int nmr_columns,18int p,19int *subset,20struct pga_vars *pga)21{22Logical zero;23register int bound = nmr_columns - 1;24register int row, column, i, j, index, val;25register int entry;26register int bit_string = 0;2728for (row = 0; row < nmr_rows; ++row) {2930/* start with the diagonal entry */31column = row;3233/* find first non-zero entry, if any, in this column;34if none, advance to next column */35do {36index = row;37while (index < nmr_rows && (zero = (a[index][column] == 0)))38++index;39if (zero) {40if (column < bound)41++column;42else43return bit_string;44}45} while (zero);4647/* store the definition set information for this matrix */48bit_string |= 1 << column;49subset[row] = column;5051/* if necessary, interchange current row with row index */52if (index > row) {53for (j = column; j < nmr_columns; ++j) {54val = a[index][j];55a[index][j] = a[row][j];56a[row][j] = val;57}58}5960/* multiply row by the inverse in GF(p) of a[row][column] */61if ((entry = a[row][column]) != 1) {62val = pga->inverse_modp[entry];63a[row][column] = 1;64for (j = column + 1; j < nmr_columns; ++j)65a[row][j] = (a[row][j] * val) % p;66}6768/* now zero out all other entries in this column */69for (i = 0; i < nmr_rows; ++i) {70if (a[i][column] == 0 || i == row)71continue;72val = p - a[i][column];73a[i][column] = 0;74for (j = column + 1; j < nmr_columns; ++j)75a[i][j] = (a[i][j] + val * a[row][j]) % p;76}77}7879return bit_string;80}818283