// file: $isip/class/algo/Statistics/stat_06.cc
// version: $Id: stat_06.cc 8314 2002-07-09 02:19:50Z picone $
//

// isip include files
//
#include "Statistics.h"

// method: setAccumulateVar
//
// arguments:
//  long num_channel: (input) number of channels in the input data
//  long dimension: (input) number of elements per channel
//
// return: a boolean value indicating status
//
// this method initializes the accumulator variables.
//
boolean Statistics::setAccumulateVar(long num_channel_a, long dimension_a) {

  // create some scalar accumulators
  //
  accum_sum_d.setLength(num_channel_a);
  accum_sumsqr_d.setLength(num_channel_a);
  accum_result_d.setLength(num_channel_a);
  accum_frame_data_d.setLength(num_channel_a);
  accum_frame_buff_d.setLength(num_channel_a);
  accum_samples_d = 0;
  accum_frames_d = 0;

  // create space to hold all past data
  //
  for (long i = 0; i < num_channel_a; i++) {

    // resize each vector
    //
    accum_sum_d(i).makeVectorFloat().setLength(dimension_a);
    accum_sumsqr_d(i).makeVectorFloat().setLength(dimension_a);
    accum_result_d(i).makeVectorFloat().setLength(dimension_a);
    accum_frame_data_d(i).makeVectorFloat().setLength(dimension_a);
    accum_frame_buff_d(i).setLength(dimension_a);

    // initialize the value
    //
    accum_sum_d(i).getVectorFloat().assign((float)0);
    accum_sumsqr_d(i).getVectorFloat().assign((float)0);
    accum_result_d(i).getVectorFloat().assign((float)0);
    accum_frame_data_d(i).getVectorFloat().assign((float)0);   
    
    // initialize the value
    //
    for (long j = 0; j < dimension_a; j++) {
      accum_frame_buff_d(i)(j).makeVectorFloat().setLength(1);      
      accum_frame_buff_d(i)(j).getVectorFloat().assign((float)0);            
    }    
  }

  // exit gracefully
  //
  is_valid_d = false;
  return true;
}
