question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Matrix row reduction is very slow

See original GitHub issue

Hi,

I’ve tried to use this library to row reduce a (quite) big matrix over a finite field. It succeeded and took quite a huge time in comparison with a naïve implementation.

As an example I copy paste the timing from the jupyter notebook.

with: https://www.nayuki.io/page/gauss-jordan-elimination-over-any-field

mat.reduced_row_echelon_form()

CPU times: user 4min 15s, sys: 18.7 ms, total: 4min 15s
Wall time: 4min 15s

with galois:

MM_reduced = MM.row_reduce()

CPU times: user 4h 21min 24s, sys: 3.06 s, total: 4h 21min 27s
Wall time: 4h 21min 28s

the matrix, for reference is sparse and defined over a 128-bit prime, the shape is: 513x1025

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
mhostettercommented, Nov 8, 2021

@ddddavidee I pushed another performance improvement to that branch. You’ll likely see another speed up.

1reaction
ddddavideecommented, Nov 8, 2021

@nayuki, what I meant is that the same computation took a very different time (~60x times) changing from your code to the one in galois… and I was thinking that there was a problem somewhere…

@mhostetter I pulled the branch and re-tried the computation (with some other small changes, I used lru_cache from functools, and shortcut the ‘division-by-one’ case, and now the computation for the very same matrix takes less than two minutes (Wall time: 1min 43s)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Row Reduction Part 2/2: How to Get Faster [Passing Linear ...
Row Reduction Algorithm: 3:09 Worked through solutions: 6:15 13:53 15:05 16:07At 14:50, the top right entry should be a 5 not a 6....
Read more >
Why my Power BI Matrix or Table Visual is SLOW - RADACAD
Summary. Your matrix and table visuals are not slow because of Power BI! They are slow because of the bad data model, and...
Read more >
FiniteFields package is very slow. Any fast substitute for ...
One can improve on this by writing a direct row reduction using a list representation form the field elements. This would require working ......
Read more >
as.matrix on a distance object is extremely slow; how to make ...
What does dist return? This function always returns a vector, holding the lower triangular part (by column) of the full matrix.
Read more >
Slow Matrices? Try Lists. - Brodie Gaslam
A classic row-wise operation is to sum values by row. This is easily done with rowSums for matrices. For lists, we can use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found