Hello Waldek,
I have the following domain in my package.
ModularFunctionExpansionsAtCusps(C, cusps): Exports == Implementation
where
C: CommutativeRing
L ==> QEtaLaurentSeries C
cusps: List Cusp
Exports ==> XEtaGradedAlgebra C with
coerce: XHashTable(Cusp, L) -> %
series: (%, P) -> L
Implementation ==> add
ncusps: P :=
dbgPrint("MFX cusps", cusps)
dbgPrint("MFX ncusps", #cusps)
asP(#cusps)
Rep ==> DirectProduct(ncusps, L)
coerce(t: XHashTable(Cusp, L)): % ==
-- sanity check
errorPrint("coerce keys", keys t)
errorPrint("coerce ncusps", ncusps)
errorPrint("coerce cusps", cusps)
errorPrint("coerce #cusps", #cusps)
sort keys t ~= sort cusps =>
error "keys do not agree with cusps of this domain"
per((directProduct(vector [t.c for c in cusps]))$Rep)
...
That seems to work fine when I call it directly in the interpreter, i.e.
for different lists of cusps, two different domains are created. In
other words I have a function that is given an object from which I
computed the cusps and then I want to call a function from
ModularFunctionExpansionsAtCusps(C, cusps) with exactly those cusps.
However, I need to create that domain dynamically inside a spad program
where I realized that the evaluation for ncusps happens only once which,
of course leads to problems.
As you might expect, it does not help when I replace
Rep ==> DirectProduct(ncusps, L)
by
Rep ==> DirectProduct(#cusps, L)
The problem only moves a bit further down.
The error then shows in the code of DirectProduct of vector.spad.
directProduct z ==
errorPrint("DP dim", dim)
errorPrint("DP size of z", #z)
size?(z, dim) => copy(z)$Rep
error "Not of the correct length"
-- DP dim:=24
-- DP size of z:=23
>> Error detected within library code:
Not of the correct length
There are actually similar constructions in the Jet-code.
https://github.com/fricas/fricas/blob/master/src/algebra/jet.spad#L6809
In fact, it looks even a bit more involved than my code.
I wouldn't want to remove cusps from the parameter list, since then it
would be ugly to add and multiply elements from
ModularFunctionExpansionsAtCusps or I would always have to check lengths
like in Vector(R).
What is the preferred way (workaround) to deal with that problem?
It may be an option for me to rewrite my domain and use dim (=#cusps) as
a domain parameter. But why should an integer behave differently from a
list. Both are non-domain parameters.
Any help is appreciated.
Thank you
Ralf