On Sat, Apr 15, 2023 at 08:18:13AM -0700, Sid Andal wrote:
> A matrix of type PAdicRational is defined and saved in a file. However,
> attempting to read it back leads to an error:
> 
> PR ==> PAdicRational(13)
> SQ ==> SQMATRIX(4, PR)
> 
> A : SQ := [[2, 3, 5, 0], [7, 11, 12, 4], [3, 8, 6, 10], [12, 9, 8, 5]]
> 
> typeOf A
> 
> SquareMatrix(4,PAdicRational(13))
> 
> f : File SQ := open("PaMat4x4.out", "output")
> 
> write!(f,A)
> close!(f)
> 
> 
> $ cat PaMat4x4.out
> 
> #2A(((0 2 #1="NullStream") (0 3 #1#) (0 5 #1#) (0 #1#))
>     ((0 7 #1#) (0 11 #1#) (0 12 #1#) (0 4 #1#))
>     ((0 3 #1#) (0 8 #1#) (0 6 #1#) (0 10 #1#))
>     ((0 12 #1#) (0 9 #1#) (0 8 #1#) (0 5 #1#)))
> 
> 
> $ cp PaMat4x4.out PaMat4x4.input
> 
> 
> fn := filename("", "PaMat4x4", "input")$FileName
> 
> f := open(fn, "input")$File(SQ)
> 
> B : SQ := read!(f)
> 
> >> System error:
>    The value "NullStream" is not of type INTEGER.
> 
> Removing the string "NullStream" doesn't seem to help....it leads to
> other types of errors.

As Ralf noted, padic numbers need special support to read/write.
For some reason (maybe bug) this support is not active when using
normal files.  However, it is active in Library.  You can use it like:

(1) -> ll := library("tst.lib")

   (1)  "tst.lib"
                                                                Type: Library
(2) -> PR ==> PAdicRational(13)
                                                                   Type: Void
(3) -> A : PR := 1

   (3)  1
                                                      Type: PAdicRational(13)
(4) -> ll("a") := A

   (4)  1
                                                      Type: PAdicRational(13)
(5) -> Al : List(PR) := [1, 1/4]

   (5)
   [1,

                       2       3       4       5       6       7       8       9
       10 + 9 13 + 9 13  + 9 13  + 9 13  + 9 13  + 9 13  + 9 13  + 9 13  + 9 13
     + 
           10       11
       9 13   + O(13  )
     ]
                                                Type: List(PAdicRational(13))
(6) -> ll("Al") := Al

   (6)
   [1,

                       2       3       4       5       6       7       8       9
       10 + 9 13 + 9 13  + 9 13  + 9 13  + 9 13  + 9 13  + 9 13  + 9 13  + 9 13
     + 
           10       11
       9 13   + O(13  )
     ]
                                                Type: List(PAdicRational(13))
(7) -> Am : SQMATRIX(4, PR) := [[2, 3, 5, 0], [7, 11, 12, 4], [3, 8, 6, 10], 
[12Am : SQMATRIX(4, PR) := [[2, 3, 5, 0], [7, 11, 12, 4], [3, 8, 6, 10], [12, 
9, 8, 5]]

        +2   3   5   0 +
        |              |
        |7   11  12  4 |
   (7)  |              |
        |3   8   6   10|
        |              |
        +12  9   8   5 +
                                      Type: SquareMatrix(4,PAdicRational(13))
(8) -> ll("Am") := Am

        +2   3   5   0 +
        |              |
        |7   11  12  4 |
   (8)  |              |
        |3   8   6   10|
        |              |
        +12  9   8   5 +
                                      Type: SquareMatrix(4,PAdicRational(13))
(9) -> keys(ll)

   (9)  ["Am", "Al", "a"]
                                                           Type: List(String)
(10) -> close!(ll)

   (10)  "tst.lib"
                                                                Type: Library

In new session:

(1) -> ll := library("tst.lib")

   (1)  "tst.lib"
                                                                Type: Library
(2) -> keys(ll)

   (2)  ["Am", "Al", "a"]
                                                           Type: List(String)
(3) -> ll("a")

   (3)  1
                                                      Type: PAdicRational(13)
(4) -> ll("Al")

   (4)
   [1,

                       2       3       4       5       6       7       8       9
       10 + 9 13 + 9 13  + 9 13  + 9 13  + 9 13  + 9 13  + 9 13  + 9 13  + 9 13
     + 
           10       11
       9 13   + O(13  )
     ]
                                                Type: List(PAdicRational(13))
(5) -> ll("Am")

        +2   3   5   0 +
        |              |
        |7   11  12  4 |
   (5)  |              |
        |3   8   6   10|
        |              |
        +12  9   8   5 +
                                      Type: SquareMatrix(4,PAdicRational(13))


-- 
                              Waldek Hebisch

-- 
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/20230415174847.5koipacge773nnnj%40fricas.math.uni.wroc.pl.

Reply via email to