Skip to content

Improve representation of monomials #15

Open
@sheaf

Description

@sheaf

Currently, monomials are represented as unboxed vectors of Ints. This seems rather inefficient: an unboxed vector stores an offset, a length, and the data is stored byte-per-byte instead of word-per-word.

Two ideas come to mind instead:

newtype Monomial ( n :: Nat ) = Monomial ( Array# Word )

or, avoiding all indirections entirely:

data family Monomial ( n :: Nat ) :: TYPE ( 'TupleRep ( Replicate n WordRep ) )
newtype instance Monomial 0 = M0 (# #)
newtype instance Monomial 1 = M1 (# Word# #)
newtype instance Monomial 2 = M2 (# Word#, Word# #)
newtype instance Monomial 3 = M3 (# Word#, Word#, Word# #)
newtype instance Monomial 4 = M4 (# Word#, Word#, Word#, Word# #)
...

I'm also wondering if a Map is the best data-structure to use to represent polynomials, but I suppose that's best left to a separate ticket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions