ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
Discret.hh
[詳解]
1
5//
6// Copyright (C) 2011-2020 Yokokura, Yuki
7// This program is free software;
8// you can redistribute it and/or modify it under the terms of the BSD License.
9// For details, see the License.txt file.
10
11#ifndef DISCRET
12#define DISCRET
13
14#include <string>
15#include <tuple>
16#include <cassert>
17#include "Matrix.hh"
18
19namespace ARCS { // ARCS名前空間
21class Discret {
22 public:
28 template <size_t NB, size_t MB>
29 static constexpr std::pair<Matrix<MB,MB>, Matrix<NB,MB>>
30 GetDiscSystem(const Matrix<MB,MB>& Ac, const Matrix<NB,MB>& Bc, const double Ts){
31 constexpr size_t Npade = 13; // パデ近似の次数
32 constexpr unsigned long Nint = 10000; // 定積分の分割数
33 return GetDiscSystem(Ac, Bc, Ts, Npade, Nint); // 離散化してタプルで返す
34 }
35
43 template <size_t NB, size_t MB>
44 static constexpr std::pair<Matrix<MB,MB>, Matrix<NB,MB>>
46 const Matrix<MB,MB>& Ac, const Matrix<NB,MB>& Bc,
47 const double Ts, const size_t Npade, const unsigned long Nint
48 ){
51 GetDiscSystem(Ac, Bc, Ad, Bd, Ts, Npade, Nint); // 離散化
52 return {Ad, Bd}; // ペアで返す
53 }
54
61 template <size_t NB, size_t MB>
62 static constexpr void GetDiscSystem(
63 const Matrix<MB,MB>& Ac, const Matrix<NB,MB>& Bc, Matrix<MB,MB>& Ad, Matrix<NB,MB>& Bd, const double Ts
64 ){
65 constexpr size_t Npade = 13; // パデ近似の次数
66 constexpr unsigned long Nint = 10000; // 定積分の分割数
67 GetDiscSystem(Ac, Bc, Ad, Bd, Ts, Npade, Nint); // 離散化
68 }
69
78 template <size_t NB, size_t MB>
79 static constexpr void GetDiscSystem(
80 const Matrix<MB,MB>& Ac, const Matrix<NB,MB>& Bc, Matrix<MB,MB>& Ad, Matrix<NB,MB>& Bd,
81 const double Ts, const size_t Npade, const size_t Nint
82 ){
83 Ad = expm(Ac*Ts, Npade); // A行列の離散化
84 Bd = integral_expm(Ac, Ts, Nint, Npade)*Bc; // B行列の離散化
85 }
86
90 template <size_t MB>
91 static constexpr Matrix<MB,MB> GetDiscMatA(const Matrix<MB,MB>& Ac, const double Ts){
92 constexpr size_t Npade = 3; // パデ近似の次数
93 return expm(Ac*Ts, Npade); // 離散系A行列を返す
94 }
95
100 template <size_t NB, size_t MB>
101 static constexpr Matrix<NB,MB> GetDiscMatB(const Matrix<MB,MB>& Ac, const Matrix<NB,MB>& Bc, const double Ts){
102 constexpr size_t Npade = 3; // パデ近似の次数
103 constexpr unsigned long Nint = 100; // 定積分の分割数
104 return integral_expm(Ac, Ts, Nint, Npade)*Bc; // 離散系B行列を返す
105 }
106
111 template <size_t MB>
112 static constexpr Matrix<MB,MB> GetDiscMatA(const Matrix<MB,MB>& Ac, const double Ts, const size_t Npade){
113 return expm(Ac*Ts, Npade); // 離散系A行列を返す
114 }
115
122 template <size_t NB, size_t MB>
123 static constexpr Matrix<NB,MB> GetDiscMatB(
124 const Matrix<MB,MB>& Ac, const Matrix<NB,MB>& Bc, const double Ts, const size_t Npade, const size_t Nint
125 ){
126 return integral_expm(Ac, Ts, Nint, Npade)*Bc; // 離散系B行列を返す
127 }
128
129 private:
130 Discret() = delete;
131 Discret(Discret&& r) = delete;
132 ~Discret() = delete;
133 Discret(const Discret&) = delete;
134 const Discret& operator=(const Discret&) = delete;
135};
136}
137
138#endif
139
行列/ベクトル計算クラス(テンプレート版)
離散化クラス(テンプレート版V2)
Definition Discret.hh:21
static constexpr std::pair< Matrix< MB, MB >, Matrix< NB, MB > > GetDiscSystem(const Matrix< MB, MB > &Ac, const Matrix< NB, MB > &Bc, const double Ts)
連続系状態方程式のA,B行列を離散化する関数(構造化束縛版)
Definition Discret.hh:30
static constexpr Matrix< MB, MB > GetDiscMatA(const Matrix< MB, MB > &Ac, const double Ts, const size_t Npade)
連続系状態方程式のA行列を離散化して返す関数 (パデ近似の次数を自分で指定する場合)
Definition Discret.hh:112
static constexpr Matrix< NB, MB > GetDiscMatB(const Matrix< MB, MB > &Ac, const Matrix< NB, MB > &Bc, const double Ts, const size_t Npade, const size_t Nint)
連続系状態方程式のB行列を離散化する関数 (パデ近似の次数と定積分分割数を自分で指定する場合)
Definition Discret.hh:123
static constexpr std::pair< Matrix< MB, MB >, Matrix< NB, MB > > GetDiscSystem(const Matrix< MB, MB > &Ac, const Matrix< NB, MB > &Bc, const double Ts, const size_t Npade, const unsigned long Nint)
連続系状態方程式のA,B行列を離散化する関数 (構造化束縛版,パデ近似の次数と定積分分割数を自分で指定する場合)
Definition Discret.hh:45
static constexpr Matrix< MB, MB > GetDiscMatA(const Matrix< MB, MB > &Ac, const double Ts)
連続系状態方程式のA行列を離散化して返す関数
Definition Discret.hh:91
static constexpr void GetDiscSystem(const Matrix< MB, MB > &Ac, const Matrix< NB, MB > &Bc, Matrix< MB, MB > &Ad, Matrix< NB, MB > &Bd, const double Ts, const size_t Npade, const size_t Nint)
連続系状態方程式のA,B行列を離散化する関数 (パデ近似の次数と定積分分割数を自分で指定する場合)
Definition Discret.hh:79
static constexpr void GetDiscSystem(const Matrix< MB, MB > &Ac, const Matrix< NB, MB > &Bc, Matrix< MB, MB > &Ad, Matrix< NB, MB > &Bd, const double Ts)
連続系状態方程式のA,B行列を離散化する関数
Definition Discret.hh:62
static constexpr Matrix< NB, MB > GetDiscMatB(const Matrix< MB, MB > &Ac, const Matrix< NB, MB > &Bc, const double Ts)
連続系状態方程式のB行列を離散化する関数
Definition Discret.hh:101
行列/ベクトル計算クラス(テンプレート版)
Definition Matrix.hh:44