terrylyons / libalgebra

This C++ headers only library provides tools for manipulating elements of algebras; the tensor algebra, free lie algebra etc. Early versions can be found in sourceforge. It is capable of calculations over many rings including the arbitrary precision rationals from gmp/mpir . The associated library libalgebra_tests has many examples of how to use the code. the pypy package wraps a version of it - with a simple interface (and vastly reduced functionality)
12 stars 2 forks source link

Excessive locking in functions associated with Lie calculations #17

Open inakleinbottle opened 3 years ago

inakleinbottle commented 3 years ago

At the moment, the architecture of Lie multiplication, implemented in lie_basis::prod, and in the maps::expand function. The locking makes sense in a situation where vectors are sparse but cause performance issues on more dense vectors. Instead it is better to pre-populate lookup-tables, where they are still necessary, and perform unlocked thread-safe lookups without any locking.

I would like to transition the code to separate the multiplication logic from the basis classes and into separate multiplication operators that pass the logic down to the data model to be applied in the correct way.

At this point it is worth pointing out that, at the moment, the maximum degree of the dense part of a vector and the whole vector itself are equal. This means that, at present, there isn't any difference between the "dense case" and the "sparse case", but this might change in the future.

For multiplication, we can simply implement the index_transform and key_transform structs as in the case for tensor multiplication and use the same mechanism to split the caching into two distinct cases. For expand, we can make use of the linear transformation mechanism, which is essentially the same as multiplication.