Two copies of Float

7 views
Skip to first unread message

Ralf Hemmecke

unread,
Jul 9, 2024, 12:00:47 PM (8 days ago) Jul 9
to fricas-devel
Currently, I have a WIP implementation of rootFactor for algebraic
numbers that builds on DoubleFloat to check whether an algebraic number
is real and/or positive. With that I restrict the factoring in such a
way that the value of the algebraic number will not change during that
factorization.

Unfortunately, that does of course not work for all cases because of
possible DoubleFloat overflow. So I would like to use a private copy of
Float inside that package so that I can change the precision to my
liking without influencing or being influenced by the setting of the
global Float domain.

Can I force the compiler to create a private copy of Float? How?

Thank you
Ralf

Waldek Hebisch

unread,
Jul 9, 2024, 12:15:30 PM (8 days ago) Jul 9
to fricas...@googlegroups.com
You would have to copy the source. Current approach is just set
precision as needed in pattern like

foo() ==
l := bits();
try
-- set new precision
bits(128)
-- do work
finally
bits(l)

The 'finally' part is executed both in case of normal exit and
in case of error. So using this pattern you will not change
"otside" precision. And you may count of called routines to
respect your precision.

--
Waldek Hebisch

Ralf Hemmecke

unread,
Jul 10, 2024, 8:57:23 AM (8 days ago) Jul 10
to fricas...@googlegroups.com
> foo() ==
> l := bits();
> try
> -- set new precision
> bits(128)
> -- do work
> finally
> bits(l)

Thank you.

Unfortunately, I only find such a construction used in the library in
particuar in special2.spad, but it is not yet anywhere documented. :-(

Ralf
Reply all
Reply to author
Forward
0 new messages