From c9962948c2a1f2851b35bbdace31f3336593d630 Mon Sep 17 00:00:00 2001 From: "David K. Zhang" Date: Sat, 7 Sep 2024 11:11:18 -0700 Subject: [PATCH] fix repr --- Manifest.toml | 43 +++++++--------------------- Project.toml | 9 ++++-- src/MultiFloats.jl | 71 +++++++++++++++++++++++++++++++++------------- 3 files changed, 70 insertions(+), 53 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index 908184c..03896c6 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,28 +1,21 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.0" +julia_version = "1.10.5" manifest_format = "2.0" -project_hash = "7eaccf21dc5611e80b3246ee4f7b04cbde37de4e" +project_hash = "48e6c585e40f6629013d65798df0e6e96a2696cf" [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" -[[deps.Base64]] -uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" - [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.0.5+1" +version = "1.1.1+0" [[deps.Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" -[[deps.InteractiveUtils]] -deps = ["Markdown"] -uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" - [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -30,29 +23,22 @@ uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -[[deps.Logging]] -uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" - -[[deps.Markdown]] -deps = ["Base64"] -uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" - [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.23+2" +version = "0.3.23+4" [[deps.PrecompileTools]] deps = ["Preferences"] -git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" +git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f" uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" -version = "1.2.0" +version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" +git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.1" +version = "1.4.3" [[deps.Printf]] deps = ["Unicode"] @@ -68,26 +54,19 @@ version = "0.7.0" [[deps.SIMD]] deps = ["PrecompileTools"] -git-tree-sha1 = "d8911cc125da009051fb35322415641d02d9e37f" +git-tree-sha1 = "2803cab51702db743f3fda07dd1745aadfbf43bd" uuid = "fdea26ae-647d-5447-a871-4b548cad5224" -version = "3.4.6" - -[[deps.Serialization]] -uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" +version = "3.5.0" [[deps.TOML]] deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" version = "1.0.3" -[[deps.Test]] -deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] -uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - [[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.8.0+1" +version = "5.11.0+0" diff --git a/Project.toml b/Project.toml index 9ad24b8..eecaf4f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,15 +1,20 @@ name = "MultiFloats" uuid = "bdf0d083-296b-4888-a5b6-7498122e68a5" authors = ["David K. Zhang "] -version = "2.0.2" +version = "2.1.0" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SIMD = "fdea26ae-647d-5447-a871-4b548cad5224" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] julia = "^1.6" SIMD = "^3" + +[extras] +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Test"] diff --git a/src/MultiFloats.jl b/src/MultiFloats.jl index 6cac123..fe9b023 100644 --- a/src/MultiFloats.jl +++ b/src/MultiFloats.jl @@ -771,13 +771,60 @@ function _call_big(f::F, x::_MF{T,N}, p::Int) where {F,T,N} end -function Base.show(io::IO, x::_MF{T,N}) where {T,N} +function Base.print(io::IO, x::_MF{T,N}) where {T,N} + _call_big(y -> print(io, y), x) + return nothing +end + + +function Base.print(io::IO, x::_MFV{M,T,N}) where {M,T,N} + write(io, '<') + print(io, M) + write(io, " x ") + print(io, T) + write(io, " x ") + print(io, N) + write(io, ">[") + for i = 1:M + if i > 1 + write(io, ", ") + end + _call_big(y -> print(io, y), x[i]) + end + write(io, ']') + return nothing +end + + +function Base.show(io::IO, ::MIME"text/plain", x::_MF{T,N}) where {T,N} _call_big(y -> show(io, y), x) return nothing end function Base.show(io::IO, x::_MFV{M,T,N}) where {M,T,N} + show(io, _MFV{M,T,N}) + write(io, "((") + for i = 1:N + if i > 1 + write(io, ", ") + end + show(io, Vec{M,T}) + write(io, "((") + for j = 1:M + if j > 1 + write(io, ", ") + end + show(io, x._limbs[i][j]) + end + write(io, "))") + end + write(io, "))") + return nothing +end + + +function Base.show(io::IO, ::MIME"text/plain", x::_MFV{M,T,N}) where {M,T,N} write(io, '<') show(io, M) write(io, " x ") @@ -1272,24 +1319,10 @@ end end -@inline rsqrt(x::_MF{Float64,1}) = _rsqrt(x, Val{0}()) -@inline rsqrt(x::_MF{Float64,2}) = _rsqrt(x, Val{1}()) -@inline rsqrt(x::_MF{Float64,3}) = _rsqrt(x, Val{2}()) -@inline rsqrt(x::_MF{Float64,4}) = _rsqrt(x, Val{2}()) -@inline rsqrt(x::_MF{Float64,5}) = _rsqrt(x, Val{3}()) -@inline rsqrt(x::_MF{Float64,6}) = _rsqrt(x, Val{3}()) -@inline rsqrt(x::_MF{Float64,7}) = _rsqrt(x, Val{4}()) -@inline rsqrt(x::_MF{Float64,8}) = _rsqrt(x, Val{4}()) - - -@inline rsqrt(x::_MFV{M,Float64,1}) where {M} = _rsqrt(x, Val{0}()) -@inline rsqrt(x::_MFV{M,Float64,2}) where {M} = _rsqrt(x, Val{1}()) -@inline rsqrt(x::_MFV{M,Float64,3}) where {M} = _rsqrt(x, Val{2}()) -@inline rsqrt(x::_MFV{M,Float64,4}) where {M} = _rsqrt(x, Val{2}()) -@inline rsqrt(x::_MFV{M,Float64,5}) where {M} = _rsqrt(x, Val{3}()) -@inline rsqrt(x::_MFV{M,Float64,6}) where {M} = _rsqrt(x, Val{3}()) -@inline rsqrt(x::_MFV{M,Float64,7}) where {M} = _rsqrt(x, Val{4}()) -@inline rsqrt(x::_MFV{M,Float64,8}) where {M} = _rsqrt(x, Val{4}()) +@inline rsqrt(x::_MF{T,1}) where {T} = _rsqrt(x, Val{0}()) +@inline rsqrt(x::_MF{T,N}) where {T,N} = _rsqrt(x, Val{(N + 1) >> 1}()) +@inline rsqrt(x::_MFV{M,T,1}) where {M,T} = _rsqrt(x, Val{0}()) +@inline rsqrt(x::_MFV{M,T,N}) where {M,T,N} = _rsqrt(x, Val{(N + 1) >> 1}()) @inline unsafe_sqrt(x::_MF{T,N}) where {T,N} = inv(rsqrt(x))