fix(math): preflight finite dense operands at dispatch boundary
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user