Lodestar
An integrated real-time control package in C++
GainBlock.hpp
1 //
2 // Created by Hamza El-Kebir on 12/23/21.
3 //
4 
5 #ifndef LODESTAR_GAINBLOCK_HPP
6 #define LODESTAR_GAINBLOCK_HPP
7 
8 #include "Lodestar/blocks/Block.hpp"
9 #include "Lodestar/aux/TemplateTools.hpp"
10 
11 namespace ls {
12  namespace blocks {
13  namespace std {
19  enum class GainBlockOperator {
21  Left,
23  Right,
28  };
29 
36  Reflect,
38  Constant,
40  Nearest,
42  Mirror,
44  Wrap
45  };
46 
47 #define OUTPUT_GAINBLOCK() \
48  typename ::std::conditional< \
49  TOps == GainBlockOperator::Convolution, \
50  TInput, \
51  typename ::std::conditional< \
52  ::std::is_arithmetic<TGain>::value, \
53  TInput, \
54  typename ls::aux::TemplateTraits::BinaryOperators::sanitizeTypeMultiplicable<typename ::std::conditional< \
55  TOps != GainBlockOperator::Right, \
56  ls::aux::TemplateTraits::BinaryOperators::isMultiplicable<TGain, TInput>, \
57  ls::aux::TemplateTraits::BinaryOperators::isMultiplicable<TInput, TGain> \
58  >::type::returnType>::returnType \
59  >::type \
60  >::type
61 
93  template<typename TInput, typename TGain = TInput, GainBlockOperator TOps = GainBlockOperator::Left, GainBlockConvolutionMode TConv = GainBlockConvolutionMode::Reflect>
94  class GainBlock :
95  public Block<
96  ::std::tuple<TInput>,
97  ::std::tuple<OUTPUT_GAINBLOCK()>,
98  ::std::tuple<TGain, double>
99  > {
100  public:
102  using OutputTrait = typename ::std::conditional<
103  TOps != GainBlockOperator::Right,
106  >::type;
107  static_assert(OutputTrait::value || (TOps == GainBlockOperator::Convolution),
108  "Gain is not multiplicable with input.");
111 
113  using OutputType = OUTPUT_GAINBLOCK();
114 
119  static_assert((TOps != GainBlockOperator::Convolution) || (GainTrait::value && InputTrait ::value),
120  "For convolution, TInput and TGain must be matrix-like.");
121 
123  using Base =
124  Block<
125  ::std::tuple<TInput>,
126  ::std::tuple<OutputType>,
127  ::std::tuple<TGain, double>
128  >;
129 
132 
135 
137  static constexpr Ops Left = Ops::Left;
139  static constexpr Ops Right = Ops::Right;
141  static constexpr Ops Convolution = Ops::Convolution;
143  static constexpr Ops ElementWise = Ops::ElementWise;
144 
146  static constexpr Conv Reflect = Conv::Reflect;
148  static constexpr Conv Constant = Conv::Constant;
150  static constexpr Conv Nearest = Conv::Nearest;
152  static constexpr Conv Mirror = Conv::Mirror;
154  static constexpr Conv Wrap = Conv::Wrap;
155 
156  // TODO: Find way to potentially make operator compile-time
157  // settable.
158 // GainBlock(const Ops op = Left)
159 // {
160 // setOperator(op);
161 // bindEquation();
162 // }
163 //
164 // GainBlock(const TGain &gain, const Ops op = Left)
165 // {
166 // setOperator(op);
167 // this->template p<0>() = gain;
168 // bindEquation();
169 // }
170 
175  {
176  bindEquation();
177  }
178 
184  GainBlock(const TGain &gain)
185  {
186  this->template p<0>() = gain;
187  bindEquation();
188  }
189 
195  void setGain(const TGain &gain)
196  {
197  this->template p<0>() = gain;
198  }
199 
205  const TGain &getGain() const
206  {
207  return this->template p<0>();
208  }
209 
210 // void setOperator(Ops op)
211 // {
212 // this->template p<1>() = op;
213 // }
214 //
215 // Ops getOperator()
216 // {
217 // return this->template p<1>();
218 // }
219 
225  typename ::std::tuple_element<0, typename Base::Params>::type &
227  {
228  return this->template p<0>();
229  }
230 
236  const typename ::std::tuple_element<0, typename Base::Params>::type &
237  gain() const
238  {
239  return this->template p<0>();
240  }
241 
242  // TODO: Make constantVal type user-settable.
243 
249  typename ::std::tuple_element<1, typename Base::Params>::type &
251  {
252  return this->template p<1>();
253  }
254 
260  const typename ::std::tuple_element<1, typename Base::Params>::type &
261  constantVal() const
262  {
263  return this->template p<1>();
264  }
265 
266 #ifdef LS_USE_GINAC
267 
268  const ::std::array<GiNaC::ex, Base::kIns> &inputSymbols()
269  {
270  if (!this->isInitInput_) {
271  for (int i = 0; i < Base::kIns; i++) {
273  GiNaC::lst input;
274  for (int ii = 0; ii <
276  GiNaC::lst row;
277  for (int jj = 0; jj <
279  GiNaC::symbol entry{
280  "blk" + ::std::to_string(this->id) + "_i_" + ::std::to_string(i) +
281  "_r_" + ::std::to_string(ii) + "_c_" + ::std::to_string(jj),
282  "\\text{BLK}^{i, " + ::std::to_string(i) + ", " + ::std::to_string(ii) +
283  ", " + ::std::to_string(jj) + "}_{" + ::std::to_string(this->id) + "}"};
284 
285  row.append(entry);
286  }
287  input.append(row);
288  }
289 
290  this->inputSymbols_[i] = GiNaC::lst_to_matrix(input);
291  } else {
292  this->inputSymbols_[i] = GiNaC::symbol{
293  "blk" + ::std::to_string(this->id) + "_i_" + ::std::to_string(i),
294  "\\text{BLK}^{i, " + ::std::to_string(i) + "}_{" +
295  ::std::to_string(this->id) +
296  "}"};
297  }
298  }
299 
300  this->isInitInput_ = true;
301  }
302 
303  return this->inputSymbols_;
304  }
305 
306  const ::std::array<GiNaC::ex, Base::kOuts> &outputSymbols()
307  {
308  if (!this->isInitOutput_) {
309  for (int i = 0; i < Base::kOuts; i++) {
311  GiNaC::lst output;
312  for (int ii = 0; ii <
314  GiNaC::lst row;
315  for (int jj = 0; jj <
317  GiNaC::symbol entry{
318  "blk" + ::std::to_string(this->id) + "_o_" + ::std::to_string(i) +
319  "_r_" + ::std::to_string(ii) + "_c_" + ::std::to_string(jj),
320  "\\text{BLK}^{i, " + ::std::to_string(i) + ", " + ::std::to_string(ii) +
321  ", " + ::std::to_string(jj) + "}_{" + ::std::to_string(this->id) + "}"};
322 
323  row.append(entry);
324  }
325  output.append(row);
326  }
327 
328  this->outputSymbols_[i] = GiNaC::lst_to_matrix(output);
329  } else {
330  this->outputSymbols_[i] = GiNaC::symbol{
331  "blk" + ::std::to_string(this->id) + "_o_" + ::std::to_string(i),
332  "\\text{BLK}^{o, " + ::std::to_string(i) + "}_{" +
333  ::std::to_string(this->id) +
334  "}"};
335  }
336  }
337 
338  this->isInitOutput_ = true;
339  }
340 
341  return this->outputSymbols_;
342  }
343 
344  const ::std::array<GiNaC::ex, Base::kPars> &parameterSymbols()
345  {
346  if (!this->isInitParameter_) {
347  int i = 0;
348  {
350  GiNaC::lst par;
351  for (int ii = 0; ii <
353  GiNaC::lst row;
354  for (int jj = 0; jj <
356  GiNaC::symbol entry{
357  "blk" + ::std::to_string(this->id) + "_p_" + ::std::to_string(i) +
358  "_r_" + ::std::to_string(ii) + "_c_" + ::std::to_string(jj),
359  "\\text{BLK}^{i, " + ::std::to_string(i) + ", " + ::std::to_string(ii) +
360  ", " + ::std::to_string(jj) + "}_{" + ::std::to_string(this->id) + "}"};
361 
362  row.append(entry);
363  }
364  par.append(row);
365  }
366 
367  this->parameterSymbols_[i] = GiNaC::lst_to_matrix(par);
368  } else {
369  this->parameterSymbols_[i] = GiNaC::symbol{
370  "blk" + ::std::to_string(this->id) + "_p_" + ::std::to_string(i),
371  "\\text{BLK}^{p, " + ::std::to_string(i) + "}_{" +
372  ::std::to_string(this->id) +
373  "}"};
374  }
375  }
376 
377  // constant value symbol
378  i++;
379  this->parameterSymbols_[i] = GiNaC::symbol{
380  "blk" + ::std::to_string(this->id) + "_p_" + ::std::to_string(i),
381  "\\text{BLK}^{p, " + ::std::to_string(i) + "}_{" +
382  ::std::to_string(this->id) +
383  "}"};
384 
385  this->isInitParameter_ = true;
386  }
387 
388  return this->parameterSymbols_;
389  }
390 
391 #endif
392 
393  protected:
401  template<GainBlockOperator TTOps = TOps, typename ::std::enable_if<TTOps == Left>::type * = nullptr>
403  {
404  this->equation = [](Base &b) -> void {
405  b.template o<0>().object =
406  b.template p<0>() * b.template i<0>().object;
407  b.template o<0>().propagate();
408  };
409 
410 #ifdef LS_USE_GINAC
411  GiNaC::function_options fops("blkf" + ::std::to_string(this->id) + "__", this->blkFunc_NPARAMS);
412 
413  ls::blocks::symbolicEvalFunctionMap[this->id] = [&](
414  const ::std::vector<GiNaC::ex> &exvec) -> GiNaC::ex {
415  GiNaC::ex res = 0;
416  int i = 0;
417 
418  for (auto &ex: exvec) {
419  res += this->parameterSymbols()[0] * ex;
420 
421  i++;
422  }
423 
424  return res;
425  };
426 
427  fops.eval_func(ls::blocks::symbolicEval);
428 
429 
430  this->serial = GiNaC::function::register_new(
431  fops
432  );
433 #endif
434  }
435 
442  template<GainBlockOperator TTOps = TOps, typename ::std::enable_if<TTOps == Right>::type * = nullptr>
444  {
445  this->equation = [](Base &b) -> void {
446  b.template o<0>().object =
447  b.template i<0>().object * b.template p<0>();
448  b.template o<0>().propagate();
449  };
450 
451 #ifdef LS_USE_GINAC
452  GiNaC::function_options fops("blkf" + ::std::to_string(this->id) + "__", this->blkFunc_NPARAMS);
453 
454  ls::blocks::symbolicEvalFunctionMap[this->id] = [&](
455  const ::std::vector<GiNaC::ex> &exvec) -> GiNaC::ex {
456  GiNaC::ex res = 0;
457  int i = 0;
458 
459  for (auto &ex: exvec) {
460  res += ex * this->parameterSymbols()[0];
461 
462  i++;
463  }
464 
465  return res;
466  };
467 
468  fops.eval_func(ls::blocks::symbolicEval);
469 
470 
471  this->serial = GiNaC::function::register_new(
472  fops
473  );
474 #endif
475  }
476 
484  template<GainBlockOperator TTOps = TOps, GainBlockConvolutionMode TTConv = TConv,
485  typename ::std::enable_if<((TTOps == Convolution) && (TTConv == Reflect))>::type * = nullptr>
486  static void convolve(Base &b)
487  {
488  static const auto NRowsKernel = GainTrait::rows;
489  static const auto NColsKernel = GainTrait::cols;
490  static const auto NRowsInput = InputTrait::rows;
491  static const auto NColsInput = InputTrait::cols;
492 
493  auto getInput = [&](int i, int j) {
494  if (i < 0)
495  i = (-i - 1) % NRowsInput;
496  if (i >= NRowsInput)
497  i = (2*NRowsInput - i - 1) % NRowsInput;
498 
499  if (j < 0)
500  j = (-j - 1) % NColsInput;
501  if (j >= NColsInput)
502  j = (2*NColsInput - j - 1) % NColsInput;
503 
504  return b.template i<0>().object(i, j);
505  };
506 
507  b.template o<0>().object.setZero();
508 
509  for (int i=0; i < NRowsInput; i++) {
510  for (int j=0; j < NColsInput; j++) {
511  for (int ii=0; ii < NRowsKernel; ii++) {
512  for (int jj=0; jj < NColsKernel; jj++) {
513  b.template o<0>().object(i, j) -= b.template p<0>()(ii, jj) * getInput(i - (NRowsKernel-1)/2 + ii, j - (NColsKernel-1)/2 + jj);
514  }
515  }
516  }
517  }
518 
519  b.template o<0>().propagate();
520  }
521 
529  template<GainBlockOperator TTOps = TOps, GainBlockConvolutionMode TTConv = TConv,
530  typename ::std::enable_if<((TTOps == Convolution) && (TTConv == Constant))>::type * = nullptr>
531  static void convolve(Base &b)
532  {
533  static const auto NRowsKernel = GainTrait::rows;
534  static const auto NColsKernel = GainTrait::cols;
535  static const auto NRowsInput = InputTrait::rows;
536  static const auto NColsInput = InputTrait::cols;
537 
538  auto getInput = [&](int i, int j) {
539  if (i < 0)
540  return b.template p<1>();
541  if (i >= NRowsInput)
542  return b.template p<1>();
543 
544  if (j < 0)
545  return b.template p<1>();
546  if (j >= NColsInput)
547  return b.template p<1>();
548 
549  return b.template i<0>().object(i, j);
550  };
551 
552  b.template o<0>().object.setZero();
553 
554  for (int i=0; i < NRowsInput; i++) {
555  for (int j=0; j < NColsInput; j++) {
556  for (int ii=0; ii < NRowsKernel; ii++) {
557  for (int jj=0; jj < NColsKernel; jj++) {
558  b.template o<0>().object(i, j) -= b.template p<0>()(ii, jj) * getInput(i - (NRowsKernel-1)/2 + ii, j - (NColsKernel-1)/2 + jj);
559  }
560  }
561  }
562  }
563 
564  b.template o<0>().propagate();
565  }
566 
574  template<GainBlockOperator TTOps = TOps, GainBlockConvolutionMode TTConv = TConv,
575  typename ::std::enable_if<((TTOps == Convolution) && (TTConv == Nearest))>::type * = nullptr>
576  static void convolve(Base &b)
577  {
578  static const auto NRowsKernel = GainTrait::rows;
579  static const auto NColsKernel = GainTrait::cols;
580  static const auto NRowsInput = InputTrait::rows;
581  static const auto NColsInput = InputTrait::cols;
582 
583  auto getInput = [&](int i, int j) {
584  if (i < 0)
585  i = 0;
586  if (i >= NRowsInput)
587  i = NRowsInput - 1;
588 
589  if (j < 0)
590  j = 0;
591  if (j >= NColsInput)
592  j = NColsInput-1;
593 
594  return b.template i<0>().object(i, j);
595  };
596 
597  b.template o<0>().object.setZero();
598 
599  for (int i=0; i < NRowsInput; i++) {
600  for (int j=0; j < NColsInput; j++) {
601  for (int ii=0; ii < NRowsKernel; ii++) {
602  for (int jj=0; jj < NColsKernel; jj++) {
603  b.template o<0>().object(i, j) -= b.template p<0>()(ii, jj) * getInput(i - (NRowsKernel-1)/2 + ii, j - (NColsKernel-1)/2 + jj);
604  }
605  }
606  }
607  }
608 
609  b.template o<0>().propagate();
610  }
611 
619  template<GainBlockOperator TTOps = TOps, GainBlockConvolutionMode TTConv = TConv,
620  typename ::std::enable_if<((TTOps == Convolution) && (TTConv == Mirror))>::type * = nullptr>
621  static void convolve(Base &b)
622  {
623  static const auto NRowsKernel = GainTrait::rows;
624  static const auto NColsKernel = GainTrait::cols;
625  static const auto NRowsInput = InputTrait::rows;
626  static const auto NColsInput = InputTrait::cols;
627 
628  auto getInput = [&](int i, int j) {
629  if (i < 0)
630  i = (-i) % NRowsInput;
631  if (i >= NRowsInput)
632  i = (2*NRowsInput - i - 2) % NRowsInput;
633 
634  if (j < 0)
635  j = (-j) % NColsInput;
636  if (j >= NColsInput)
637  j = (2*NColsInput - j - 2) % NColsInput;
638 
639  return b.template i<0>().object(i, j);
640  };
641 
642  b.template o<0>().object.setZero();
643 
644  for (int i=0; i < NRowsInput; i++) {
645  for (int j=0; j < NColsInput; j++) {
646  for (int ii=0; ii < NRowsKernel; ii++) {
647  for (int jj=0; jj < NColsKernel; jj++) {
648  b.template o<0>().object(i, j) -= b.template p<0>()(ii, jj) * getInput(i - (NRowsKernel-1)/2 + ii, j - (NColsKernel-1)/2 + jj);
649  }
650  }
651  }
652  }
653 
654  b.template o<0>().propagate();
655  }
656 
664  template<GainBlockOperator TTOps = TOps, GainBlockConvolutionMode TTConv = TConv,
665  typename ::std::enable_if<((TTOps == Convolution) && (TTConv == Wrap))>::type * = nullptr>
666  static void convolve(Base &b)
667  {
668  static const auto NRowsKernel = GainTrait::rows;
669  static const auto NColsKernel = GainTrait::cols;
670  static const auto NRowsInput = InputTrait::rows;
671  static const auto NColsInput = InputTrait::cols;
672 
673  auto getInput = [&](int i, int j) {
674  if (i < 0)
675  i = (NRowsInput + i) % NRowsInput;
676  if (i >= NRowsInput)
677  i = i % NRowsInput;
678 
679  if (j < 0)
680  j = (NColsInput + j) % NColsInput;
681  if (j >= NColsInput)
682  j = j % NColsInput;
683 
684  return b.template i<0>().object(i, j);
685  };
686 
687  b.template o<0>().object.setZero();
688 
689  for (int i=0; i < NRowsInput; i++) {
690  for (int j=0; j < NColsInput; j++) {
691  for (int ii=0; ii < NRowsKernel; ii++) {
692  for (int jj=0; jj < NColsKernel; jj++) {
693  b.template o<0>().object(i, j) -= b.template p<0>()(ii, jj) * getInput(i - (NRowsKernel-1)/2 + ii, j - (NColsKernel-1)/2 + jj);
694  }
695  }
696  }
697  }
698 
699  b.template o<0>().propagate();
700  }
701 
708  template<GainBlockOperator TTOps = TOps, typename ::std::enable_if<
709  TTOps == Convolution>::type * = nullptr>
711  {
712  this->equation = [](Base &b) -> void {
713  convolve(b);
714  };
715 
716 //#ifdef LS_USE_GINAC
717 // GiNaC::function_options fops("blkf" + ::std::to_string(this->id) + "__", this->blkFunc_NPARAMS);
718 //
719 // ls::blocks::symbolicEvalFunctionMap[this->id] = [&](
720 // const ::std::vector<GiNaC::ex> &exvec) -> GiNaC::ex {
721 // GiNaC::ex res = 0;
722 // int i = 0;
723 //
724 // for (auto &ex: exvec) {
725 // res += ex * this->parameterSymbols()[0];
726 //
727 // i++;
728 // }
729 //
730 // return res;
731 // };
732 //
733 // fops.eval_func(ls::blocks::symbolicEval);
734 //
735 //
736 // this->serial = GiNaC::function::register_new(
737 // fops
738 // );
739 //#endif
740  }
741 
742  // TODO: Implement convolution and elementwise multiplication.
743  };
744  }
745 
752  template<typename TInput, typename TGain, std::GainBlockOperator TOps, std::GainBlockConvolutionMode TConv>
753  class BlockTraits<std::GainBlock<TInput, TGain, TOps, TConv>> {
754  public:
755  static constexpr const BlockType blockType = BlockType::GainBlock;
756  enum {
757  directFeedthrough = true
758  };
759 
761  using Base = typename type::Base;
762 
763  enum {
764  kIns = Base::kIns,
765  kOuts = Base::kOuts,
766  kPars = Base::kPars
767  };
768 
769  static const ::std::array<::std::string, kIns> inTypes;
770  static const ::std::array<::std::string, kOuts> outTypes;
771  static const ::std::array<::std::string, kPars> parTypes;
772 
773  static const ::std::array<::std::string, 4> templateTypes;
774  };
775 
776  template<typename TInput, typename TGain, std::GainBlockOperator TOps, std::GainBlockConvolutionMode TConv>
777  const ::std::array<::std::string, BlockTraits<std::GainBlock<TInput, TGain, TOps, TConv>>::kIns> BlockTraits<std::GainBlock<TInput, TGain, TOps, TConv>>::inTypes =
778  {demangle(typeid(TInput).name())};
779 
780  template<typename TInput, typename TGain, std::GainBlockOperator TOps, std::GainBlockConvolutionMode TConv>
781  const ::std::array<::std::string, BlockTraits<std::GainBlock<TInput, TGain, TOps, TConv>>::kOuts> BlockTraits<std::GainBlock<TInput, TGain, TOps, TConv>>::outTypes =
782  {demangle(typeid(typename std::GainBlock<TInput, TGain, TOps>::OutputType).name())};
783 
784  template<typename TInput, typename TGain, std::GainBlockOperator TOps, std::GainBlockConvolutionMode TConv>
785  const ::std::array<::std::string, BlockTraits<std::GainBlock<TInput, TGain, TOps, TConv>>::kPars> BlockTraits<std::GainBlock<TInput, TGain, TOps, TConv>>::parTypes =
786  {demangle(typeid(TGain).name()), "double"};
787 
788  template<typename TInput, typename TGain, std::GainBlockOperator TOps, std::GainBlockConvolutionMode TConv>
789  const ::std::array<::std::string, 4> BlockTraits<std::GainBlock<TInput, TGain, TOps, TConv>>::templateTypes =
790  {demangle(typeid(TInput).name()), demangle(typeid(TGain).name()), demangle(typeid(TOps).name()),
791  demangle(typeid(TConv).name())};
792  }
793 }
794 
795 #undef OUTPUT_GAINBLOCK
796 
797 #endif //LODESTAR_GAINBLOCK_HPP
ls::blocks::std::GainBlockConvolutionMode::Mirror
@ Mirror
Extend by reflecting about the center of the last pixel. Also known as whole-sample symmetric.
ls::blocks::std::GainBlock::Mirror
static constexpr Conv Mirror
Utility alias for mirror convolution mode.
Definition: GainBlock.hpp:152
ls::blocks::std::GainBlockOperator::ElementWise
@ ElementWise
Elementwise multiplication.
ls::blocks::BlockTraits::directFeedthrough
static constexpr const bool directFeedthrough
Whether or not the block has direct feedthrough.
Definition: BlockTraits.hpp:44
ls::blocks::std::GainBlockOperator::Convolution
@ Convolution
Linear convolution.
ls::aux::TemplateTraits::BinaryOperators::sanitizeTypeBinop
Sanitizes a binary operator return type.
Definition: TemplateTraits.hpp:152
ls::blocks::std::GainBlock::Wrap
static constexpr Conv Wrap
Utility alias for wrap convolution mode.
Definition: GainBlock.hpp:154
ls::blocks::std::GainBlock::Left
static constexpr Ops Left
Utility alias for left multiplication.
Definition: GainBlock.hpp:137
ls::blocks::std::GainBlock::getGain
const TGain & getGain() const
Definition: GainBlock.hpp:205
ls::blocks::std::GainBlockConvolutionMode
GainBlockConvolutionMode
Convolution modes for GainBlock.
Definition: GainBlock.hpp:34
ls::blocks::std::GainBlock::gain
typename ::std::tuple_element< 0, typename Base::Params >::type & gain()
Definition: GainBlock.hpp:226
ls::blocks::std::GainBlock::Convolution
static constexpr Ops Convolution
Utility alias for convolution.
Definition: GainBlock.hpp:141
ls::blocks::std::GainBlock::gain
const typename ::std::tuple_element< 0, typename Base::Params >::type & gain() const
Definition: GainBlock.hpp:237
ls::aux::TemplateTraits::BinaryOperators::isBinopableImpl
Definition: TemplateTraits.hpp:90
ls::blocks::std::GainBlock::Constant
static constexpr Conv Constant
Utility alias for constant convolution mode.
Definition: GainBlock.hpp:148
ls::blocks::BlockTraits
A traits object that exposes information about TBlock.
Definition: BlockTraits.hpp:37
ls::blocks::BlockTraits::inTypes
static const ::std::array<::std::string, kIns > inTypes
Input types (as strings).
Definition: BlockTraits.hpp:59
ls::blocks::BlockType
BlockType
Block type information.
Definition: BlockType.hpp:25
ls::blocks::std::GainBlockOperator::Left
@ Left
Left multiplication.
ls::blocks::std::GainBlock::setGain
void setGain(const TGain &gain)
Definition: GainBlock.hpp:195
ls::aux::TemplateTraits::BinaryOperators::parseMatrixLike
Extracts data from matrix-like types.
Definition: TemplateTraits.hpp:114
ls::blocks::std::GainBlockConvolutionMode::Reflect
@ Reflect
Reflect about the edge of the last pixel. Also known as half-sample symmetric.
ls
Main Lodestar code.
Definition: BilinearTransformation.hpp:12
ls::blocks::std::GainBlock
Multiplies input by a value (gain).
Definition: GainBlock.hpp:94
ls::blocks::std::GainBlockOperator
GainBlockOperator
Operation types for GainBlock.
Definition: GainBlock.hpp:19
ls::blocks::BlockProto::id
const unsigned int id
Vector of output signal pointers.
Definition: BlockProto.hpp:28
ls::blocks::std::GainBlock::constantVal
typename ::std::tuple_element< 1, typename Base::Params >::type & constantVal()
Definition: GainBlock.hpp:250
ls::blocks::std::GainBlock::GainBlock
GainBlock(const TGain &gain)
Definition: GainBlock.hpp:184
ls::blocks::std::GainBlock::constantVal
const typename ::std::tuple_element< 1, typename Base::Params >::type & constantVal() const
Definition: GainBlock.hpp:261
ls::blocks::std::GainBlockConvolutionMode::Constant
@ Constant
Fill all values beyond edges with a constant value.
ls::blocks::std::GainBlock::GainBlock
GainBlock()
Definition: GainBlock.hpp:174
ls::blocks::BlockTraits::outTypes
static const ::std::array<::std::string, kOuts > outTypes
Output types (as strings).
Definition: BlockTraits.hpp:61
ls::blocks::std::GainBlock::OutputType
OUTPUT_GAINBLOCK() OutputType
Output type.
Definition: GainBlock.hpp:113
ls::blocks::BlockTraits::blockType
static constexpr const BlockType blockType
Block type.
Definition: BlockTraits.hpp:42
ls::blocks::std::GainBlock::ElementWise
static constexpr Ops ElementWise
Utility alias for elementwise multiplication.
Definition: GainBlock.hpp:143
ls::blocks::std::GainBlock::Nearest
static constexpr Conv Nearest
Utility alias for nearest convolution mode.
Definition: GainBlock.hpp:150
ls::blocks::std::GainBlock::convolve
static void convolve(Base &b)
Definition: GainBlock.hpp:486
ls::blocks::BlockTraits::templateTypes
static const ::std::array<::std::string, 1 > templateTypes
Template parameter types (as strings).
Definition: BlockTraits.hpp:66
ls::blocks::Block
Generic base template class for all tuple-based Block instances.
Definition: Block.hpp:45
ls::blocks::BlockTraits::kIns
static const constexpr int kIns
Number of input slots.
Definition: BlockTraits.hpp:52
ls::blocks::std::GainBlock::OutputTrait
typename ::std::conditional< TOps !=GainBlockOperator::Right, ls::aux::TemplateTraits::BinaryOperators::isMultiplicable< TGain, TInput >, ls::aux::TemplateTraits::BinaryOperators::isMultiplicable< TInput, TGain > >::type OutputTrait
Output type trait.
Definition: GainBlock.hpp:106
ls::blocks::std::GainBlock::bindEquation
void bindEquation()
Sets trigger function for non-right multiplication TOps.
Definition: GainBlock.hpp:402
ls::blocks::BlockTraits::parTypes
static const ::std::array<::std::string, kPars > parTypes
Parameter types (as strings).
Definition: BlockTraits.hpp:63
ls::blocks::std::GainBlockOperator::Right
@ Right
Right multiplication.
ls::blocks::std::GainBlockConvolutionMode::Nearest
@ Nearest
Extend by replicating last pixel.
ls::blocks::std::GainBlockConvolutionMode::Wrap
@ Wrap
Wrap around to the opposing edge.
ls::blocks::BlockTraits::kPars
static const constexpr int kPars
Number of parameters.
Definition: BlockTraits.hpp:56
ls::blocks::std::GainBlock::SanitizedOutputTrait
typename ls::aux::TemplateTraits::BinaryOperators::sanitizeTypeMultiplicable< typename OutputTrait::returnType > SanitizedOutputTrait
Sanitized output type trait.
Definition: GainBlock.hpp:110
ls::blocks::std::GainBlock::Right
static constexpr Ops Right
Utility alias for right multiplication.
Definition: GainBlock.hpp:139
ls::blocks::std::GainBlock::Reflect
static constexpr Conv Reflect
Utility alias for reflect convolution mode.
Definition: GainBlock.hpp:146
ls::blocks::BlockTraits::kOuts
static const constexpr int kOuts
Number of output slots.
Definition: BlockTraits.hpp:54
ls::blocks::BlockType::GainBlock
@ GainBlock
Gain block.