Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/friesischscott/monomials.jl

A simple package for monomials in Julia
https://github.com/friesischscott/monomials.jl

julia monomials

Last synced: about 1 month ago
JSON representation

A simple package for monomials in Julia

Awesome Lists containing this project

README

        

# Monomials.jl

![Build Status](https://github.com/FriesischScott/Monomials.jl/actions/workflows/ci.yml/badge.svg) [![Coverage Status](https://codecov.io/gh/FriesischScott/Monomials.jl/graph/badge.svg?token=MFK6LJBRNK)](https://codecov.io/gh/FriesischScott/Monomials.jl)

A simple apackage to generate, order, and evaluate vectors of monomials. It is designed as an alternative to the [MultivariatePolynomials.jl](https://github.com/JuliaAlgebra/MultivariatePolynomials.jl) ecosystem if all you require is monomials not fully fledged polynomials.

The core functionality is exposed through the `monomials` function. It generates all monomials of the given variables up to a defined maximum degree and sorts them in the requested order. Available monomial orders are:

- `LexicographicOrder`
- `GradedLexicographicOrder`
- `GradedReverseLexicographicOrder`

There are no concrete plans to add more features to the package.

## Examples

The following returns the monomials of two variables with a maximum degree of 2 in lexicographic order.

```julia
monomials(["x","y"], 2, LexicographicOrder())
```

```
5-element Vector{Monomial}:
y

x
xy

```

it is possible to include the zero-degree monomial by passing the `include_zero=true` option.

```julia
m = monomials(["x","y"], 2, LexicographicOrder(); include_zero=true)
```

```
6-element Vector{Monomial}:
1
y

x
xy

```

Monomials can be evaluated by passing a `Vector`.

```julia
m = Monomial(["x", "y"], [1, 2])
m([2, 3])
```

For convenience, a single monomial can be evaluated at multiple points by passing a `Matrix`. In this case, the points are expected to be the columns of the given matrix.

```julia
m = Monomial(["x", "y"], [1, 2])
m(rand(2, 5))
```

Finally, to evaulate all monomials in a vector for one or more points pass the `Vector` or `Matrix` directly to the vector of monomials.

```julia
m = monomials((["x", "y"], 2, LexicographicOrder())
m(rand(2, 5))
```