title: Return Initial-state only once
body: <p>may you have an idea.</p>
  
  <p>I want to call a discrete time function "execute". 
  First call: "execute" returns an init-state
  Every next call: "execute" returns a calculated value.</p>
  
  <p>My idea with a "Initflag" (runtime):</p>
  
  <pre><code>while( true ){
    myValue = myObj.execute();
    doSomethingWith( myValue );
  }
  
  //Anywhere in a Class
  public:
     float execute(){
       if( InitFlag ){
         InitFlag  = false; //now permanent set to false
         return 42;
       }
       else{
         return value = value + 42;
       }
  }
  private:
    bool InitFlag = true;
    float value = 0;
  }
  </code></pre>
  
  <p>My Question:
  Is there a way to implement the "init" to "NormalExecution" -switchin to compiletime ? Without asking a flag permanently ?</p>
  
  <p>Exists a better "Keyword" / "Description" for this problem ?</p>
  
  <p>Thanks for your help</p>
  
  <pre><code>//Bigger view
  
  // One of my algorithm (dont take it, it´s not tested)
  
  /// Integrator Euler-Backward 1/s Z-Transf. K*Ts*z/(z - 1) with K := slope, Ts := SampleTime
  template&lt;class T&gt;
  class IntegratorEB{//Euler Backward
  public:
  ///CTOR
  /// @brief Constructor
  IntegratorEB(const T&amp; K)
  : Ts_(1.0), u_(0.0), y_(0.0), h_(K*Ts_), InitFlag_(true) {}
  ///END_CTOR
  
  ///ACCESS
      /// @brief copy and save input u
      void Input(const T&amp; u){
          u_ = u;
      }
  
      //TODO First call should not change y_
      /// @brief calculate new output y 
      void Execute(){
          if( InitFlag ){
            y_ = y_; //or do nothing...
            InitFlag = false; 
          }
          else
            y_ = y_ + h_ * u_;  // y[k] = y[k-1] + h * u[k];
      }
  
      /// @brief read output, return copy
      T Output() const{
          return y_;
      }
      /// @brief read output, return reference
      const T&amp; Output() const{
          return y_;
      }
  ///END_ACCESS
  private:
      T Ts_;  //SampleTime
      T u_;   //Input u[k]
      T y_;   //Output y[k]
      T h_;   //Stepsize
  
      bool InitFlag_;
  
  };
  </code></pre>
  
  <p>Whished use of the class </p>
  
  <pre><code>1.Init 
  2. Loop calls any algorithmen in the same way
  2.1 Input
  2.2 Execute
  2.3 Output
  </code></pre>
  
  <p>An example for the call with another algorithm:</p>
  
  <pre><code>std::cout &lt;&lt; "Class Statespace"; //Ausgabe  
  for(int t = 1; t &lt;= 50; ++t){
      DCMotor.Input(Matrix&lt;float, 1, 1&gt;(u));
      DCMotor.Execute();
      y = DCMotor.Output();
      std::cout &lt;&lt; "t = " &lt;&lt; t &lt;&lt; " y = " &lt;&lt; y; //Ausgabe
  }
  </code></pre>
  
  <p>My Question:
  I like to handle each algorithm in the same way. First call of execute supply the Initstate. For the example on top it works(depend on the algorith-structure). For my class "IntegratorEB" not. (or just with asking a runtime-flag ?! )</p>
  
  <p>Hope it will be clearly. </p>