fix(math): preflight finite dense operands at dispatch boundary

This commit is contained in:
KOKO\Mimi
2026-10-14 16:02:17 +09:00
parent 770fa2a0d1
commit 9c4e6854ae
8 changed files with 65 additions and 5 deletions
+13
View File
@@ -1,5 +1,6 @@
#include "fesa/math/matrix.h"
#include <cmath>
#include <mkl.h>
#include <limits>
@@ -107,6 +108,12 @@ Vector Matrix::Multiply(const Vector& rhs) const {
throw std::invalid_argument{
"Matrix-vector multiplication has incompatible dimensions."};
}
for (const double value : values_)
if (!std::isfinite(value))
throw std::invalid_argument{"Matrix product inputs must be finite."};
for (std::size_t i = 0; i < rhs.Size(); ++i)
if (!std::isfinite(rhs.Data()[i]))
throw std::invalid_argument{"Matrix product inputs must be finite."};
Vector result{rows_};
if (rows_ == 0 || columns_ == 0) {
@@ -126,6 +133,12 @@ Matrix Matrix::Multiply(const Matrix& rhs) const {
throw std::invalid_argument{
"Matrix multiplication has incompatible dimensions."};
}
for (const double value : values_)
if (!std::isfinite(value))
throw std::invalid_argument{"Matrix product inputs must be finite."};
for (const double value : rhs.values_)
if (!std::isfinite(value))
throw std::invalid_argument{"Matrix product inputs must be finite."};
Matrix result{rows_, rhs.columns_};
if (rows_ == 0 || columns_ == 0 || rhs.columns_ == 0) {