Is multiplication cached?

asked 2025-05-21 01:21:30 +0200

Joux gravatar image

I'm doing some fairly complicated computations in a quotient ring of the form Z[x_1,..x_n]/I. I've tried looking through the code myself to try to understand it, but unfortunately it is beyond me.

My question is this: Suppose in the process of some computation (say I have an element f and I'm trying to compute f^9), the program computes a product xy, then later in the same computation it must repeat the product xy it already did before - will it be able to just pick up what it already computed, or will it compute the whole thing again? If it stores the value, is there a way to keep it cached to use in a future computation?

Unfortunately my code is taking too long to run the computations I need, so I'm trying to find ways to improve it. Most of the computational time is just spend with polynomial expressions in the quotient ring, so I want to see if it's worth my time to make it store a multiplication table as it goes, if it's not already doing that.

edit retag flag offensive close merge delete

Comments

I'm curious: might it be faster to compute everything in the polynomial ring, and then at the end convert the result to the quotient?

John Palmieri gravatar imageJohn Palmieri ( 2025-05-21 01:48:50 +0200 )edit

I have tried this and it seems to be faster, though not by a significant enough margin. As well for more complex terms the difference is smaller, as in the quotient ring terms become 0 and that reduces the operations needed.

Joux gravatar imageJoux ( 2025-05-21 02:44:38 +0200 )edit
1

You might also do some computations in the polynomial ring and use a pre-computed Gröbner basis G = I.groebner_basis() to perform reduction f.reduce(G) at certain steps. That way you have control over when the reduction happens. And you can cache reduced results (manually).

rburing gravatar imagerburing ( 2025-05-21 08:40:11 +0200 )edit

I'll give this a try, thanks for the tip!

Joux gravatar imageJoux ( 2025-05-21 20:38:10 +0200 )edit