Is there a more direct or more efficient way to convert a PAdicRational to
PAdicInteger?
Officially, no.
However, there are two ways to get all digits of your rational number.
A) Provide a patch that exposes the representation of PAdicRactional(p)
and fight for it to be included into FriCAS.
B) Get the source code from src/algebra/padic.spad and move some lines
(see below). (Which would give you (A) if you properly put this in your
clone of your github repo of fricas and start a pull request.) Maybe you
should come up with some more telling names for the exported functions.
Look at
https://github.com/fricas/fricas/blob/master/src/algebra/padic.spad#L522
and
https://github.com/fricas/fricas/blob/master/src/algebra/padic.spad#L339
you learn that the representation is given by
https://github.com/fricas/fricas/blob/master/src/algebra/padic.spad#L377
Rep := Record(expon : I, pint : PADIC)
So all you have to do is to move the lines
https://github.com/fricas/fricas/blob/master/src/algebra/padic.spad#L379
https://github.com/fricas/fricas/blob/master/src/algebra/padic.spad#L380
just before
https://github.com/fricas/fricas/blob/master/src/algebra/padic.spad#L371
Then type
)compile padic.spad
and suddenly
PAR ==> PAdicRational 7
(13) -> r := (- 3/49)::PAR
(13)
- 2 - 1 2 3 4 5 6
7 8
4 7 + 6 7 + 6 + 6 7 + 6 7 + 6 7 + 6 7 + 6 7 + 6 7 + 6 7
+ 6 7
+
9
O(7 )
Type: PAdicRational(7)
(14) -> getExpon r
(14) - 2
Type: Integer
(15) -> digits getZp r
(15) [4, 6, 6, 6, 6, 6, 6, 6, 6, 6, ...]
Type: Stream(Integer)
Now for achieving your initial goal in 3 dimensions, you would have to
do a little programming. I put this as an exercise. ;-)
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/9d311ab5-d80c-be9e-14bb-42d8e87da045%40hemmecke.org.