LazyArrays.jl icon indicating copy to clipboard operation
LazyArrays.jl copied to clipboard

one argument ApplyArray(*, A) not implemented

Open putianyi889 opened this issue 2 years ago • 3 comments

julia> ApplyArray(*, ones(10,10))
(10×10 Matrix{Float64}):
Error showing value of type ApplyArray{Float64, 2, typeof(*), Tuple{Matrix{Float64}}}:
ERROR: MethodError: no method matching _mul()

Closest candidates are:
  _mul(::Any)
   @ LazyArrays C:\Users\pty\.julia\packages\LazyArrays\N0VGX\src\linalg\mul.jl:138
  _mul(::Any, ::Any, ::Any...)
   @ LazyArrays C:\Users\pty\.julia\packages\LazyArrays\N0VGX\src\linalg\mul.jl:139

Stacktrace:
  [1] getindex(::Applied{LazyArrays.DefaultArrayApplyStyle, typeof(*), Tuple{Matrix{Float64}}}, ::Int64, ::Int64)
    @ LazyArrays C:\Users\pty\.julia\packages\LazyArrays\N0VGX\src\linalg\mul.jl:160
  [2] getindex
    @ C:\Users\pty\.julia\packages\LazyArrays\N0VGX\src\lazyapplying.jl:232 [inlined]
  [3] isassigned(::ApplyArray{Float64, 2, typeof(*), Tuple{Matrix{Float64}}}, ::Int64, ::Int64)
    @ Base .\abstractarray.jl:606
  [4] alignment(io::IOContext{Base.TTY}, X::AbstractVecOrMat, rows::Vector{Int64}, cols::Vector{Int64}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64, ncols::Int64)
    @ Base .\arrayshow.jl:68
  [5] _print_matrix(io::IOContext{Base.TTY}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{Int64}, colsA::UnitRange{Int64})
    @ Base .\arrayshow.jl:207
  [6] print_matrix(io::IOContext{Base.TTY}, X::ApplyArray{Float64, 2, typeof(*), Tuple{Matrix{Float64}}}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64)
    @ Base .\arrayshow.jl:171
  [7] print_matrix
    @ .\arrayshow.jl:171 [inlined]
  [8] print_array
    @ .\arrayshow.jl:358 [inlined]
  [9] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, X::ApplyArray{Float64, 2, typeof(*), Tuple{Matrix{Float64}}})
    @ Base .\arrayshow.jl:399
 [10] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL C:\Applications\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:276
 [11] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Applications\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:557
 [12] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL C:\Applications\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:262
 [13] display
    @ C:\Applications\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:281 [inlined]
 [14] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:340

julia> *(ones(10,10))
10×10 Matrix{Float64}:
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0

putianyi889 avatar Jul 14 '23 11:07 putianyi889

I don't have time to look at this, would you be able to submit a PR?

dlfivefifty avatar Jul 14 '23 11:07 dlfivefifty

sure. would you like this change to be before the Jacobi conversion or after? I'm using a workaround in ClassicalOPs currently

putianyi889 avatar Jul 14 '23 11:07 putianyi889

Up to you

dlfivefifty avatar Jul 14 '23 12:07 dlfivefifty

Fixed:

julia> ApplyArray(*, ones(10,10))
(10×10 Matrix{Float64}):
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0

dlfivefifty avatar Jun 25 '24 13:06 dlfivefifty