diff --git a/DESCRIPTION b/DESCRIPTION index 72d486e..31b3cc9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 @@ -33,8 +33,6 @@ LinkingTo: Rcpp, RcppArmadillo, RcppCGAL -Remotes: - stla/ratioOfQsprays Config/testthat/edition: 3 Encoding: UTF-8 RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index c540b20..8c25d00 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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<-") @@ -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) diff --git a/R/show.R b/R/show.R index 9987116..2326ae3 100644 --- a/R/show.R +++ b/R/show.R @@ -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} @@ -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 diff --git a/R/symbolicQspray.R b/R/symbolicQspray.R index 8366651..9d0583a 100644 --- a/R/symbolicQspray.R +++ b/R/symbolicQspray.R @@ -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 @@ -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", diff --git a/R/symmetricPolynomials.R b/R/symmetricPolynomials.R index d1cffbf..3aa0b90 100644 --- a/R/symmetricPolynomials.R +++ b/R/symmetricPolynomials.R @@ -37,6 +37,7 @@ setMethod( ) #' @rdname compactSymmetricQspray +#' @export setMethod( "compactSymmetricQspray", c("symbolicQspray", "missing"), function(qspray, check) { diff --git a/README.Rmd b/README.Rmd index b0fc170..e5f9840 100644 --- a/README.Rmd +++ b/README.Rmd @@ -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. @@ -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: @@ -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. @@ -102,7 +101,7 @@ 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. @@ -110,9 +109,6 @@ 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`. @@ -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 @@ -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) @@ -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: @@ -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) { @@ -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 @@ -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. + + + + +[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" diff --git a/README.md b/README.md index 9d855bc..937a8c0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ The ‘symbolicQspray’ package ================ Stéphane Laurent -2024-04-22 +2024-05-01 ***Multivariate polynomials with symbolic parameters.*** @@ -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. @@ -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: @@ -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) @@ -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 @@ -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 ] @@ -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 @@ -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) @@ -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: @@ -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) { @@ -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 @@ -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. + + diff --git a/man/changeParameters.Rd b/man/changeParameters.Rd index 66d5aa9..3598af4 100644 --- a/man/changeParameters.Rd +++ b/man/changeParameters.Rd @@ -10,7 +10,7 @@ changeParameters(Qspray, newParameters) \item{Qspray}{a \code{symbolicQspray} polynomial} \item{newParameters}{a list containing at least \code{n} \code{qspray} -objects, or objects coercable to \code{qspray} objects, where \code{n} is +objects, or objects coercible to \code{qspray} objects, where \code{n} is the number of parameters in the symbolic polynomial given in the \code{Qspray} argument} } diff --git a/man/changeVariables.Rd b/man/changeVariables.Rd index eef8954..1794317 100644 --- a/man/changeVariables.Rd +++ b/man/changeVariables.Rd @@ -12,7 +12,7 @@ \item{x}{a \code{symbolicQspray} polynomial} \item{listOfQsprays}{a list containing at least \code{n} -\code{symbolicQspray} objects, or objects coercable to +\code{symbolicQspray} objects, or objects coercible to \code{symbolicQspray} objects, where \code{n} is the number of variables in the polynomial given in the \code{x} argument} } diff --git a/man/dSymbolicQspray.Rd b/man/dSymbolicQspray.Rd index 33470ab..4db5bb7 100644 --- a/man/dSymbolicQspray.Rd +++ b/man/dSymbolicQspray.Rd @@ -9,7 +9,10 @@ dSymbolicQspray(Qspray, orders) \arguments{ \item{Qspray}{object of class \code{symbolicQspray}} -\item{orders}{integer vector, the orders of the differentiation} +\item{orders}{integer vector, the orders of the differentiation; e.g. +\code{c(2, 0, 1)} means that you differentiate two times with respect to +\eqn{x}, you do not differentiate with respect to \eqn{y}, and you +differentiate one time with respect to \eqn{z}} } \value{ A \code{symbolicQspray} object. diff --git a/man/derivSymbolicQspray.Rd b/man/derivSymbolicQspray.Rd index 64dcd0d..b92dfa4 100644 --- a/man/derivSymbolicQspray.Rd +++ b/man/derivSymbolicQspray.Rd @@ -9,7 +9,8 @@ derivSymbolicQspray(Qspray, i, derivative = 1) \arguments{ \item{Qspray}{object of class \code{symbolicQspray}} -\item{i}{integer, the dimension to differentiate with respect to} +\item{i}{integer, the dimension to differentiate with respect to, e.g. +\code{2} to differentiate w.r.t. \eqn{y}} \item{derivative}{positive integer, how many times to differentiate} } diff --git a/man/evalSymbolicQspray.Rd b/man/evalSymbolicQspray.Rd index f11de15..f4da7e1 100644 --- a/man/evalSymbolicQspray.Rd +++ b/man/evalSymbolicQspray.Rd @@ -10,10 +10,10 @@ evalSymbolicQspray(Qspray, a = NULL, X = NULL) \item{Qspray}{a \code{symbolicQspray} object} \item{a}{vector of values to be substituted to the parameters; -these values must be coercable to \code{bigq} numbers} +these values must be coercible to \code{bigq} numbers} \item{X}{vector of values to be substituted to the variables; these -values must be coercable to \code{bigq} numbers} +values must be coercible to \code{bigq} numbers} } \value{ If both \code{a} and \code{X} are \code{NULL}, this returns the diff --git a/man/showSymbolicQspray.Rd b/man/showSymbolicQspray.Rd index 11e9e5f..d2a2f17 100644 --- a/man/showSymbolicQspray.Rd +++ b/man/showSymbolicQspray.Rd @@ -32,7 +32,7 @@ within a term} A function which prints a \code{symbolicQspray} object. } \description{ -Print a \code{symbolicQspray} object given a function to print +Prints a \code{symbolicQspray} object given a function to print a \code{ratioOfQsprays} object. } \note{ diff --git a/man/showSymbolicQsprayX1X2X3.Rd b/man/showSymbolicQsprayX1X2X3.Rd index 58f7c43..1a39788 100644 --- a/man/showSymbolicQsprayX1X2X3.Rd +++ b/man/showSymbolicQsprayX1X2X3.Rd @@ -23,7 +23,7 @@ spaces, e.g. \code{"/"}} A function which prints \code{symbolicQspray} objects. } \description{ -Print a \code{symbolicQspray} object. +Prints a \code{symbolicQspray} object. } \note{ This function is built by applying \code{\link{showSymbolicQspray}} to diff --git a/man/substituteParameters.Rd b/man/substituteParameters.Rd index 2614849..6ecdca5 100644 --- a/man/substituteParameters.Rd +++ b/man/substituteParameters.Rd @@ -10,7 +10,7 @@ substituteParameters(Qspray, values) \item{Qspray}{a \code{symbolicQspray} object} \item{values}{vector of values to be substituted to the parameters; these -values must be coercable to \code{bigq} numbers} +values must be coercible to \code{bigq} numbers} } \value{ A \code{qspray} object. diff --git a/man/substituteVariables.Rd b/man/substituteVariables.Rd index 9eb36a5..48a739f 100644 --- a/man/substituteVariables.Rd +++ b/man/substituteVariables.Rd @@ -10,7 +10,7 @@ substituteVariables(Qspray, values) \item{Qspray}{a \code{symbolicQspray} object} \item{values}{vector of values to be substituted to the parameters; these -values must be coercable to \code{bigq} numbers} +values must be coercible to \code{bigq} numbers} } \value{ A \code{ratioOfQsprays} object.