Files
FESADev/phases/linear-static-3d-euler-beam/step9.md
T
2026-08-15 03:14:34 +09:00

114 lines
4.2 KiB
Markdown

# Step 9: Dense Math Adapters
## 담당 역할과 필수 스킬
- 담당 역할: `implementation-agent`
- 필수 스킬: `fesa-cpp-msvc-tdd`
## 읽어야 할 파일
- `/AGENTS.md`
- `/docs/ARCHITECTURE.md`
- `/docs/ADR.md`
- `/docs/linear-static-3d-euler-beam/requirements.md`
- `/docs/linear-static-3d-euler-beam/implementation-plan.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:
```powershell
cmake --build .harness/build --config Debug --target fesa_tests
ctest --test-dir .harness/build -C Debug -R DenseMath --output-on-failure
```
GREEN/VERIFY:
```powershell
cmake -S . -B .harness/build -A x64 `
-DFESA_GTEST_SOURCE_DIR=C:/git/googletest `
"-DMKL_DIR=C:/Program Files (x86)/Intel/oneAPI/mkl/2026.1/lib/cmake/mkl" `
"-DTBB_DIR=C:/Program Files (x86)/Intel/oneAPI/tbb/2023.1/lib/cmake/tbb" `
"-DHDF5_DIR=C:/Program Files/HDF_Group/HDF5/2.1.1/cmake"
cmake --build .harness/build --config Debug
ctest --test-dir .harness/build -C Debug -R DenseMath --output-on-failure
ctest --test-dir .harness/build -C Debug --show-only=json-v1
ctest --test-dir .harness/build -C Debug --output-on-failure
$leaks = rg -n "mkl\.h|MKL_INT|CBLAS_" include/fesa
if ($LASTEXITCODE -eq 0) { throw "MKL API leaked into public headers:`n$leaks" }
if ($LASTEXITCODE -ne 1) { throw 'Public-header dependency scan failed' }
```
마지막 `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/implementation-report.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가 담당한다.