Spad function parameterized by types (or values)?

2 views
Skip to first unread message

Neven Sajko

unread,
Aug 5, 2021, 1:39:49 AM8/5/21
to fricas...@googlegroups.com
Hello,

I want a Spad function parameterized by some constants, but this
function would preferably reside in a package without constructor
parameters.

For example like this:

I ==> Integer
UPLY(var) ==> UnivariatePolynomial(var, Expression(I))
TAY(var) ==> UnivariateTaylorSeries(Expression(I), var, 0)
...
polynomial9(s: TAY(X)): UPLY(X) == univariatePolynomial(s, 9)

The above function polynomial9 should be parameterized by X (the name
of the variable, of type Symbol).

How best to achieve this in Fricas Spad? Do I have to create a new
package just for this function?

In case there is a way to have one parameter, is it also possible to
have multiple parameters?


Thanks,
Neven

Ralf Hemmecke

unread,
Aug 5, 2021, 4:12:20 AM8/5/21
to fricas...@googlegroups.com
> I ==> Integer
> UPLY(var) ==> UnivariatePolynomial(var, Expression(I))
> TAY(var) ==> UnivariateTaylorSeries(Expression(I), var, 0)
> ...
> polynomial9(s: TAY(X)): UPLY(X) == univariatePolynomial(s, 9)
>
> The above function polynomial9 should be parameterized by X (the name
> of the variable, of type Symbol).

And where does the variable X come from?

My impression is that you just want an abbreviation of the following form

polynomial9(s) ==> univariatePolynomial(s, 9)

which is a simple macro. Wouldn't that suffice? Why do you need a
"function"?

Ralf

Waldek Hebisch

unread,
Aug 5, 2021, 7:11:50 AM8/5/21
to fricas...@googlegroups.com
On Thu, Aug 05, 2021 at 05:39:36AM +0000, Neven Sajko wrote:
> Hello,
>
> I want a Spad function parameterized by some constants, but this
> function would preferably reside in a package without constructor
> parameters.
>
> For example like this:
>
> I ==> Integer
> UPLY(var) ==> UnivariatePolynomial(var, Expression(I))
> TAY(var) ==> UnivariateTaylorSeries(Expression(I), var, 0)
> ...
> polynomial9(s: TAY(X)): UPLY(X) == univariatePolynomial(s, 9)
>
> The above function polynomial9 should be parameterized by X (the name
> of the variable, of type Symbol).
>
> How best to achieve this in Fricas Spad? Do I have to create a new
> package just for this function?

In Spad you need extra package with all needed parameters. In
"interpreter" there is a difference: intepreters compiles functions
on demend, so from one source interpreter can produce versions
for multiple types. However, interpreter has its own limitations.

> In case there is a way to have one parameter, is it also possible to
> have multiple parameters?

Interpreter has "modes", that is types with one free parameter,
but they are probably irrelevant to your problem.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages