Skip to contents

Creates random spray objects as quick-and-dirty examples of multivariate polynomials

Usage

rspray(n=9  , vals = seq_len(n), arity = 3, powers = 0:2)
rsprayy(n=30, vals = seq_len(n), arity = 7, powers = 0:8)

Arguments

n

Number of distinct rows (maximum); repeated rows are merged (argument addrepeats is TRUE)

vals

Values to use for coefficients

arity

Arity of the spray; the number of columns in the index matrix

powers

Set from which to sample the entries of the index matrix

Value

Returns a spray object

Author

Robin K. S. Hankin

Note

If the index matrix contains repeated rows, the returned spray object will contain fewer than n entries

See also

Examples


rspray()
#> 6 +8*a^2 +7*a*b +4*a*b^2*c^2 +8*a^2*b^2 +11*a^2*c +a^2*c^2

rspray(4)*rspray(3,rnorm(3))
#> +1.5136697*a^3*b^4*c +6.0565837*a^2*b^2*c^2 +0.7407928*a^2*b^2*c^3
#> +6.1226568*a^2*b^2*c +3.0273394*a^3*b^4 +2.2223784*a*c^4
#> +3.0651379*a*c^3 +0.1359557*a*c^2

rspray(3,arity=7,powers=-2:2)^3
#> +a^-3*b^3*c^-6*d^6*e^6*g^3 +36*a*b^4*c^-5*d^-1*e*g
#> +6*a^-2*b^4*c^-5*d^2*e^5*f +9*b^3*c^-6*d^3*e^2*f^-1*g^4
#> +36*a^2*b^5*c^-4*d^-5*f*g^-2 +27*a^3*b^3*c^-6*e^-2*f^-2*g^5
#> +12*a^-1*b^5*c^-4*d^-2*e^4*f^2*g^-3 +8*b^6*c^-3*d^-6*e^3*f^3*g^-6
#> +54*a^4*b^4*c^-5*d^-4*e^-3*f^-1*g^2 +27*a^6*b^3*c^-6*d^-3*e^-6*f^-3*g^6

rspray(1000,vals=rnorm(1000))
#> -4.01327510389639 -9.5018981*b*c^2 -1.3028648*b^2*c^2
#> -3.9635428*a*b^2*c -1.625289*b^2*c +10.4978609*a*b^2*c^2 -1.9603868*b*c
#> -7.370476*a*b -0.7462413*a*b^2 -7.9876373*a^2*c^2 -6.6645177*a^2*b*c^2
#> -0.0670641*a^2 +6.4136295*a^2*b -0.0888211*a*c^2 +3.5093108*a^2*b^2
#> +12.5646265*a*b*c^2 +8.1276653*c^2 +2.8431999*a^2*b^2*c^2 -12.943039*a
#> +3.3783639*a*b*c -2.2902092*a^2*c +10.0369957*b -2.9588053*c
#> +5.4976432*b^2 -15.1088858*a^2*b*c -6.2686196*a*c +4.2958776*a^2*b^2*c