Improve rsMatrix* documentation, fix bugs Improves the user-facing documentation. Fix the incorrect row & column naming on the Get/Set API. Fix a bug where rsMatrixLoadMultiply could not have the destination be one of the source, e.g. rsMatrixLoadMultiply(&l, &l, &r) Change-Id: I42207aacf4ebe815d4a79db2aaa9c44f85864696
diff --git a/rsMatrix3x3.cpp b/rsMatrix3x3.cpp index 3f9a2d1..4f27fcc 100644 --- a/rsMatrix3x3.cpp +++ b/rsMatrix3x3.cpp
@@ -46,6 +46,9 @@ } void Matrix3x3::loadMultiply(const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs) { + // Use a temporary variable to support the case where one of the inputs + // is also the destination, e.g. left.loadMultiply(left, right); + Matrix3x3 temp; for (int i=0 ; i<3 ; i++) { float ri0 = 0; float ri1 = 0; @@ -56,10 +59,11 @@ ri1 += ((const Matrix3x3 *)lhs)->get(j, 1) * rhs_ij; ri2 += ((const Matrix3x3 *)lhs)->get(j, 2) * rhs_ij; } - set(i, 0, ri0); - set(i, 1, ri1); - set(i, 2, ri2); + temp.set(i, 0, ri0); + temp.set(i, 1, ri1); + temp.set(i, 2, ri2); } + load(&temp); } void Matrix3x3::transpose() {