MyNixOS website logo
Description

Fast Symbolic Multivariate Polynomials.

Fast manipulation of symbolic multivariate polynomials using the 'Map' class of the Standard Template Library. The package uses print and coercion methods from the 'mpoly' package (Kahle 2013, "Multivariate polynomials in R", The R Journal, 5(1):162), but offers speed improvements. It is comparable in speed to the 'spray' package for sparse arrays, but retains the symbolic benefits of 'mpoly'. To cite the package in publications, use Hankin 2022 <doi:10.48550/ARXIV.2210.15991>. Uses 'disordR' discipline.

Fast symbolic multivariate polynomials in R

Overview

Multivariate polynomials are intereresting and useful objects. Here I present the mvp package which hopefully improves upon previous R functionality provided by the packages multipol, mpoly, and spray. The mvp package follows mpoly in using a symbolic, rather than numeric, representation of a multivariate polynomial; but it offers speed advantages over mpoly. mvp uses the excellent print and coercion methods of the mpoly package. mvp includes some pleasing substitution idiom not found elsewhere; it is theoretically comparable in speed to the spray package and I present some timings in the package vignette.

The mvp package uses C++’s STL map class for efficiency, which has the downside that the order of the terms, and the order of the symbols within each term, is undefined. This does not matter as the mathematical value of a multivariate polynomial is unaffected by reordering; and the print method (taken from mpoly) does a good job in producing human-readable output.

Installation

You can install the released version of mvp from CRAN with:

# install.packages("mvp")  # uncomment this to install the package
library("mvp")

The mvp package in use

Creating a multivariate polynomial is straightforward:

X <- as.mvp("1 + a^2 + a*b*c^3")
X
#> mvp object algebraically equal to
#> 1 + a b c^3 + a^2

and arithmetic operations work as expected:

Y <- as.mvp("12*a^2  + b - c^2 + 4*d")
X+Y
#> mvp object algebraically equal to
#> 1 + a b c^3 + 13 a^2 + b - c^2 + 4 d
X-3*Y
#> mvp object algebraically equal to
#> 1 + a b c^3 - 35 a^2 - 3 b + 3 c^2 - 12 d
X^2
#> mvp object algebraically equal to
#> 1 + 2 a b c^3 + 2 a^2 + a^2 b^2 c^6 + 2 a^3 b c^3 + a^4

Substitution uses the subs() function:

X
#> mvp object algebraically equal to
#> 1 + a b c^3 + a^2
subs(X,a=1)
#> mvp object algebraically equal to
#> 2 + b c^3
subs(X,a=1,b=2)
#> mvp object algebraically equal to
#> 2 + 2 c^3
subs(X,a=1,b=2,c=3)
#> [1] 56
subs(X+Y,a="1+x^2",b="x+y",c=0)
#> mvp object algebraically equal to
#> 14 + 4 d + x + 26 x^2 + 13 x^4 + y

Further information

For more detail, see the package vignette

vignette("mvp")

Metadata

Version

1.0-14

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows