Reputation: 105
I am following this documentation from SymbolicUtils.jl
package, and I want to implement a rule in my matrix. (I am not totally sure if it can be done tbh)
Here's what I am doing:
using Symbolics
using SymbolicUtils
# generate variable Q with subscripts
Q = Symbolics.variables(:Q, 1:3, 1:3)
Now I want to assign a rule such that Q[j,i] = -Q[i,j]
This is what I tried
r1 = @rule Q[~j, ~i] => -Q[~i,~j]
But there's something wrong, because when I try:
r1(Q[2,1]) # I get nothing
From the documentation: when I get nothing, that indicates that my expression does not match the rule. So I am not sure how else to define the rule?
Another issue might be that there's something wrong with my logic, and this could result in an unwanted recursion. So maybe I'd also have to set conditions such that: Q[j,i] = -Q[i,j]
only when j > i
; else (when i == j
) Q[i,j] = 0
.
What might be the correct/conventional approach?
Upvotes: 0
Views: 30