Skip to content
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

Change default implementation of FreeAlgebra #22708

Open
simon-king-jena opened this issue Mar 29, 2017 · 2 comments
Open

Change default implementation of FreeAlgebra #22708

simon-king-jena opened this issue Mar 29, 2017 · 2 comments

Comments

@simon-king-jena
Copy link
Member

By default, FreeAlgebra uses a rather sluggish default implementation written in Python. We have several implementations of free algebras that provide faster arithmetics: letterplace and path algebras.

Example:

sage: R.<x,y,z> = FreeAlgebra(Integers(2))
sage: 1 in R
True
sage: %timeit (x+y+z)*(x+y+z)
10000 loops, best of 3: 99.2 µs per loop

sage: R.<x,y,z> = FreeAlgebra(Integers(2), implementation='letterplace')
sage: 1 in R
True
sage: %timeit (x+y+z)*(x+y+z)
10000 loops, best of 3: 31.7 µs per loop

sage: R = DiGraph({1:{1:['x','y','z']}}).path_semigroup().algebra(Integers(2))
sage: R.inject_variables()
Defining e_1, x, y, z
sage: 1 in R
True
sage: %timeit (x+y+z)*(x+y+z)
100000 loops, best of 3: 4.5 µs per loop

I suggest to

  • add "paths" as possible value of the implementation keyword of FreeAlgebra.
  • let "paths" be the default implementation, as "generic" seems the slowest of them all.

Note that "letterplace" can not be the default, as is does not allow the creation of inhomogeneous elements. That's not a problem for path algebras, but it may be needed to add more functionality to path algebras in order to make it a true replacement for the generic implementation.

CC: @tscrim

Component: algebra

Issue created by migration from https://trac.sagemath.org/ticket/22708

@tscrim

This comment has been minimized.

@tscrim
Copy link
Collaborator

tscrim commented Mar 29, 2017

comment:1

I think we should focus a little bit more on speeding up the default/generic implementation. Towards that goal, #22632 will be the first step (and benefit a larger portion of Sage). The next step would be directly cythonizing the free algebra element and possibly having a better/faster index set.

I would say defect = bug, and just being the slowest would not have it fall into that category IMO (especially since it is possibly the most general).

@mkoeppe mkoeppe removed this from the sage-8.0 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants