// -*- c++ -*- /*****************************************************************************/ // Copyright (c) Illumina 2008 // Author: Richard Shaw // // This software is covered by the "Illumina Genome Analyzer Software // License Agreement" and the "Illumina Source Code License Agreement", // and certain third party copyright/licenses, and any user of this // source file is bound by the terms therein (see accompanying files // Illumina_Genome_Analyzer_Software_License_Agreement.pdf and // Illumina_Source_Code_License_Agreement.pdf and third party // copyright/license notices). /*****************************************************************************/ #ifndef PROPORTION_CALC_H #define PROPORTION_CALC_H /*****************************************************************************/ template class Proportion_Calc { public: Proportion_Calc(T sum, bool as_percent=true) : my_sum(sum), my_multiplier(as_percent ? 100.0 : 1.0) { } ~Proportion_Calc() { } float operator()(const T val) const { return ((my_sum > 0) ? ((my_multiplier * val) / my_sum) : 0.0); } private: T my_sum; float my_multiplier; }; /*****************************************************************************/ #endif // ! PROPORTION_CALC_H /*****************************************************************************/