Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear algebra doesn't work #5

Closed
dlfivefifty opened this issue Apr 18, 2023 · 0 comments · Fixed by #6
Closed

Linear algebra doesn't work #5

dlfivefifty opened this issue Apr 18, 2023 · 0 comments · Fixed by #6

Comments

@dlfivefifty
Copy link
Contributor

dlfivefifty commented Apr 18, 2023

I think we just need to overload iterate and adjoint to fix this:

julia> dot([x,y], [-y,x])
ERROR: MethodError: no method matching iterate(::@ring(ℚ[x,y]))

Closest candidates are:
  iterate(::Union{LinRange, StepRangeLen})
   @ Base range.jl:880
  iterate(::Union{LinRange, StepRangeLen}, ::Integer)
   @ Base range.jl:880
  iterate(::T) where T<:Union{Base.KeySet{<:Any, <:Dict}, Base.ValueIterator{<:Dict}}
   @ Base dict.jl:698
  ...

Stacktrace:
 [1] dot(x::@ring(ℚ[x,y]), y::@ring(ℚ[x,y]))
   @ LinearAlgebra ~/Projects/julia-1.9/usr/share/julia/stdlib/v1.9/LinearAlgebra/src/generic.jl:848
 [2] dot(x::Vector{@ring(ℚ[x,y])}, y::Vector{@ring(ℚ[x,y])})
   @ LinearAlgebra ~/Projects/julia-1.9/usr/share/julia/stdlib/v1.9/LinearAlgebra/src/generic.jl:886
 [3] top-level scope
   @ REPL[24]:1

julia> [x,y]'* [-y,x]
ERROR: MethodError: no method matching adjoint(::@ring(ℚ[x,y]))

Closest candidates are:
  adjoint(::Union{QR, LinearAlgebra.QRCompactWY, QRPivoted})
   @ LinearAlgebra ~/Projects/julia-1.9/usr/share/julia/stdlib/v1.9/LinearAlgebra/src/qr.jl:517
  adjoint(::Union{Cholesky, CholeskyPivoted})
   @ LinearAlgebra ~/Projects/julia-1.9/usr/share/julia/stdlib/v1.9/LinearAlgebra/src/cholesky.jl:556
  adjoint(::LQ)
   @ LinearAlgebra ~/Projects/julia-1.9/usr/share/julia/stdlib/v1.9/LinearAlgebra/src/lq.jl:138
  ...

Stacktrace:
  [1] getindex
    @ ~/Projects/julia-1.9/usr/share/julia/stdlib/v1.9/LinearAlgebra/src/adjtrans.jl:302 [inlined]
  [2] iterate
    @ ./abstractarray.jl:1220 [inlined]
  [3] iterate
    @ ./abstractarray.jl:1218 [inlined]
  [4] _zip_iterate_some
    @ ./iterators.jl:424 [inlined]
  [5] _zip_iterate_all
    @ ./iterators.jl:416 [inlined]
  [6] iterate
    @ ./iterators.jl:406 [inlined]
  [7] _foldl_impl
    @ ./reduce.jl:56 [inlined]
  [8] foldl_impl(op::Base.MappingRF{LinearAlgebra.var"#13#14", Base.BottomRF{typeof(Base.add_sum)}}, nt::Base._InitialValue, itr::Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}})
    @ Base ./reduce.jl:48
  [9] mapfoldl_impl(f::typeof(identity), op::typeof(Base.add_sum), nt::Base._InitialValue, itr::Base.Generator{Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}}, LinearAlgebra.var"#13#14"})
    @ Base ./reduce.jl:44
 [10] mapfoldl(f::Function, op::Function, itr::Base.Generator{Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}}, LinearAlgebra.var"#13#14"}; init::Base._InitialValue)
    @ Base ./reduce.jl:170
 [11] mapfoldl(f::Function, op::Function, itr::Base.Generator{Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}}, LinearAlgebra.var"#13#14"})
    @ Base ./reduce.jl:170
 [12] mapreduce(f::Function, op::Function, itr::Base.Generator{Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}}, LinearAlgebra.var"#13#14"}; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./reduce.jl:302
 [13] mapreduce(f::Function, op::Function, itr::Base.Generator{Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}}, LinearAlgebra.var"#13#14"})
    @ Base ./reduce.jl:302
 [14] sum(f::Function, a::Base.Generator{Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}}, LinearAlgebra.var"#13#14"}; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./reduce.jl:530
 [15] sum(f::Function, a::Base.Generator{Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}}, LinearAlgebra.var"#13#14"})
    @ Base ./reduce.jl:530
 [16] sum(a::Base.Generator{Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}}, LinearAlgebra.var"#13#14"}; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./reduce.jl:559
 [17] sum(a::Base.Generator{Base.Iterators.Zip{Tuple{Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, Vector{@ring(ℚ[x,y])}}}, LinearAlgebra.var"#13#14"})
    @ Base ./reduce.jl:559
 [18] _dot_nonrecursive(u::Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, v::Vector{@ring(ℚ[x,y])})
    @ LinearAlgebra ~/Projects/julia-1.9/usr/share/julia/stdlib/v1.9/LinearAlgebra/src/adjtrans.jl:428
 [19] *(u::Adjoint{Union{}, Vector{@ring(ℚ[x,y])}}, v::Vector{@ring(ℚ[x,y])})
    @ LinearAlgebra ~/Projects/julia-1.9/usr/share/julia/stdlib/v1.9/LinearAlgebra/src/adjtrans.jl:435
 [20] top-level scope
    @ REPL[25]:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant