CachedPower SΒΆ
cachedpow.spad line 38 [edit on github]
- S: SemiGroup 
CachedPower(S) stores together with an element also its powers. Each power is only computed once.
- coerce: % -> S
- from CoercibleTo S 
- coerce: S -> %
- from CoercibleFrom S 
- power!: (%, Integer) -> S if S has MagmaWithUnit
- power!(x, n)extracts the- n-th power of- x, if that has already been computed. Otherwise it computes the- n-th power by repeated squaring and stores all intermediately computed powers of- xincluding the- n-th power in the cache and only then returns the result.
- power!: (%, PositiveInteger) -> S
- power!(x, n)extracts the- n-th power of- x, if that has already been computed. Otherwise it computes the- n-th power by repeated squaring and stores all intermediately computed powers of- xincluding the- n-th power in the cache and only then returns the result.