- Timestamp:
- 12/15/11 14:33:53 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fitsdump.cc
r12725 r12726 535 535 536 536 template<typename T> 537 void displayStats(char* array, int numElems) 538 { 537 void displayStats(char* array, int numElems, ofstream& out) 538 { 539 if (numElems == 0) 540 { 541 out << "Min: 0" << endl; 542 out << "Max: 0" << endl; 543 out << "Med: 0" << endl; 544 out << "Mea: 0" << endl; 545 return; 546 } 539 547 sort(reinterpret_cast<T*>(array), &reinterpret_cast<T*>(array)[numElems]); 540 cout << "Min: " << reinterpret_cast<T*>(array)[0] << endl;541 cout << "Max: " << reinterpret_cast<T*>(array)[numElems-1] << endl;548 out << "Min: " << reinterpret_cast<T*>(array)[0] << endl; 549 out << "Max: " << reinterpret_cast<T*>(array)[numElems-1] << endl; 542 550 if (numElems%2 == 0) 543 cout << "Med: " << (reinterpret_cast<T*>(array)[numElems/2] + reinterpret_cast<T*>(array)[numElems/2+1])/2.f << endl;551 out << "Med: " << (reinterpret_cast<T*>(array)[numElems/2] + reinterpret_cast<T*>(array)[numElems/2+1])/2.f << endl; 544 552 else 545 cout << "Med: " << reinterpret_cast<T*>(array)[numElems/2+1] << endl;553 out << "Med: " << reinterpret_cast<T*>(array)[numElems/2+1] << endl; 546 554 547 555 double average = 0; 548 556 for (int i=0;i<numElems;i++) 549 557 average += reinterpret_cast<T*>(array)[i]; 550 cout << "Mea: " << average/(double)numElems << endl;558 out << "Mea: " << average/(double)numElems << endl; 551 559 552 560 } … … 633 641 auto statsIt = statData.begin(); 634 642 635 auto nameIt = list NamesOnly.begin();643 auto nameIt = list.begin(); 636 644 for (auto it=columnsData.begin(); it != columnsData.end(); it++, rangesIt++, statsIt++, nameIt++) 637 645 { 638 646 int span = rangesIt->second - rangesIt->first; 639 cout << *nameIt << ": " << endl;647 out << *nameIt << ": " << endl; 640 648 switch (it->first) { 641 649 case 'L': 642 displayStats<bool>(*statsIt, numRows*span );650 displayStats<bool>(*statsIt, numRows*span, out); 643 651 break; 644 652 case 'B': 645 displayStats<char>(*statsIt, numRows*span );653 displayStats<char>(*statsIt, numRows*span, out); 646 654 break; 647 655 case 'I': 648 displayStats<int16_t>(*statsIt, numRows*span );656 displayStats<int16_t>(*statsIt, numRows*span, out); 649 657 break; 650 658 case 'J': 651 displayStats<int32_t>(*statsIt, numRows*span );659 displayStats<int32_t>(*statsIt, numRows*span, out); 652 660 break; 653 661 case 'K': 654 displayStats<int64_t>(*statsIt, numRows*span );662 displayStats<int64_t>(*statsIt, numRows*span, out); 655 663 break; 656 664 case 'E': 657 displayStats<float>(*statsIt, numRows*span );665 displayStats<float>(*statsIt, numRows*span, out); 658 666 break; 659 667 case 'D': 660 displayStats<double>(*statsIt, numRows*span );668 displayStats<double>(*statsIt, numRows*span, out); 661 669 break; 662 670 default:
Note:
See TracChangeset
for help on using the changeset viewer.