I'm looking for a C++ library but I'm not sure what to search for because I'm not sure what to call the task I want to do (in such a way that it's searchable).
Example of functionality
I have a number of matrix equations involving a single operation (multiplication), with some common elements in them, for example:
result_1 = a * b * c * e
result_2 = b * c
result_3 = c * e * f
There are no unknowns here; we're just calculating the result_n
items.
These multiplications are expensive to perform so I'm wanting a library that lets me set up the equations and the values of a
, b
, etc, then retrieve the result
items.
Most crucially, I also need to then be able to say "I am updating values (for example) a
and f
", and have the library not do any unnecessary calcualtion; it would not bother recalculating result_2
(as the answer won't change), and it wouldn't not bother recalculating sub-terms b * c * e
(in result_1
) or c * e
(in result_3
) as these parts will be not different either.
Is there a good name for this kind of facility?
Ideally it would also be able to handle different operators (e.g. binary *
and unary transpose
) and you could specify properties of operators, e.g. "*
does not commute, but is associative". Knowing these properties would allow the lib to sometimes do a more efficient job.
Unless you were working with really big numbers, I would advise you to stick with the standard libraries. Multiplying numbers in C++ is probably as bare minimum as one could get besides using assembly code, even then i doubt you would see significant improvements.
I personally say you are fine, if you were using Python then YES I would definitely advise you to use Python's math library but since this is C++, you really don't need to worry about it.
Why do you need to optimize it if i may ask? Have you tried flagging your compiler with optimizations? Are the numbers you are working with big?