anj1 / algebraicnumbers.jl Goto Github PK
View Code? Open in Web Editor NEWExact representation and calculation with roots (e.g. square roots) and their addition/multiplication
License: MIT License
Exact representation and calculation with roots (e.g. square roots) and their addition/multiplication
License: MIT License
The composed sum of (the coeffs of) 1 and i gives a wrong result.
Reproduce like:
i = sqrt(AlgebraicNumber(-1))
# ≈0.0 + 1.0im
uno = AlgebraicNumber(1)
# ≈1.0 + 0.0im
two = AlgebraicNumber(2)
# ≈2.0 + 0.0im
ipu = 1+i
[ipu == two, two.coeff == ipu.coeff, two.prec == ipu.prec, two.apprx == ipu.apprx]'
# true true true false
(i+1).coeff'
# -2 1
AlgebraicNumbers.composed_sum(uno.coeff, i.coeff)'
# -2 1
The polynomial should be x²-2x+2, thus the coeffs [2,-2,1]
Hi,
is this project still maintained?
Would you mind either taking a look at my PR (#8) or considering giving me commit rights?
I find this package very useful and would like to register it on the General registry.
Hello,
Your package is exactly what i'm looking for! However your package could not be found in Pkg
julia> using Pkg
julia> Pkg.add("AlgebraicNumber")
ERROR: The following package names could not be resolved:
* AlgebraicNumber (not found in project, manifest or registry)
Please specify by known `name=uuid`.
This should return 2
, I think
julia> convert(Int, AlgebraicNumber(2))
-2
Consider the following MWE:
using LinearAlgebra
using AlgebraicNumbers
A = AlgebraicNumber.([
1 2
3 4
])
λ = AlgebraicNumber(2)
B = A - λ*I # error here
Error arises:
ERROR: LoadError: MethodError: promote_rule(::Type{Bool}, ::Type{AlgebraicNumber{BigInt, BigFloat}}) is ambiguous.
Candidates:
promote_rule(x::Type{T}, y::Type{AlgebraicNumber{S, F}}) where {T<:Integer, S, F}
@ AlgebraicNumbers ~/.julia/packages/AlgebraicNumbers/H0atE/src/promote.jl:14
promote_rule(::Type{Bool}, ::Type{T}) where T<:Number
@ Base bool.jl:4
Possible fix, define
promote_rule(::Type{Bool}, ::Type{AlgebraicNumber{S, F}}) where {S, F}
Stacktrace:
[1] promote_type(#unused#::Type{AlgebraicNumber{BigInt, BigFloat}}, #unused#::Type{Bool})
@ Base ./promotion.jl:307
[2] _promote
@ ./promotion.jl:357 [inlined]
[3] promote
@ ./promotion.jl:381 [inlined]
[4] *(x::AlgebraicNumber{BigInt, BigFloat}, y::Bool)
@ Base ./promotion.jl:411
[5] *(x::AlgebraicNumber{BigInt, BigFloat}, J::UniformScaling{Bool})
@ LinearAlgebra ~/julia-1.9.3/share/julia/stdlib/v1.9/LinearAlgebra/src/uniformscaling.jl:263
[6] top-level scope
@ ~/MSU/Code/Quadrics/bug.jl:12
[7] include(fname::String)
@ Base.MainInclude ./client.jl:478
[8] top-level scope
@ REPL[14]:1
I expected that I
will work just like with, e.g., NiceNumbers
:
using LinearAlgebra
using NiceNumbers
A = NiceNumber.([
1 2
3 4
])
λ = NiceNumber(2)
B = A - λ*I
(the answer is
2×2 Matrix{NiceNumber}:
-1 2
3 2
what I've expected)
Hi @anj1,
to publish new versions to the 'General' registry, it would be easiest to install the Registrator GitHub app. Currently, new versions of AlgebraicNumbers.jl
don't get deployed to the registry.
This can be done using few clicks here: install
If you want to read a bit more about it, you can take a look at the Readme here.
Have a nice day,
Felix
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
There's a TODO for efficient calculation of third power here. Please would you be so kind and explain how (if at all) it is possible to make it more efficient than pow2 and *?
Hello! Didn't get an answer on Discourse, so hope to succeed here.
Let’s consider MVE:
using LinearAlgebra
using AlgebraicNumbers
M = AlgebraicNumber.([
1 2
3 4
])
b = AlgebraicNumber.([5; 6])
println(typeof(M))
println(typeof(b))
x = M * b
println(typeof(x))
Expected a Vector{AlgebraicNumber...}
, not Vector{Any}
, just like in this example:
using LinearAlgebra
using AlgebraicNumbers
M = Rational.([
1 2
3 4
])
b = Rational.([5; 6])
println(typeof(M))
println(typeof(b))
x = M * b
println(typeof(x))
That’s interesting that it works just fine with functions like det
and tr
, but not with matrix multiplication.
So, my question is: is it normal behavior? And if so, how should I perform this operation in order to get Vector{AlgebraicNumber...}
? Should I just use conversion from type Any
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.