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

normalize() fails with symbolic arguments #52465

Closed
ufechner7 opened this issue Dec 9, 2023 · 2 comments
Closed

normalize() fails with symbolic arguments #52465

ufechner7 opened this issue Dec 9, 2023 · 2 comments
Labels

Comments

@ufechner7
Copy link

ufechner7 commented Dec 9, 2023

The following code works:

using ModelingToolkit, LinearAlgebra

@variables t pos(t)[1:3] = [0.0, 0.0,  10.0]
pos/norm(pos)

the following code crashes:

using ModelingToolkit, LinearAlgebra

@variables t pos(t)[1:3] = [0.0, 0.0,  10.0]
normalize(pos)

with the following message:

ERROR: TypeError: non-boolean (Num) used in boolean context
Stacktrace:
 [1] copyto!(dest::OffsetArrays.OffsetVector{Num, Vector{Num}}, src::Symbolics.Arr{Num, 1})
   @ Base ./abstractarray.jl:1059
 [2] copymutable_oftype(A::Symbolics.Arr{Num, 1}, ::Type{Num})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0-rc2+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/LinearAlgebra.jl:404
 [3] normalize(a::Symbolics.Arr{Num, 1}, p::Int64)
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0-rc2+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:1881
 [4] normalize(a::Symbolics.Arr{Num, 1})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.0-rc2+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:1879
 [5] top-level scope
   @ REPL[3]:1

So I think there is an additional method needed for the function normalize() with a vector of symbols as parameter.

julia> versioninfo()
Julia Version 1.10.0-rc2
Commit dbb9c46795b (2023-12-03 15:25 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × AMD Ryzen 9 7950X 16-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
  Threads: 1 on 32 virtual cores
Environment:
  LD_LIBRARY_PATH = /lib:/usr/lib:/usr/local/lib
@ufechner7
Copy link
Author

There might be a fix in the works already, see: https://discourse.julialang.org/t/modelingtoolkit-and-normalize/107349/2

@stevengj
Copy link
Member

Per the discussion, it seems like this needs to be fixed in Symbolics.jl, not in LinearAlgebra.

@dkarrasch dkarrasch closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants