On 3/16/25 12:21, Waldek Hebisch wrote:
On Sun, Mar 16, 2025 at 07:46:43AM +0100, 'Ralf Hemmecke' via FriCAS - computer
algebra system wrote:
I would suggest to avoid creating new kernels in AlgebraicNumber.
At implementation level AlgebraicNumber is essentially a slightly
changed view of Expression(Integer) and IIRC corresponding
kernels live in cache for Kernel(Expression(Integer)).
Aaaahh.... I was just about to test and wondered why the cache for
SortedCache(Kernel(AlgebraicNumber)) printed as empty though I entered
sqrt(2) into the session. Additionally, I get
%%% (1) -> a2:=sqrt(2)
+-+
(1) \|2
Type: AlgebraicNumber
%%% (2) -> k2 := kernels(a2).1
+-+
(2) \|2
Type: Kernel(AlgebraicNumber)
%%% (3) -> position(k2)
(3) 2048
Type: PositiveInteger
%%% (4) -> position(k2)$Kernel(AlgebraicNumber)
(4) 2048
Type: NonNegativeInteger
I added
getCache(): PrimitiveArray S == cache
to SortedCache.
%%% (5) -> getCache()$SortedCache(Kernel(Expression(Integer)))
+-+
(5) [%%var, \|2 , %%var, %%var, %%var, %%var, %%var, %%var, %%var,
%%var]
Type: PrimitiveArray(Kernel(Expression(Integer)))
%%% (6) -> getCache()$SortedCache(Kernel(AlgebraicNumber))
(6) []
Type: PrimitiveArray(Kernel(AlgebraicNumber))
So certainly I must create kernels in Kernel(Expression Integer). That's
a good hint.
However, why position gives such a big number whereas the true position
in the primitive array should actually be 2, is a mystery for me.
Anyhow, if I could ensure all my kernels are truely in Kernel(AN) (which
I probably cannot), then all would be fine?
> BTW: It probably would be better to change our declarations so
> that AlgebraicNumber does not export FunctionSpace, but doing
> that without removing useful operations looks tricky.
Erm, according to https://fricas.github.io/api/AlgebraicNumber.html, it
doesn´t. You probably meant ExpressionSpace.
My first thought was to implement explicitly all those exports in AN via
coercion to E==>Expression(INT), calling the respective function from E
and then converting back the result. But that cannot work without
confusion, because if a result contains Kernel(AN), then an entry in
SortedCache(Kernel(AN)) would be created, and two kernels from AN might
have different positions in SortedCache(Kernel(AN)) and
SortedCache(Kernel(E)). So when k1 < k2 in Kernel(AN) may give a
different result then the one in Kernel(E).
Wait, something must be wrong with my thinking. How would otherwise
getCache()$SortedCache(Kernel(AlgebraicNumber)) still return the empty
list although I clearly have created an element of Kernel(AN) in (2) above?
Thank you
Ralf
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion visit
https://groups.google.com/d/msgid/fricas-devel/66bd3966-e560-4338-b626-49ce1af27394%40hemmecke.org.