Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/friesischscott/monomials.jl
- Owner: FriesischScott
- License: mit
- Created: 2024-05-08T09:54:24.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-09-15T14:44:00.000Z (2 months ago)
- Last Synced: 2024-10-12T19:20:46.644Z (about 1 month ago)
- Topics: julia, monomials
- Language: Julia
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
y²
x
xy
x²
```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
y²
x
xy
x²
```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))
```