Skip to content

Commit

Permalink
pretty printing for elliptic curves and their points
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrandhorst committed Nov 8, 2024
1 parent 39fc9cb commit b083fab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
21 changes: 19 additions & 2 deletions src/EllCrv/EllCrv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,23 @@ end
#
################################################################################

function show(io::IO, ::MIME"text/plain", E::EllipticCurve)
io = pretty(io)
println(io, "Elliptic curve with equation")
print(io, Indent())
_print_equation(io, E)
print(io, Dedent())
end

function show(io::IO, E::EllipticCurve)
print(io, "Elliptic curve with equation\n")
io = pretty(io)
print(io, "Elliptic curve with equation ")
print(io, Indent())
_print_equation(io, E)
print(io, Dedent())
end

function _print_equation(io::IO, E::EllipticCurve)
a1, a2, a3, a4, a6 = a_invariants(E)
sum = Expr(:call, :+)
push!(sum.args, Expr(:call, :^, :y, 2))
Expand Down Expand Up @@ -831,8 +846,10 @@ function show(io::IO, E::EllipticCurve)
print(io, AbstractAlgebra.expr_to_string(AbstractAlgebra.canonicalize(sum)))
end


function show(io::IO, P::EllipticCurvePoint)
print(io, "Point ($(P[1]) : $(P[2]) : $(P[3])) of $(P.parent)")
io = pretty(io)
print(io, "($(P[1]) : $(P[2]) : $(P[3]))")
end


Expand Down
13 changes: 7 additions & 6 deletions src/EllCrv/Isomorphisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -615,15 +615,16 @@ end
#
################################################################################


function show(io::IO, f::EllCrvIso)
function show(io::IO, ::MIME"text/plain", f::EllCrvIso)
io = pretty(io)
E1 = domain(f)
E2 = codomain(f)
fx, fy, fz = rational_maps(f)
print(io, "Isomorphism from
$(E1) to \n
$(E2) given by \n
(x : y : 1) -> ($(fx) : $(fy) : $(fz) )")
println(io, "Isomorphism")
println(io, Indent(), "from ", E1)
println(io, "to ", E2)
print(io,"given by ")
print(io, "(x : y : 1) -> ($(fx) : $(fy) : $(fz) )")
end

################################################################################
Expand Down

0 comments on commit b083fab

Please sign in to comment.