Skip to main content

A multivariate polynomial module.

Project description

multipoly

A multivariate polynomial module.

This package provides a single class, MultiPoly, to handle multivariate polynomials of form

$$ p(\vec{x}) = \sum_{0\leq n\leq\deg(p)}a_n(\vec{x}-\vec{c})^n = \sum_{n_0=0}^{\deg_0(p)}\cdots\sum_{n_{\dim(p)-1}=0}^{\deg_{\dim(p)-1}(p)}a_{n_0\cdots n_{\dim(p)-1}}(x_0-c_0)^{n_0}\cdots(x_{\dim(p)-1}-c_{\dim(p)-1})^{n_{\dim(p)-1}} $$

where $n$ and $\deg(p)$ are multi-indices. This differs from the usual upper sum limit $|n|\leq\deg(p)$ where $n$ is a multi-index and $\deg(p)$ a natural number, because this way the degree in every variable can be controlled individually.

Installation

pip install multipoly

Usage

A polynomial can be initialized in two ways:

  • With the constructor Multipoly(a, c=None), that takes the coefficients and optional offsets. The coefficients are of shape deg, that is a tuple with the degree for every variable.
  • By fitting data with Multipoly.fit(X, y, deg, c=None).

MultiPoly objects have

  • a dimension dim, the number of variables &
  • a degree deg, the degrees in its variables.

They can

  • be called on a single datapoint p(x, y, ...) or on multiple datapoints in a 2D numpy.array,
  • rounded p.round(decimals=0), to round coefficients a and offsets c &
  • be converted to strings with toString(symbols=None), where the symbols for its variables can be specified (__str__ defaults to x0, x1, ...).

License (MIT)

Copyright (c) 2023 Sebastian Gössl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multipoly-0.9.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

multipoly-0.9.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file multipoly-0.9.1.tar.gz.

File metadata

  • Download URL: multipoly-0.9.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for multipoly-0.9.1.tar.gz
Algorithm Hash digest
SHA256 08d05b63a6df76f436687e95a18920778a5926a4ea7a2fc2c6d0e6f8d5c32253
MD5 86e393f3cc5b3830b54ed708f6f90837
BLAKE2b-256 90bf4d79cbd433d35ddc3c6946fafccdf2986e95b8ff05022571d00e06d393a4

See more details on using hashes here.

File details

Details for the file multipoly-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: multipoly-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for multipoly-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f052a4c3a3e57fdc88758098c7381a5cf93a71d6fec39b7c517067eeb45afbd
MD5 3ba5eb6aa2c93c6d200efe84266f5959
BLAKE2b-256 c1493735146fb87f04979f353aea937d8837faed7af2913a49ce2644f7758451

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page