feat(linear-static-3d-euler-beam): step 9 - dense-math-adapters-review-fix

This commit is contained in:
KOKO\Mimi
2026-08-09 11:47:58 +09:00
parent 15b5e9916b
commit 4155267c45
3 changed files with 32 additions and 1 deletions
+10 -1
View File
@@ -9,6 +9,15 @@
namespace fesa {
namespace {
std::size_t checkedStorageSize(const std::size_t rows, const std::size_t columns) {
// Reject shape multiplication overflow before logical dimensions and storage diverge.
if (columns != 0 &&
rows > (std::numeric_limits<std::size_t>::max)() / columns) {
throw std::length_error{"Dense matrix dimensions exceed the storage size range."};
}
return rows * columns;
}
MKL_INT toMklSize(const std::size_t size) {
if (size > static_cast<std::size_t>((std::numeric_limits<MKL_INT>::max)())) {
throw std::length_error{"Dense matrix dimension exceeds the MKL integer range."};
@@ -30,7 +39,7 @@ Matrix::Matrix(
const std::size_t rows,
const std::size_t columns,
const double value)
: rows_(rows), columns_(columns), values_(rows * columns, value) {}
: rows_(rows), columns_(columns), values_(checkedStorageSize(rows, columns), value) {}
Matrix::Matrix(const Matrix& other)
: rows_(other.rows_), columns_(other.columns_), values_(other.values_.size()) {