Downloaded the padic.spad from github and made the recommended 
modifications (moving up lines with getExpon and getZp) and compiled.

In addition, the attached file, als.input, was also modified per the 
following:


pR := PAdicRational(11)
pI := PAdicInteger(11)
ll := [[[10, 7], [3, 8]], [[9, 2], [5, 1]]]
AP := ALGSC(pR, 2, ['A, 'B], ll)
qF := Fraction(Integer)
BP := ALGSC(qF, 2, ['A, 'B], ll)
V := basis()$AP
(A, B) := (V(1), V(2))

gen_digs2(d1 : Stream(Integer), d2 : Stream(Integer)) : Stream(BP) ==
  (delay$Stream(BP))(
    () : Stream(BP) +->
         ed1 := empty?(d1)
         ed2 := empty?(d2)
         ed1 and ed2 => empty()$Stream(BP)
         c1 : Integer
         if ed2 then
             c1 := 0
         else
             c1 := frst(d1)
             d1 := rst(d1)
         c2 : Integer
         if ed2 then
             c2 := 0
         else
             c2 := frst(d2)
             d2 := rst(d2)
         bv := represents(vector([c1::qF, c2::qF]))$BP
         cons(bv, gen_digs2(d1, d2))
   )

my_pr(n : Integer) : OutputForm == 11::OutputForm ^ (n::OutputForm)

mS := ModuleTaylorSeries(qF, BP, my_pr)

dW(x) == digits(retract(x)@pI)

pds(W : AP) : mS ==
    cW := coordinates(W)
    series(gen_digs2(dW(cW(1)), dW(cW(2))))$mS


Here are a few examples of the applications of pds on vectors:


(14) -> D : AP := 654 * A + 488 * B

                            2                                  2
   (14)  (4 + 4 11 )B + (5 + 4 11 + 5 11 )A
(15) -> typeOf(D)

   (15)
  
AlgebraGivenByStructuralConstants(PAdicRational(11),2,[A,B],[[[10,7],[3,8]],[
  [9,2],[5,1]]])
(16) -> 
(16) -> pds(D)
   Compiling function dW with type PAdicRational(11) -> Stream(Integer)
      
   Compiling function gen_digs2 with type (Stream(Integer), Stream(
      Integer)) -> Stream(AlgebraGivenByStructuralConstants(Fraction(
      Integer),2,[A,B],[[[10,7],[3,8]],[[9,2],[5,1]]])) 
   Compiling function pds with type AlgebraGivenByStructuralConstants(
      PAdicRational(11),2,[A,B],[[[10,7],[3,8]],[[9,2],[5,1]]]) -> 
      ModuleTaylorSeries(Fraction(Integer),
      AlgebraGivenByStructuralConstants(Fraction(Integer),2,[A,B],[[[10
      ,7],[3,8]],[[9,2],[5,1]]]),theMap(*1;my_pr;1;frame1)) 

                                           1                          2
   (16)  4 B + 5 A + 4 A 11  + (4 B + 5 A)11
(17) -> 


However, in the following example it complains:


(17) -> F : AP := 1234 * A + 5678 * B

                                         2           3                     
                2
   (17)  (2 + 10 11 + 2 11  + 4 11 )B + (2 + 2 11 + 10 11 )A
(18) -> 
(18) -> pds(F)

 
   >> System error:
   Argument X is not a NUMBER: "NullStream"

(18) ->

It seems pds works on some but not on all vectors.

On Wednesday, April 26, 2023 at 9:19:37 PM UTC-5 Waldek Hebisch wrote:

> On Sat, Apr 22, 2023 at 02:41:55PM -0700, Sid Andal wrote:
> > The following 2D example describes the problem:
> > 
> > PR ==> PAdicRational(11)
> > SQ ==> SQMATRIX(2, PR)
> > LS ==> List SQ
> > 
> > M : SQ := [[10, 7], [3, 8]]
> > 
> > ┌10 7┐
> > (4) │ │
> > └3 8┘
> > 
> > N : SQ := [[9, 2], [5, 1]]
> > 
> > ┌9 2┐
> > (5) │ │
> > └5 1┘
> > 
> > S : LS := [M, N]
> > 
> > ┌10 7┐ ┌9 2┐
> > (6) [│ │, │ │]
> > └3 8┘ └5 1┘
> > 
> > AP := ALGSC(PR, 2, ['A, 'B], S)
> > 
> > (7)
> > 
> > 
> AlgebraGivenByStructuralConstants(PAdicRational(11),2,[A,B],[[[10,7],[3,8]],[
> > [9,2],[5,1]]])
> > 
> > V := basis()$AP
> > 
> > (8) [A, B]
> > (A, B) := (V.1, V.2)
> > 
> > (9) B
> > 
> > )clear p M N S V
> > 
> > (10) -> (U, V, W) : AP
> > (11) -> U := 9*A + 10*B
> > 
> > (11) 10 B + 9 A
> > (12) -> V := 8*A + 7*B
> > 
> > (12) 7 B + 8 A
> > (13) -> W := U*V
> > 
> > 2 
> > 2 3
> > (13) (1 + 3 11 + 10 11 )B + (3 + 2 11 + 5 11 + 11 )A
> > (14) ->
> > 
> > All scalar coefs are padic integers and an algebra over the ring
> > of padic integers would've been sufficient. However, ALGSC requires
> > the Ring to be a Field, so, PAdicRational was chosen, instead.
>
> Well, basic things in ALGSC work for CommutativeRing, it is relatively
> simple change to allow CommutativeRing. Field is needed to have
> equation solvers, which is needed for example for LeftUnit. In
> principle equation solving can be done for PrincipalIdealDomain,
> so for Integer or PAdicInteger. However, that would require more
> work.
>
> > The problem now is to rewrite the product W into the following form
> > or into something equivalent:
> > 
> > 2 3
> > (B + 3A) + (3B + 2A)11 + (10B + 5A)11 + A 11
> > 
> > where the powers of the prime (11, in this case) are factored out.
>
> You did not write what you consider "rewrite"? Basically, in FriCAS
> you need a domain to represent your values. I attach a simple domain
> which is only good for printing, but you probably want more.
>
> To try it you need newest FriCAS from git ('retract' from padic
> rationals to padic integer is implemented only in git version).
> Compile the attached Spad file. Then ')read' the attached
> input file. Final line of outut is:
>
> 1 2 11
> (17) B + 3 A + (3 B + 2 A)11 + (10 B + 5 A)11 + O(11 )
> Type: 
> ModuleTaylorSeries(Fraction(Integer),AlgebraGivenByStructuralConstants(Fraction(Integer),2,[A,B],[[[10,7],[3,8]],[[9,2],[5,1]]]),theMap(*1;my_pr;1;frame1)
>
> which IIUC is what you want
>
> -- 
> 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 fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/97bcd8da-9192-4b05-865e-a066031cafe8n%40googlegroups.com.

Reply via email to