| 1 |
/* |
| 2 |
* Copyright © 2004-2011 Ondra Kamenik |
| 3 |
* Copyright © 2019-2023 Dynare Team |
| 4 |
* |
| 5 |
* This file is part of Dynare. |
| 6 |
* |
| 7 |
* Dynare is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation, either version 3 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* Dynare is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with Dynare. If not, see <https://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef MM_MATRIX_HH |
| 22 |
#define MM_MATRIX_HH |
| 23 |
|
| 24 |
#include "GeneralMatrix.hh" |
| 25 |
|
| 26 |
#include <string> |
| 27 |
#include <utility> |
| 28 |
#include <vector> |
| 29 |
|
| 30 |
class MMException |
| 31 |
{ |
| 32 |
std::string message; |
| 33 |
|
| 34 |
public: |
| 35 |
MMException(std::string mes) : message(std::move(mes)) |
| 36 |
{ |
| 37 |
} |
| 38 |
[[nodiscard]] std::string |
| 39 |
getMessage() const |
| 40 |
{ |
| 41 |
return message; |
| 42 |
} |
| 43 |
}; |
| 44 |
|
| 45 |
class MMMatrixIn |
| 46 |
{ |
| 47 |
std::vector<double> data; |
| 48 |
int rows; |
| 49 |
int cols; |
| 50 |
|
| 51 |
public: |
| 52 |
MMMatrixIn(const std::string& fname); |
| 53 |
~MMMatrixIn() = default; |
| 54 |
Vector |
| 55 |
getData() |
| 56 |
{ |
| 57 |
return Vector {data.data(), size()}; |
| 58 |
} |
| 59 |
[[nodiscard]] int |
| 60 |
size() const |
| 61 |
{ |
| 62 |
return rows * cols; |
| 63 |
} |
| 64 |
[[nodiscard]] int |
| 65 |
row() const |
| 66 |
{ |
| 67 |
return rows; |
| 68 |
} |
| 69 |
[[nodiscard]] int |
| 70 |
col() const |
| 71 |
{ |
| 72 |
return cols; |
| 73 |
} |
| 74 |
}; |
| 75 |
|
| 76 |
class MMMatrixOut |
| 77 |
{ |
| 78 |
public: |
| 79 |
static void write(const std::string& fname, const GeneralMatrix& m); |
| 80 |
}; |
| 81 |
|
| 82 |
#endif |