Open yuanming-hu opened 5 years ago
I think the code is a little ambiguous as a temporary diagonal taichi::MatrixND
is initialized from (lambda * (J-1) * J)
with the following implicit constructor:
TC_FORCE_INLINE MatrixND(T v) : MatrixND() {
for (int i = 0; i < dim; i++) {
d[i][i] = v;
}
}
Then the following operator override is used to carry out the matrix-matrix addition:
TC_FORCE_INLINE MatrixND operator+(const MatrixND &o) const {
return MatrixND([=](int i) { return this->d[i] + o[i]; });
}
🤔 For readability it may be nice to initialize the diagonal matrix explicitly?
This really confused me - it looked like the line was trying to add a scalar to a matrix.
Also, it is not clear how this matches equation 52 here: https://www.seas.upenn.edu/~cffjiang/research/mpmcourse/mpmcourse.pdf . That equation has F^-T in the second term, which I am guessing is meant to mean the transpose of the inverse matrix of F? In the implementation, the first term is multiplied by F^T (the transpose of F). How is this correctly implemented?
Please make the code explicit for readability instead of using an implicit constructor.