-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Computing echelon form of smaller matrix takes longer than larger matrix? #2129
Comments
Can you replicate this in C, that is, make a MWE? I am not familiar with how Python works under the hood. |
Perhaps the tuning parameters could be changed for |
Sure: #include <flint/flint.h>
#include <flint/fmpz.h>
#include <flint/fmpz_mat.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void random_fmpz_mat(fmpz_mat_t mat, slong entry_size) {
slong i, j;
flint_rand_t state;
flint_randinit(state);
for (i = 0; i < fmpz_mat_nrows(mat); i++) {
for (j = 0; j < fmpz_mat_ncols(mat); j++) {
fmpz* tmp = fmpz_mat_entry(mat, i, j);
fmpz_randbits(tmp, state, entry_size);
fmpz_add_ui(tmp, tmp, 1);
}
}
}
int main() {
slong entry_size = 10000;
slong num_col = 20, num_row = 20;
//slong num_col = 40, num_row = 40;
fmpz_mat_t A;
fmpz_mat_init(A, num_row, num_col);
random_fmpz_mat(A, entry_size);
clock_t start = clock();
fmpz den;
fmpz_init(&den);
fmpz_mat_rref(A, &den, A);
clock_t end = clock();
double time_taken = (double)(end - start) / CLOCKS_PER_SEC;
printf("Time taken: %f seconds\n", time_taken);
fmpz_mat_clear(A);
return 0;
} Change the parameter between 20 and 40 at the commented out line. |
I would guess |
I suppose @fredrik-johansson is the expert here. Perhaps he can answer when he is back from vacation and has time. |
Use flint's algorithm through SageMath's interface (which uses
fmpq_mat_rref
under the hood).Why is it that in the first case with a 20 × 20 matrix it takes >1 second while in the second case it is instant?
In both cases the matrix is invertible, thus the echelon form is identity.
(larger context: sagemath/sage#39197 , if flint is the fastest in all cases it would be easiest to just switch to flint, but this is not the case at the moment)
The text was updated successfully, but these errors were encountered: