2019-06-19 14:34:30 +02:00
|
|
|
|
/*
|
|
|
|
|
* Copyright © 2004-2011 Ondra Kamenik
|
2023-12-05 15:44:23 +01:00
|
|
|
|
* Copyright © 2019-2023 Dynare Team
|
2019-06-19 14:34:30 +02:00
|
|
|
|
*
|
|
|
|
|
* 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
|
2021-06-09 17:33:48 +02:00
|
|
|
|
* along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2019-06-19 14:34:30 +02:00
|
|
|
|
*/
|
2009-09-08 15:55:19 +02:00
|
|
|
|
|
|
|
|
|
#ifndef QUASI_TRIANGULAR_ZERO_H
|
|
|
|
|
#define QUASI_TRIANGULAR_ZERO_H
|
|
|
|
|
|
2019-01-08 17:12:05 +01:00
|
|
|
|
#include "GeneralMatrix.hh"
|
2023-11-29 19:00:21 +01:00
|
|
|
|
#include "QuasiTriangular.hh"
|
2009-09-08 15:55:19 +02:00
|
|
|
|
|
2019-01-15 18:55:09 +01:00
|
|
|
|
#include <memory>
|
|
|
|
|
|
2019-03-29 18:46:52 +01:00
|
|
|
|
/*
|
|
|
|
|
Stores a (square) quasi-triangular matrix whose first columns are zero:
|
|
|
|
|
⎛0 R⎞
|
|
|
|
|
⎝0 M⎠
|
|
|
|
|
where M (square quasi-triangular) is stored in the super-class, and R (rectangular)
|
|
|
|
|
is stored in ‘ru’.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-05-16 16:30:27 +02:00
|
|
|
|
class QuasiTriangularZero : public QuasiTriangular
|
|
|
|
|
{
|
2023-11-29 19:00:21 +01:00
|
|
|
|
int nz; // number of zero columns
|
2019-03-29 18:46:52 +01:00
|
|
|
|
GeneralMatrix ru; // data in right upper part (of size nz×d_size)
|
2009-09-08 15:55:19 +02:00
|
|
|
|
public:
|
2023-11-29 19:00:21 +01:00
|
|
|
|
QuasiTriangularZero(int num_zeros, const ConstVector& d, int d_size);
|
2019-03-29 15:27:34 +01:00
|
|
|
|
// Initializes with r·t
|
2023-11-29 19:00:21 +01:00
|
|
|
|
QuasiTriangularZero(double r, const QuasiTriangularZero& t);
|
2019-03-29 15:27:34 +01:00
|
|
|
|
// Initializes with r·t+r₂·t₂
|
2023-11-29 19:00:21 +01:00
|
|
|
|
QuasiTriangularZero(double r, const QuasiTriangularZero& t, double r2,
|
|
|
|
|
const QuasiTriangularZero& t2);
|
2019-03-29 15:27:34 +01:00
|
|
|
|
// Initializes with t²
|
2023-11-29 19:00:21 +01:00
|
|
|
|
QuasiTriangularZero(const std::string& dummy, const QuasiTriangularZero& t);
|
|
|
|
|
explicit QuasiTriangularZero(const QuasiTriangular& t);
|
|
|
|
|
explicit QuasiTriangularZero(const SchurDecompZero& decomp);
|
2019-01-16 17:52:16 +01:00
|
|
|
|
~QuasiTriangularZero() override = default;
|
2023-11-29 19:00:21 +01:00
|
|
|
|
void solvePre(Vector& x, double& eig_min) override;
|
|
|
|
|
void solvePreTrans(Vector& x, double& eig_min) override;
|
|
|
|
|
void multVec(Vector& x, const ConstVector& b) const override;
|
|
|
|
|
void multVecTrans(Vector& x, const ConstVector& b) const override;
|
|
|
|
|
void multaVec(Vector& x, const ConstVector& b) const override;
|
|
|
|
|
void multaVecTrans(Vector& x, const ConstVector& b) const override;
|
|
|
|
|
void multKron(KronVector& x) const override;
|
|
|
|
|
void multKronTrans(KronVector& x) const override;
|
|
|
|
|
void multLeftOther(GeneralMatrix& a) const override;
|
2019-03-29 15:27:34 +01:00
|
|
|
|
|
2023-12-05 15:44:23 +01:00
|
|
|
|
[[nodiscard]] std::unique_ptr<QuasiTriangular>
|
2019-01-09 16:26:42 +01:00
|
|
|
|
clone() const override
|
2017-05-16 16:30:27 +02:00
|
|
|
|
{
|
2019-01-15 18:55:09 +01:00
|
|
|
|
return std::make_unique<QuasiTriangularZero>(*this);
|
2017-05-16 16:30:27 +02:00
|
|
|
|
}
|
2023-12-05 15:44:23 +01:00
|
|
|
|
[[nodiscard]] std::unique_ptr<QuasiTriangular>
|
2019-03-29 15:27:34 +01:00
|
|
|
|
square() const override
|
2017-05-16 16:30:27 +02:00
|
|
|
|
{
|
2019-03-29 15:27:34 +01:00
|
|
|
|
return std::make_unique<QuasiTriangularZero>("square", *this);
|
2017-05-16 16:30:27 +02:00
|
|
|
|
}
|
2023-12-05 15:44:23 +01:00
|
|
|
|
[[nodiscard]] std::unique_ptr<QuasiTriangular>
|
2019-03-29 15:27:34 +01:00
|
|
|
|
scale(double r) const override
|
2017-05-16 16:30:27 +02:00
|
|
|
|
{
|
2019-01-15 18:55:09 +01:00
|
|
|
|
return std::make_unique<QuasiTriangularZero>(r, *this);
|
2017-05-16 16:30:27 +02:00
|
|
|
|
}
|
2023-12-05 15:44:23 +01:00
|
|
|
|
[[nodiscard]] std::unique_ptr<QuasiTriangular>
|
2023-11-29 19:00:21 +01:00
|
|
|
|
linearlyCombine(double r, double r2, const QuasiTriangular& t2) const override
|
2017-05-16 16:30:27 +02:00
|
|
|
|
{
|
2023-11-29 19:00:21 +01:00
|
|
|
|
return std::make_unique<QuasiTriangularZero>(r, *this, r2,
|
|
|
|
|
dynamic_cast<const QuasiTriangularZero&>(t2));
|
2017-05-16 16:30:27 +02:00
|
|
|
|
}
|
2019-01-09 16:26:42 +01:00
|
|
|
|
void print() const override;
|
2009-09-08 15:55:19 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* QUASI_TRIANGULAR_ZERO_H */
|