diff --git a/include/libcamera/internal/matrix.h b/include/libcamera/internal/matrix.h index a07a4770..47513b99 100644 --- a/include/libcamera/internal/matrix.h +++ b/include/libcamera/internal/matrix.h @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -152,15 +153,16 @@ Matrix operator*(const Matrix &m, T d) return d * m; } -template -constexpr Matrix operator*(const Matrix &m1, const Matrix &m2) +template +constexpr Matrix, R1, C2> operator*(const Matrix &m1, + const Matrix &m2) { static_assert(C1 == R2, "Matrix dimensions must match for multiplication"); - Matrix result; + Matrix, R1, C2> result; for (unsigned int i = 0; i < R1; i++) { for (unsigned int j = 0; j < C2; j++) { - T sum = 0; + std::common_type_t sum = 0; for (unsigned int k = 0; k < C1; k++) sum += m1[i][k] * m2[k][j]; diff --git a/src/libcamera/matrix.cpp b/src/libcamera/matrix.cpp index 68fc1b7b..ed22263b 100644 --- a/src/libcamera/matrix.cpp +++ b/src/libcamera/matrix.cpp @@ -138,11 +138,12 @@ LOG_DEFINE_CATEGORY(Matrix) */ /** - * \fn Matrix operator*(const Matrix &m1, const Matrix &m2) + * \fn operator*(const Matrix &m1, const Matrix &m2) * \brief Matrix multiplication - * \tparam T Type of numerical values in the matrices + * \tparam T1 Type of numerical values in the first matrix * \tparam R1 Number of rows in the first matrix * \tparam C1 Number of columns in the first matrix + * \tparam T2 Type of numerical values in the secont matrix * \tparam R2 Number of rows in the second matrix * \tparam C2 Number of columns in the second matrix * \param m1 Multiplicand matrix