2019-06-19 14:34:30 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2004-2011 Ondra Kamenik
|
|
|
|
* Copyright © 2019 Dynare Team
|
|
|
|
*
|
|
|
|
* This file is part of Dynare.
|
|
|
|
*
|
|
|
|
* Dynare is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Dynare is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2009-09-08 15:55:19 +02:00
|
|
|
|
|
|
|
#ifndef MM_MATRIX_H
|
|
|
|
#define MM_MATRIX_H
|
|
|
|
|
2019-01-08 17:12:05 +01:00
|
|
|
#include "GeneralMatrix.hh"
|
2009-09-08 15:55:19 +02:00
|
|
|
|
|
|
|
#include <string>
|
2019-01-09 15:46:04 +01:00
|
|
|
#include <utility>
|
2019-02-14 11:29:18 +01:00
|
|
|
#include <vector>
|
2009-09-08 15:55:19 +02:00
|
|
|
|
2019-01-25 15:29:14 +01:00
|
|
|
class MMException
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
2019-01-25 15:27:20 +01:00
|
|
|
std::string message;
|
2009-09-08 15:55:19 +02:00
|
|
|
public:
|
2019-01-25 15:27:20 +01:00
|
|
|
MMException(std::string mes) : message(std::move(mes))
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
|
|
|
}
|
2019-01-25 15:27:20 +01:00
|
|
|
std::string
|
2017-05-16 16:30:27 +02:00
|
|
|
getMessage() const
|
|
|
|
{
|
2019-01-25 15:27:20 +01:00
|
|
|
return message;
|
2017-05-16 16:30:27 +02:00
|
|
|
}
|
2009-09-08 15:55:19 +02:00
|
|
|
};
|
|
|
|
|
2019-01-25 15:29:14 +01:00
|
|
|
class MMMatrixIn
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
2019-02-14 11:29:18 +01:00
|
|
|
std::vector<double> data;
|
2017-05-16 16:30:27 +02:00
|
|
|
int rows;
|
|
|
|
int cols;
|
2009-09-08 15:55:19 +02:00
|
|
|
public:
|
2019-01-25 15:27:20 +01:00
|
|
|
MMMatrixIn(const std::string &fname);
|
Dynare++ / sylvester equation solver: refactor Vector and ConstVector classes
- these classes now encapsulate a std::shared_ptr<{const, }double>, so that
they do not perform memory management, and several {Const,}Vector instances
can transparently share the same underlying data
- make converting constructor from ConstVector to Vector explicit, since that
entails memory allocation (but the reverse conversion is almost costless, so
keep it implicit); do the same for GeneralMatrix/ConstGeneralMatrix,
TwoDMatrix/ConstTwoDMatrix
- remove the constructors that were extracting a row/column from a matrix, and
replace them by getRow() and getCol() methods on {Const,}GeneralMatrix
- rename and change the API of the complex version Vector::add(), so that it is
explicit that it deals with complex numbers
- add constructors that take a MATLAB mxArray
2019-01-22 16:07:44 +01:00
|
|
|
~MMMatrixIn() = default;
|
2019-01-24 15:22:36 +01:00
|
|
|
Vector
|
2019-02-14 11:29:18 +01:00
|
|
|
getData()
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
2019-02-14 11:29:18 +01:00
|
|
|
return Vector{data.data(), size()};
|
2017-05-16 16:30:27 +02:00
|
|
|
}
|
|
|
|
int
|
|
|
|
size() const
|
|
|
|
{
|
|
|
|
return rows*cols;
|
|
|
|
}
|
|
|
|
int
|
|
|
|
row() const
|
|
|
|
{
|
|
|
|
return rows;
|
|
|
|
}
|
|
|
|
int
|
|
|
|
col() const
|
|
|
|
{
|
|
|
|
return cols;
|
|
|
|
}
|
2009-09-08 15:55:19 +02:00
|
|
|
};
|
|
|
|
|
2019-01-25 15:29:14 +01:00
|
|
|
class MMMatrixOut
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
2009-09-08 15:55:19 +02:00
|
|
|
public:
|
2019-01-25 15:27:20 +01:00
|
|
|
static void write(const std::string &fname, const GeneralMatrix &m);
|
2009-09-08 15:55:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MM_MATRIX_H */
|