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

similar for a symbolic matrix #707

Open
qwertyjl opened this issue Aug 19, 2022 · 1 comment
Open

similar for a symbolic matrix #707

qwertyjl opened this issue Aug 19, 2022 · 1 comment

Comments

@qwertyjl
Copy link

similar() function is widely used. The problem is that if I want to use a function that uses it with a symbolic matrix I must first apply the collect() function.
For example this doesn't work:

using Symbolics, Tullio
@variables x[1:3, 1:3] v[1:3]
@tullio r[i] := x[i, j]*v[j]
@nsajko
Copy link
Contributor

nsajko commented Nov 19, 2023

The missing similar method also breaks zero:

julia> using Symbolics

julia> @variables x[1:6]
1-element Vector{Symbolics.Arr{Num, 1}}:
 x[1:6]

julia> zero(x)
ERROR: MethodError: no method matching similar(::Symbolics.Arr{Num, 1}, ::Type{Num}, ::Tuple{UnitRange{Int64}})

Closest candidates are:
  similar(::Base.Broadcast.Broadcasted{Base.Broadcast.ArrayConflict}, ::Type{ElType}, ::Any) where ElType
   @ Base broadcast.jl:229
  similar(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{N}}, ::Type{ElType}, ::Any) where {N, ElType}
   @ Base broadcast.jl:224
  similar(::A, ::Type{T}, ::StaticArraysCore.Size{S}) where {A<:AbstractArray, T, S}
   @ StaticArrays ~/tmp/jl/StaticArrays.jl/src/abstractarray.jl:129
  ...

Stacktrace:
 [1] similar(a::Symbolics.Arr{Num, 1}, ::Type{Num})
   @ Base ./abstractarray.jl:825
 [2] zero(x::Symbolics.Arr{Num, 1})
   @ Base ./abstractarray.jl:1224
 [3] top-level scope
   @ REPL[3]:1

julia> versioninfo()
Julia Version 1.11.0-DEV.929
Commit 03bbf91902b (2023-11-17 15:00 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-15.0.7 (ORCJIT, znver2)
  Threads: 11 on 8 virtual cores
Environment:
  JULIA_NUM_PRECOMPILE_TASKS = 3
  JULIA_PKG_PRECOMPILE_AUTO = 0
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 8

(@v1.11) pkg> st Symbolics
Status `~/.julia/environments/v1.11/Project.toml`
  [0c5d862f] Symbolics v5.10.0

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

No branches or pull requests

2 participants