Mhh, interesting.

In the REPL it works:
A=matrix([[0,0,0,0],[1/2,0,0,0],[0,1/2,0,0],[0,0,1,0]])*AA.one()
ok
and:
sage: A.parent().is_exact()
True

But an other problem happens:
The class "RungeKutta" (the parent class of RK4) as a test:

class RungeKutta(SageObject):
def __init__(self,A,B,Title,C=[]):
        if not A.parent().is_exact():
         <raise an Exception">

and I get the exception, which seems to mean that, seen from the RungeKutta class the parent af A is not exact.

Then putting a
print(A.parent())
just before the test in the constructor of RungeKutta, I get:

Full MatrixSpace of 4 by 4 dense matrices over Real Double Field

which, for me, is very surprising... why ?

Thank you!

thierry


Le 21/04/2025 à 11:05, pedritomele...@gmail.com a écrit :
Hi,
I would do
A=matrix([[0,0,0,0],[1/2,0,0,0],[0,1/2,0,0],[0,0,1,0]])*AA.one()
B=vector([1/6,2/6,2/6,1/6])*AA.one()
Best, Pedro

El lun, 21 abr 2025 a las 10:35, Thierry Dumont (<tdum...@math.univ- lyon1.fr <mailto:tdum...@math.univ-lyon1.fr>>) escribió:

    May be this problem is trivial (RTFM...) but:

    1) Suppose I run this in the REPL:

    from sage.all import *
    from rkkit.RKRungeKutta import * #my code
    class RK4(RungeKutta):
          def __init__(self):
              title="Classical Runge-Kutta 4 explicit method"
              A=matrix(AA,[[0,0,0,0],[1/2,0,0,0],[0,1/2,0,0],[0,0,1,0]])
              B=vector(AA,[1/6,2/6,2/6,1/6])
              super().__init__(A,B,title)


    then I can do:

    R=RK4()
    everything is ok.

    2) Now, in a directory "methods" I put the same piece of code as above
    in a file called "RK4.py".

    I add a file __init__.py in methods/, which is:

    from sage.all import *
    from rkkit.RKRungeKutta import *
    __all__=["RK4"]

    So, I have
    methods/
       __init__.py
       RK4.py

    Now, typing:

    from methods import *
    R=RK4.RK4()

    I get the error message:

    typeError: Illegal initializer for algebraic number

    How can I avoid this?

    (something like putting Integer() around the elements of the list in
    matrix(AA,[[0,0,0,0],[1/2,0,0,0],[0,1/2,0,0],[0,0,1,0]])
    is something I want (need) to avoid).

    Yours,
    Thierry

-- You received this message because you are subscribed to the Google
    Groups "sage-support" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to sage-support+unsubscr...@googlegroups.com
    <mailto:sage-support%2bunsubscr...@googlegroups.com>.
    To view this discussion visit https://groups.google.com/d/msgid/
    sage-support/9fbe6b5b-1bd1-4bf2-bc66-ee0ff7343826%40math.univ-
    lyon1.fr <https://groups.google.com/d/msgid/sage-
    support/9fbe6b5b-1bd1-4bf2-bc66-ee0ff7343826%40math.univ-lyon1.fr>.

--
You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com <mailto:sage- support+unsubscr...@googlegroups.com>. To view this discussion visit https://groups.google.com/d/msgid/sage- support/ CAOAJP6qRM47LOaFx_nQhmubGELzfj_f8ASkQfP%3D5aZkG2DOSdA%40mail.gmail.com <https://groups.google.com/d/msgid/sage-support/ CAOAJP6qRM47LOaFx_nQhmubGELzfj_f8ASkQfP%3D5aZkG2DOSdA%40mail.gmail.com? utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/sage-support/b5590e4a-7628-4782-9bde-0cc96f39151b%40math.univ-lyon1.fr.

Reply via email to