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
Indexed matrix expressions can now be parsed into TensorProduct #13622
base: master
Are you sure you want to change the base?
Indexed matrix expressions can now be parsed into TensorProduct #13622
Conversation
Hi @jksuom , I would like to ask you whether you think that this PR makes sense, that is allow to use |
|
I've come to the conclusion that this cannot be done with If
This is clearly not the same as |
Maybe a generalization of |
So this PR tries to solve the issue of matrix derivative returning higher-rank tensors. A matrix is a rank-2 tensor (i.e. an object with 2 indices). Sometimes, the derivative of a matrix expression may be a higher rank tensor, for example
X.diff(X)
is the rank-4 identity tensor (a tensor where all the ones are on the principal diagonal).This PR tries to introduce results based on
TensorProduct
:X.diff(X) == TensorProduct(I, I)
, whereI
is the identity matrix (TODO: this result is not yet achieved).Reasoning:
X.diff(X)
can be rewritten into index-form asX[i, j].diff(X[m, n])
, this returnsKroneckerDelta(m, i)*KroneckerDelta(n, j)
. This last expression can be re-interpreted as the tensor product of two identity matrices:TensorProduct(I, I)
, by assigning indices(m, i)
to the first term, and(n, j)
to the second term.