Hi all, I’ve been stuck with a problem traversing the indices of @polyvar. My code is as follows
@polyvar p11 p12 p13 p21 p22 p23 p31 p32 p33
which is a way to declare 9 polyvars of a 3x3 matrix.
Since there are only 9 variables, then I can simply list all the polyvars.
What if there are n*n variables? Is there a way that I can declare the variables using for-loop?
Here’s another code of computing the derivatives of matrix M with respect to pij, where i = 1:n, j=1:n
M = [[2p11, p21, p31] [p12, 2p22, p32] [p13, p23, 2p33]] det(M) ForwardDiff.gradient(detM, p11) ForwardDiff.gradient(detM, p12) ... ForwardDiff.gradient(detM, pnn)
Similar to the upper problem, is there a way that I can write a for-loop that can traverse all the indices of p from 11 to nn?