96 lines
3.6 KiB
Markdown
96 lines
3.6 KiB
Markdown
# Step 9: Dense Math Adapters
|
|
|
|
> 과거 개발 계획이다. 아래 작업·상태·예시는 현재 실행 지시가 아니다.
|
|
> 현재 구현과 검증 한계는 [기능 요약](../../docs/linear-static-3d-euler-beam/README.md)을 따른다.
|
|
|
|
## 읽어야 할 파일
|
|
|
|
- `/AGENTS.md`
|
|
- `../../docs/solver-core/README.md`
|
|
- `../../docs/solver-core/README.md`
|
|
- `../../docs/linear-static-3d-euler-beam/README.md`
|
|
- `../../docs/linear-static-3d-euler-beam/README.md`
|
|
- `/include/fesa/core/status.hpp`
|
|
- `/src/fesa/CMakeLists.txt`
|
|
- `/tests/CMakeLists.txt`
|
|
|
|
## 소유 파일
|
|
|
|
- Create: `/include/fesa/math/vector.hpp`
|
|
- Create: `/include/fesa/math/matrix.hpp`
|
|
- Create: `/src/fesa/math/vector.cpp`
|
|
- Create: `/src/fesa/math/matrix.cpp`
|
|
- Create: `/tests/unit/math/vector_test.cpp`
|
|
- Create: `/tests/unit/math/matrix_test.cpp`
|
|
- Modify: `/src/fesa/CMakeLists.txt`
|
|
- Modify: `/tests/CMakeLists.txt`
|
|
|
|
## 작업
|
|
|
|
연속 `double` storage를 소유하는 `Vector`와 row-major `Matrix`를 위 exact paths에
|
|
구현하라. Public 의미는 다음과 같아야 한다.
|
|
|
|
```cpp
|
|
class Vector {
|
|
public:
|
|
explicit Vector(std::size_t size, double value = 0.0);
|
|
std::size_t size() const noexcept;
|
|
double* data() noexcept;
|
|
const double* data() const noexcept;
|
|
double& operator[](std::size_t index);
|
|
const double& operator[](std::size_t index) const;
|
|
double dot(const Vector& rhs) const;
|
|
double norm() const;
|
|
void scale(double alpha);
|
|
void axpy(double alpha, const Vector& x);
|
|
};
|
|
|
|
class Matrix {
|
|
public:
|
|
Matrix(std::size_t rows, std::size_t columns, double value = 0.0);
|
|
std::size_t rows() const noexcept;
|
|
std::size_t columns() const noexcept;
|
|
double& operator()(std::size_t row, std::size_t column);
|
|
const double& operator()(std::size_t row, std::size_t column) const;
|
|
Vector multiply(const Vector& rhs) const;
|
|
Matrix multiply(const Matrix& rhs) const;
|
|
};
|
|
```
|
|
|
|
copy/move semantics를 검증하고 모든 index access는 bounds-checked여야 한다. dimension
|
|
mismatch는 `std::invalid_argument`, bounds 위반은 `std::out_of_range`로 일관되게 처리한다.
|
|
copy, dot, Euclidean norm, scale, axpy, GEMV, GEMM은 `.cpp` 내부 MKL CBLAS adapter를
|
|
사용한다. `mkl.h`, `MKL_INT`, `CBLAS_*`가 public header에 나타나면 안 된다.
|
|
|
|
Tests는 zero-size policy, ownership/deep-copy, move safety, bounds, mismatch, non-square
|
|
row-major GEMV/GEMM과 known BLAS values를 검증하고 `DenseMath` regex로 실행 가능하게 한다.
|
|
|
|
## Acceptance Criteria
|
|
|
|
RED targeted command:
|
|
|
|
과거 도구 실행·출력 지시는 정리했으며, 현재 검증 방법은 기능 요약을 따른다.
|
|
|
|
GREEN/VERIFY:
|
|
|
|
과거 도구 실행·출력 지시는 정리했으며, 현재 검증 방법은 기능 요약을 따른다.
|
|
|
|
마지막 `rg`는 no-match여야 한다.
|
|
|
|
## 검증 절차
|
|
|
|
1. `vector_test.cpp`, `matrix_test.cpp`를 먼저 작성하고 missing behavior RED를 확인한다.
|
|
2. 최소 adapter/ownership 구현으로 GREEN을 만든다.
|
|
3. 전체 MSVC x64 Debug VERIFY와 public-header dependency scan을 실행한다.
|
|
4. `../../docs/linear-static-3d-euler-beam/README.md`의
|
|
Step 9 section에 실제 RED/GREEN/VERIFY command, exit code,
|
|
핵심 output과 변경 파일을 기록한다.
|
|
5. Step 9를 `completed`로 바꾸고 operations/test evidence를 summary에 기록한다.
|
|
|
|
## 금지사항
|
|
|
|
- `Matrix`를 sparse storage로 재사용하지 마라. 이유: CSR은 별도 타입이다.
|
|
- MKL type/header를 public API에 노출하지 마라. 이유: adapter boundary 계약이다.
|
|
- expression template이나 lazy evaluation을 추가하지 마라. 이유: 승인되지 않은 일반화다.
|
|
- 직접 commit하지 마라. 이유: Harness executor가 담당한다.
|