diff options
author | Jean-Luc Brouillet <jeanluc@google.com> | 2014-09-05 17:44:48 -0700 |
---|---|---|
committer | Jean-Luc Brouillet <jeanluc@google.com> | 2014-09-08 15:40:58 -0700 |
commit | 1bb2eed69caa28cf8198d58db7d9134cc2f563f5 (patch) | |
tree | a13139843a108be78b86d4f1eef0fe574055c1a7 /rsMatrix2x2.cpp | |
parent | 33164686a7ac88d4eda38201be4127937e9c12b0 (diff) | |
download | rs-1bb2eed69caa28cf8198d58db7d9134cc2f563f5.tar.gz |
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
Diffstat (limited to 'rsMatrix2x2.cpp')
-rw-r--r-- | rsMatrix2x2.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/rsMatrix2x2.cpp b/rsMatrix2x2.cpp index 622113ce..91accbee 100644 --- a/rsMatrix2x2.cpp +++ b/rsMatrix2x2.cpp @@ -42,6 +42,9 @@ void Matrix2x2::load(const rs_matrix2x2 *v) { } void Matrix2x2::loadMultiply(const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs) { + // Use a temporary variable to support the case where one of the inputs + // is also the destination, e.g. left.loadMultiply(left, right); + Matrix2x2 temp; for (int i=0 ; i<2 ; i++) { float ri0 = 0; float ri1 = 0; @@ -50,9 +53,10 @@ void Matrix2x2::loadMultiply(const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs) { ri0 += ((const Matrix2x2 *)lhs)->get(j, 0) * rhs_ij; ri1 += ((const Matrix2x2 *)lhs)->get(j, 1) * rhs_ij; } - set(i, 0, ri0); - set(i, 1, ri1); + temp.set(i, 0, ri0); + temp.set(i, 1, ri1); } + load(&temp); } void Matrix2x2::transpose() { |