Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed May 1, 2024
1 parent 689f864 commit aa84774
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 88 deletions.
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version: 0.0.0.9000
Authors@R:
person("Stéphane", "Laurent", , "laurent_step@outlook.fr", role = c("aut", "cre"))
Description: Introduces the 'symbolicQspray' objects. Such an object
defines a multivariate polynomial whose coefficients are fractions of
represents a multivariate polynomial whose coefficients are fractions of
multivariate polynomials with rational coefficients. The package
allows arithmetic on such polynomials. It is based on the 'qspray' and
'ratioOfQsprays' packages. Some functions for 'qspray' polynomials have
Expand Down Expand Up @@ -33,8 +33,6 @@ LinkingTo:
Rcpp,
RcppArmadillo,
RcppCGAL
Remotes:
stla/ratioOfQsprays
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.3.1
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ importFrom(gmp,c_bigq)
importFrom(methods,new)
importFrom(methods,setAs)
importFrom(methods,setClass)
importFrom(methods,setGeneric)
importFrom(methods,setMethod)
importFrom(methods,show)
importFrom(qspray,"showQsprayOption<-")
Expand Down Expand Up @@ -69,6 +70,5 @@ importFrom(ratioOfQsprays,rRatioOfQsprays)
importFrom(ratioOfQsprays,ratioOfQsprays_from_list)
importFrom(ratioOfQsprays,showRatioOfQspraysX1X2X3)
importFrom(ratioOfQsprays,showRatioOfQspraysXYZ)
importFrom(utils,capture.output)
importFrom(utils,head)
useDynLib(symbolicQspray, .registration=TRUE)
4 changes: 2 additions & 2 deletions R/show.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @title Print a 'symbolicQspray' object
#' @description Print a \code{symbolicQspray} object given a function to print
#' @description Prints a \code{symbolicQspray} object given a function to print
#' a \code{ratioOfQsprays} object.
#'
#' @param showRatioOfQsprays a function which prints a \code{ratioOfQsprays}
Expand Down Expand Up @@ -83,7 +83,7 @@ showSymbolicQspray <- function(
}

#' @title Print a 'symbolicQspray' object
#' @description Print a \code{symbolicQspray} object.
#' @description Prints a \code{symbolicQspray} object.
#'
#' @param a a string, usually a letter, to denote the non-indexed variables
#' of the \code{ratioOfQsprays} coefficients
Expand Down
5 changes: 2 additions & 3 deletions R/symbolicQspray.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#' @importFrom Rcpp evalCpp
#' @importFrom qspray orderedQspray
#' @importFrom ratioOfQsprays as.ratioOfQsprays
#' @importFrom methods setMethod setClass new show setAs
#' @importFrom methods setMethod setClass new show setAs setGeneric
#' @importFrom gmp as.bigq
#' @importFrom utils capture.output
#' @include symbolicQspray.R
NULL

Expand All @@ -22,7 +21,7 @@ setMethod(
)


setAs( # for usage in qspray::MSPcombination
setAs( # for usage in qspray::MSPcombination and unit tests of 'jack'
"qspray", "symbolicQspray", function(from) {
new(
"symbolicQspray",
Expand Down
1 change: 1 addition & 0 deletions R/symmetricPolynomials.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ setMethod(
)

#' @rdname compactSymmetricQspray
#' @export
setMethod(
"compactSymmetricQspray", c("symbolicQspray", "missing"),
function(qspray, check) {
Expand Down
67 changes: 39 additions & 28 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, message = FALSE)
___

These notes about the **symbolicQspray** package assume that the reader is a
bit familiar with the [**qspray** package](https://github.com/stla/qspray)
and the [**ratioOfQsprays** package](https://github.com/stla/ratioOfQsprays).
bit familiar with the [**qspray** package][qspray] and with the
[**ratioOfQsprays** package][ratioOfQsprays].

A `symbolicQspray` object represents a multivariate polynomial whose
coefficients are fractions of polynomials with rational coefficients.
Expand Down Expand Up @@ -51,10 +51,9 @@ X3 <- Qlone(3)
```

The fractions of polynomials such as the first coefficient `a1/(a2^2+1)`
in the above example are
[**ratioOfQsprays**](https://github.com/stla/ratioOfQsprays) objects,
in the above example are [**ratioOfQsprays**][ratioOfQsprays] objects,
and the numerator and the denominator of a `ratioOfQsprays` are
[**qspray**](https://github.com/stla/qspray) objects.
[**qspray**][qspray] objects.

Arithmetic on `symbolicQspray` objects is available:

Expand Down Expand Up @@ -84,7 +83,7 @@ X <- c(4, 3, "2/5")
```

There is a discutable point here. A `symbolicQspray` object represents a
polynomial with `ratioOfQsprays` coefficients. So one can consider
polynomial with `ratioOfQsprays` coefficients. So one could consider
that the polynomial variables `X`, `Y` and `Z` represent some indeterminate
`ratioOfQsprays` fractions, and that it should be possible to replace them
with `ratioOfQsprays` objects. However this is not allowed.
Expand All @@ -102,17 +101,14 @@ Now let's turn to our promised discussion. Why is replacing the values of the
polynomial variables with some `ratioOfQsprays` objects not allowed?

Actually my motivation to do this package was inspired by the
**Jack polynomials**. In the context of Jack polynomials, the variables
[**Jack polynomials**][jack]. In the context of Jack polynomials, the variables
`X`, `Y` and `Z` represent indeterminate *numbers*, and the coefficients
are *numbers depending on a parameter* (the Jack parameter), and it turns out
that they are fractions of polynomials of this parameter.
So I consider that a `symbolicQspray` is *not* a polynomial on the field
of fractions of polynomials: I consider it is a polynomial with
*rational coefficients depending on some parameters*.

By the way, I'm wondering whether I should rename `symbolicQspray` to
`parametricQspray`. Comments?..

Also note that evaluating the `ratioOfQsprays` object
`evalSymbolicQspray(Qspray, X = X)` at `a` would make no sense if we took
some `ratioOfQsprays` objects for the values of `X`.
Expand All @@ -127,15 +123,16 @@ The package provides some functions to perform elementary queries on a
numberOfVariables(Qspray)
numberOfParameters(Qspray)
numberOfTerms(Qspray)
getCoefficient(Qspray, c(2, 1))
getCoefficient(Qspray, c(2, 1)) # coefficient of X^2.Y
getConstantTerm(Qspray)
isUnivariate(Qspray)
isConstant(Qspray)
```


## Transforming a `symbolicQspray`

You can derivate a `symbolicQspray` polynomial:
You can differentiate a `symbolicQspray` polynomial:

```{r}
derivSymbolicQspray(Qspray, 2) # derivative w.r.t. Y
Expand Down Expand Up @@ -190,9 +187,9 @@ to use **symbolicQspray**.

## Application: Jacobi polynomials

The [Jacobi polynomials](https://en.wikipedia.org/wiki/Jacobi_polynomials)
are univariate polynomials depending on two parameters that we will denote by
`alpha` and `beta`. They are implemented in this package:
The [Jacobi polynomials][jacobi] are univariate polynomials depending on two
parameters that we will denote by `alpha` and `beta`. They are implemented in
this package:

```{r}
JP <- JacobiPolynomial(2)
Expand All @@ -204,7 +201,7 @@ JP
```

The implementation constructs these polynomials by using the
[recurrence relation](https://en.wikipedia.org/wiki/Jacobi_polynomials#Recurrence_relations).
[recurrence relation][jacobirecurrence].
This is a child game, one just has to copy the first two terms and this
recurrence relation:

Expand Down Expand Up @@ -245,12 +242,10 @@ JP <- JacobiPolynomial(7)
hasPolynomialCoefficientsOnly(JP)
```

Up to a factor, the
[Gegenbauer polynomials](https://en.wikipedia.org/wiki/Gegenbauer_polynomials)
with parameter `alpha` coincide with the Jacobi polynomials with parameters
`alpha - 1/2` and `alpha - 1/2`. Let's derive them from the Jacobi polynomials,
as an exercise. The factor can be implemented as follows (see Wikipedia for its
formula):
Up to a factor, the [Gegenbauer polynomials][gegenbauer] with parameter `alpha`
coincide with the Jacobi polynomials with parameters `alpha - 1/2` and
`alpha - 1/2`. Let's derive them from the Jacobi polynomials, as an exercise.
The factor can be implemented as follows (see Wikipedia for its formula):

```{r}
risingFactorial <- function(theta, n) {
Expand All @@ -274,7 +269,8 @@ GegenbauerPolynomial <- function(n) {
}
```

Let's check the recurrence relation given in the Wikipedia article is fulfilled:
Let's check that the recurrence relation given in the Wikipedia article is
fulfilled:

```{r}
n <- 5
Expand All @@ -288,8 +284,23 @@ X <- Qlone(1)

## Application to Jack polynomials

The **symbolicQspray** package is used by the
[**jack** package](https://github.com/stla/jackR) to compute the Jack
polynomials with a symbolic Jack parameter. The Jack polynomials exactly fit to
the polynomials represented by the `symbolicQspray` objects: their coefficients
are fractions of polynomials by definition, of one variable: the Jack parameter.
The **symbolicQspray** package is used in the [**jack** package][jack] to
compute the Jack polynomials with a symbolic Jack parameter. The Jack
polynomials exactly fit to the polynomials represented by the `symbolicQspray`
objects: their coefficients are fractions of polynomials by definition, of one
variable: the Jack parameter.


<!-- -------------------- links -------------------- -->

[qspray]: https://github.com/stla/qspray "the 'qspray' package on Github"

[ratioOfQsprays]: https://github.com/stla/ratioOfQsprays "the 'ratioOfQsprays' package on Github"

[jack]: https://github.com/stla/jackR "the 'jack' package on Github"

[gegenbauer]: https://en.wikipedia.org/wiki/Gegenbauer_polynomials "Gegenbauer polynomials on Wikipedia"

[jacobi]: https://en.wikipedia.org/wiki/Jacobi_polynomials "Jacobi polynomials on Wikipedia"

[jacobirecurrence]: https://en.wikipedia.org/wiki/Jacobi_polynomials#Recurrence_relations "recurrence relation between Jacobi polynomials"
84 changes: 43 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The ‘symbolicQspray’ package
================
Stéphane Laurent
2024-04-22
2024-05-01

***Multivariate polynomials with symbolic parameters.***

Expand All @@ -14,8 +14,9 @@ Stéphane Laurent

These notes about the **symbolicQspray** package assume that the reader
is a bit familiar with the [**qspray**
package](https://github.com/stla/qspray) and the [**ratioOfQsprays**
package](https://github.com/stla/ratioOfQsprays).
package](https://github.com/stla/qspray "the 'qspray' package on Github")
and with the [**ratioOfQsprays**
package](https://github.com/stla/ratioOfQsprays "the 'ratioOfQsprays' package on Github").

A `symbolicQspray` object represents a multivariate polynomial whose
coefficients are fractions of polynomials with rational coefficients.
Expand Down Expand Up @@ -47,9 +48,10 @@ X3 <- Qlone(3)

The fractions of polynomials such as the first coefficient `a1/(a2^2+1)`
in the above example are
[**ratioOfQsprays**](https://github.com/stla/ratioOfQsprays) objects,
and the numerator and the denominator of a `ratioOfQsprays` are
[**qspray**](https://github.com/stla/qspray) objects.
[**ratioOfQsprays**](https://github.com/stla/ratioOfQsprays "the 'ratioOfQsprays' package on Github")
objects, and the numerator and the denominator of a `ratioOfQsprays` are
[**qspray**](https://github.com/stla/qspray "the 'qspray' package on Github")
objects.

Arithmetic on `symbolicQspray` objects is available:

Expand Down Expand Up @@ -85,11 +87,11 @@ X <- c(4, 3, "2/5")
```

There is a discutable point here. A `symbolicQspray` object represents a
polynomial with `ratioOfQsprays` coefficients. So one can consider that
the polynomial variables `X`, `Y` and `Z` represent some indeterminate
`ratioOfQsprays` fractions, and that it should be possible to replace
them with `ratioOfQsprays` objects. However this is not allowed. We will
discuss that, just after checking the consistency:
polynomial with `ratioOfQsprays` coefficients. So one could consider
that the polynomial variables `X`, `Y` and `Z` represent some
indeterminate `ratioOfQsprays` fractions, and that it should be possible
to replace them with `ratioOfQsprays` objects. However this is not
allowed. We will discuss that, just after checking the consistency:

``` r
evalSymbolicQspray(Qspray, a = a, X = X)
Expand All @@ -111,17 +113,15 @@ Now let’s turn to our promised discussion. Why is replacing the values
of the polynomial variables with some `ratioOfQsprays` objects not
allowed?

Actually my motivation to do this package was inspired by the **Jack
polynomials**. In the context of Jack polynomials, the variables `X`,
`Y` and `Z` represent indeterminate *numbers*, and the coefficients are
*numbers depending on a parameter* (the Jack parameter), and it turns
out that they are fractions of polynomials of this parameter. So I
consider that a `symbolicQspray` is *not* a polynomial on the field of
fractions of polynomials: I consider it is a polynomial with *rational
coefficients depending on some parameters*.

By the way, I’m wondering whether I should rename `symbolicQspray` to
`parametricQspray`. Comments?..
Actually my motivation to do this package was inspired by the [**Jack
polynomials**](https://github.com/stla/jackR "the 'jack' package on Github").
In the context of Jack polynomials, the variables `X`, `Y` and `Z`
represent indeterminate *numbers*, and the coefficients are *numbers
depending on a parameter* (the Jack parameter), and it turns out that
they are fractions of polynomials of this parameter. So I consider that
a `symbolicQspray` is *not* a polynomial on the field of fractions of
polynomials: I consider it is a polynomial with *rational coefficients
depending on some parameters*.

Also note that evaluating the `ratioOfQsprays` object
`evalSymbolicQspray(Qspray, X = X)` at `a` would make no sense if we
Expand All @@ -139,7 +139,7 @@ numberOfParameters(Qspray)
## [1] 2
numberOfTerms(Qspray)
## [1] 3
getCoefficient(Qspray, c(2, 1))
getCoefficient(Qspray, c(2, 1)) # coefficient of X^2.Y
## [ a1 ] %//% [ a2^2 + 1 ]
getConstantTerm(Qspray)
## [ a1 ] %//% [ a2 ]
Expand All @@ -151,7 +151,7 @@ isConstant(Qspray)

## Transforming a `symbolicQspray`

You can derivate a `symbolicQspray` polynomial:
You can differentiate a `symbolicQspray` polynomial:

``` r
derivSymbolicQspray(Qspray, 2) # derivative w.r.t. Y
Expand Down Expand Up @@ -212,9 +212,9 @@ order to use **symbolicQspray**.
## Application: Jacobi polynomials

The [Jacobi
polynomials](https://en.wikipedia.org/wiki/Jacobi_polynomials) are
univariate polynomials depending on two parameters that we will denote
by `alpha` and `beta`. They are implemented in this package:
polynomials](https://en.wikipedia.org/wiki/Jacobi_polynomials "Jacobi polynomials on Wikipedia")
are univariate polynomials depending on two parameters that we will
denote by `alpha` and `beta`. They are implemented in this package:

``` r
JP <- JacobiPolynomial(2)
Expand All @@ -229,7 +229,7 @@ JP
```

The implementation constructs these polynomials by using the [recurrence
relation](https://en.wikipedia.org/wiki/Jacobi_polynomials#Recurrence_relations).
relation](https://en.wikipedia.org/wiki/Jacobi_polynomials#Recurrence_relations "recurrence relation between Jacobi polynomials").
This is a child game, one just has to copy the first two terms and this
recurrence relation:

Expand Down Expand Up @@ -272,11 +272,11 @@ hasPolynomialCoefficientsOnly(JP)
```

Up to a factor, the [Gegenbauer
polynomials](https://en.wikipedia.org/wiki/Gegenbauer_polynomials) with
parameter `alpha` coincide with the Jacobi polynomials with parameters
`alpha - 1/2` and `alpha - 1/2`. Let’s derive them from the Jacobi
polynomials, as an exercise. The factor can be implemented as follows
(see Wikipedia for its formula):
polynomials](https://en.wikipedia.org/wiki/Gegenbauer_polynomials "Gegenbauer polynomials on Wikipedia")
with parameter `alpha` coincide with the Jacobi polynomials with
parameters `alpha - 1/2` and `alpha - 1/2`. Let’s derive them from the
Jacobi polynomials, as an exercise. The factor can be implemented as
follows (see Wikipedia for its formula):

``` r
risingFactorial <- function(theta, n) {
Expand All @@ -300,8 +300,8 @@ GegenbauerPolynomial <- function(n) {
}
```

Let’s check the recurrence relation given in the Wikipedia article is
fulfilled:
Let’s check that the recurrence relation given in the Wikipedia article
is fulfilled:

``` r
n <- 5
Expand All @@ -315,9 +315,11 @@ X <- Qlone(1)

## Application to Jack polynomials

The **symbolicQspray** package is used by the [**jack**
package](https://github.com/stla/jackR) to compute the Jack polynomials
with a symbolic Jack parameter. The Jack polynomials exactly fit to the
polynomials represented by the `symbolicQspray` objects: their
coefficients are fractions of polynomials by definition, of one
variable: the Jack parameter.
The **symbolicQspray** package is used in the [**jack**
package](https://github.com/stla/jackR "the 'jack' package on Github")
to compute the Jack polynomials with a symbolic Jack parameter. The Jack
polynomials exactly fit to the polynomials represented by the
`symbolicQspray` objects: their coefficients are fractions of
polynomials by definition, of one variable: the Jack parameter.

<!-- -------------------- links -------------------- -->
2 changes: 1 addition & 1 deletion man/changeParameters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aa84774

Please sign in to comment.