-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrixSpace.hh
52 lines (37 loc) · 1.36 KB
/
MatrixSpace.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2021 Chanjung Kim. All rights reserved.
// Licensed under the MIT License.
#ifndef LAPLACE_EQ_THERM_SERVER_CORE_MATRIX_SPACE_HH
#define LAPLACE_EQ_THERM_SERVER_CORE_MATRIX_SPACE_HH
#include <leth/Space.hh>
#include <random>
#include <vector>
class MatrixSpace : public Space
{
private:
enum class ErrorType
{
Success,
InvalidEquation,
};
private:
std::vector<float> _A, _x, _b;
std::vector<Pos> _i2Pos;
std::vector<uint32_t> _i2NumNeighboringWalls;
std::vector<size_t> _pos2I;
public:
MatrixSpace(uint16_t width, uint16_t height);
protected:
virtual char const* GetName() noexcept override;
virtual char const* GetErrorMessage(ErrorCode errorCode) noexcept override final;
virtual ErrorCode RunSimulation(Point const* input, float* output) noexcept override final;
/// Solves the equation Ax = b.
virtual void SolveEquation(std::vector<float> const& A,
std::vector<float>& x,
std::vector<float> const& b) noexcept = 0;
private:
char const* GetErrorMessageInternal(ErrorType errorType) noexcept;
ErrorType RunSimulationInternal(Point const* input, float* output) noexcept;
bool BuildEquation(Point const* input) noexcept;
void CopyResults(Point const* input, float* output) noexcept;
};
#endif