FACT++  1.0
template<typename T >
void displayStats ( vector< char > &  array,
ostream &  out 
)

Definition at line 806 of file fitsdump.cc.

References FitsDumper::DumpStats(), and i.

807 {
808  const size_t numElems = array.size()/sizeof(T);
809  if (numElems == 0)
810  {
811  out << "Min: -\nMax: -\nMed: -\nAvg: -\nRms: -" << endl;
812  return;
813  }
814 
815  T *val = reinterpret_cast<T*>(array.data());
816 
817  sort(val, val+numElems);
818 
819  out << "Min: " << double(val[0]) << '\n';
820  out << "Max: " << double(val[numElems-1]) << '\n';
821 
822  if (numElems%2 == 0)
823  out << "Med: " << (double(val[numElems/2-1]) + double(val[numElems/2]))/2 << '\n';
824  else
825  out << "Med: " << double(val[numElems/2]) << '\n';
826 
827  long double avg = 0;
828  long double rms = 0;
829  for (uint32_t i=0;i<numElems;i++)
830  {
831  const long double v = val[i];
832  avg += v;
833  rms += v*v;
834  }
835 
836  avg /= numElems;
837  rms /= numElems;
838  rms -= avg*avg;
839  rms = rms<0 ? 0 : sqrt(rms);
840 
841 
842  out << "Avg: " << avg << '\n';
843  out << "Rms: " << rms << endl;
844 }
int i
Definition: db_dim_client.c:21

+ Here is the call graph for this function: