5 #ifndef LODESTAR_CONSTANTBLOCK_HPP
6 #define LODESTAR_CONSTANTBLOCK_HPP
8 #include "Lodestar/blocks/Block.hpp"
13 template<
typename TType>
35 this->
template p<0>() = constant;
39 typename ::std::tuple_element<0, typename Base::Params>::type &
42 return this->
template p<0>();
45 const typename ::std::tuple_element<0, typename Base::Params>::type &
48 return this->
template p<0>();
53 const ::std::array<GiNaC::ex, Base::kIns> &inputSymbols()
55 if (!this->isInitInput_) {
56 for (
int i = 0; i < Base::kIns; i++) {
65 "blk" + ::std::to_string(this->
id) +
"_i_" + ::std::to_string(i) +
66 "_r_" + ::std::to_string(ii) +
"_c_" + ::std::to_string(jj),
67 "\\text{BLK}^{i, " + ::std::to_string(i) +
", " + ::std::to_string(ii) +
68 ", " + ::std::to_string(jj) +
"}_{" + ::std::to_string(this->
id) +
"}"};
75 this->inputSymbols_[i] = GiNaC::lst_to_matrix(input);
77 this->inputSymbols_[i] = GiNaC::symbol{
"blk" + ::std::to_string(this->
id) +
"_i_" + ::std::to_string(i),
78 "\\text{BLK}^{i, " + ::std::to_string(i) +
"}_{" +
79 ::std::to_string(this->
id) +
84 this->isInitInput_ =
true;
87 return this->inputSymbols_;
90 const ::std::array<GiNaC::ex, Base::kOuts> &outputSymbols()
92 if (!this->isInitOutput_) {
93 for (
int i = 0; i < Base::kOuts; i++) {
102 "blk" + ::std::to_string(this->
id) +
"_o_" + ::std::to_string(i) +
103 "_r_" + ::std::to_string(ii) +
"_c_" + ::std::to_string(jj),
104 "\\text{BLK}^{i, " + ::std::to_string(i) +
", " + ::std::to_string(ii) +
105 ", " + ::std::to_string(jj) +
"}_{" + ::std::to_string(this->
id) +
"}"};
112 this->outputSymbols_[i] = GiNaC::lst_to_matrix(output);
114 this->outputSymbols_[i] = GiNaC::symbol{
"blk" + ::std::to_string(this->
id) +
"_o_" + ::std::to_string(i),
115 "\\text{BLK}^{i, " + ::std::to_string(i) +
"}_{" +
116 ::std::to_string(this->
id) +
121 this->isInitOutput_ =
true;
124 return this->outputSymbols_;
127 const ::std::array<GiNaC::ex, 1> ¶meterSymbols()
129 if (!this->isInitParameter_) {
136 ii < ls::aux::TemplateTraits::BinaryOperators::parseMatrixLike<TType>::rows; ii++) {
138 for (
int jj = 0; jj <
141 "blk" + ::std::to_string(this->
id) +
"_p_" + ::std::to_string(i) +
"_r_" +
142 ::std::to_string(ii) +
"_c_" + ::std::to_string(jj),
143 "\\text{BLK}^{i, " + ::std::to_string(i) +
", " + ::std::to_string(ii) +
144 ", " + ::std::to_string(jj) +
"}_{" + ::std::to_string(this->
id) +
"}"};
151 this->parameterSymbols_[i] = GiNaC::lst_to_matrix(output);
153 this->parameterSymbols_[i] = GiNaC::symbol{
"blk" + ::std::to_string(this->
id) +
"_p_" + ::std::to_string(i),
154 "\\text{BLK}^{i, " + ::std::to_string(i) +
"}_{" +
155 ::std::to_string(this->
id) +
159 this->isInitParameter_ =
true;
162 return this->parameterSymbols_;
169 ::std::array<GiNaC::ex, 1> parameterSymbols_;
174 this->equation = ::std::bind(
177 ::std::placeholders::_1
181 GiNaC::function_options fops(
"blkf" + ::std::to_string(this->
id) +
"__", this->blkFunc_NPARAMS);
182 ls::blocks::symbolicEvalFunctionMap[this->
id] = [&](const ::std::vector<GiNaC::ex> &exvec) -> GiNaC::ex {
183 return GiNaC::ex{this->parameterSymbols()[0]};
186 fops.eval_func(ls::blocks::symbolicEval);
189 this->serial = GiNaC::function::register_new(
195 void triggerFunction(
Base &b)
197 b.template o<0>() = b.template p<0>();
202 template<
typename TType>
207 directFeedthrough =
true
219 static const ::std::array<::std::string, kIns> inTypes;
220 static const ::std::array<::std::string, kOuts> outTypes;
221 static const ::std::array<::std::string, kPars> parTypes;
223 static const ::std::array<::std::string, 1> templateTypes;
226 template<
typename TType>
230 template<
typename TType>
231 const ::std::array<::std::string, BlockTraits<std::ConstantBlock<TType>>::kOuts> BlockTraits<std::ConstantBlock<TType>>::outTypes =
232 {demangle(
typeid(TType).name())};
234 template<
typename TType>
235 const ::std::array<::std::string, BlockTraits<std::ConstantBlock<TType>>::kPars> BlockTraits<std::ConstantBlock<TType>>::parTypes =
236 {demangle(
typeid(TType).name())};
238 template<
typename TType>
239 const ::std::array<::std::string, 1> BlockTraits<std::ConstantBlock<TType>>::templateTypes =
240 {demangle(
typeid(TType).name())};
245 #endif //LODESTAR_CONSTANTBLOCK_HPP