// file: $isip/doc/examples/class/math/vector/math_vector_example_01/example.cc
// version: $Id: example.cc 5954 2000-12-17 18:26:04Z hamaker $
//

// isip include files
//
#include <VectorFloat.h>
#include <VectorLong.h>
#include <Console.h>

// main program starts here:
//  this example demonstrates the use of math vector methods to manipulate
//  the values of a vector.
//
int main () {
  
  // define a vector of floats that is 5 elements long
  // and a vector of integers
  //
  VectorFloat signal(5);
  VectorLong idx;
  
  // generate a ramp. it will start at 1.0 with a slope of 2.0.
  //
  signal.ramp(1.0, 2.0);
  
  // print the signal using the debug method
  //
  signal.debug(L"The signal is ");
  
  // generate an index array for reordering
  //
  idx.assign(L"4, 3, 2, 1, 0");
  
  // time-reverse the signal via the reorder method.
  //
  signal.reorder(idx);
  
  // verify that the signal is reversed
  //
  signal.debug(L"The time-reversed signal is ");
  
  // increase the length of the signal to 10 elements.
  //
  signal.setLength(10);

  // zero-out the new elements. this step is not strictly needed,
  // since the values were initially zero and the program has never
  // assigned them to other elements. however, the setLength() method
  // does NOT zero out new elements, so if this vector was previously
  // a longer length with non-zero elements in these new positions
  // somewhat unpredictable results could occur.
  //
  for (long i = 5; i < 10; i++) {
    signal(i) = 0;
  }
  
  // verify that the signal has been zero-stuffed
  //
  signal.debug(L"The zero-stuffed signal is ");
  
  // exit gracefully
  //
  Integral::exit();
}
