Esempio n. 1
0
main(){
    char s[400];
    printf("Enter the string:");
    gets(s);
    camelCase(s);
    printf("String in camel case is:");
    puts(s);
}
Esempio n. 2
0
    void IFRSEarlyWarning::getChangeInRatings(std::vector<string> &headings, 
                                                       std::vector<string> &sectorNames,
                                                       std::vector<std::vector<double>> &data)
    {        
        std::vector<string> uniqueSectors = IFRSEarlyWarning::getSectors(); 
        std::vector<int> sectorComposition = std::vector<int>(uniqueSectors.size(), 0); 

        headings = std::vector<string>();
        sectorNames = std::vector<string>();

        headings.push_back("Num Shares");
        headings.push_back("Base PD");
        headings.push_back("Current PD");
        headings.push_back("Relative Change in PD");
        headings.push_back("Notch Change");
        
        //std::vector<pair<string, double>> pdChange = std::vector<pair<string, double>>();
        data = std::vector<std::vector<double>>();
        std::vector<double> basePDxWeight = std::vector<double>(uniqueSectors.size(), 0);
        std::vector<double> currentPDxWeight = std::vector<double>(uniqueSectors.size(), 0);
        std::vector<double> weight = std::vector<double>(uniqueSectors.size(), 0);
        std::vector<double> changeInPD = std::vector<double>(uniqueSectors.size(), 0);
        for (size_t i = 0; i < uniqueSectors.size(); ++i)
        {
            for (size_t j = 0; j < sectors.size(); ++ j)
            {
                if (uniqueSectors[i].compare(sectors[j])==0)
                {
                    basePDxWeight[i] += weightings[j] * basePD[j];
                    currentPDxWeight[i] += weightings[j] * currentPD[j];
                    weight[i] += weightings[j];
                    sectorComposition[i] += 1;
                }                         
            }
        }
        for (size_t i = 0; i < uniqueSectors.size(); ++i)
        {
            if (weight[i] <= 1e-14)
            {
                changeInPD[i] = 0;
            }
            else 
            {
                changeInPD[i] = (currentPDxWeight[i] / basePDxWeight[i]);
            }

            string s = uniqueSectors[i];
            camelCase(s);
            sectorNames.push_back(s);
            std::vector<double> dataRow = std::vector<double>();
            dataRow.push_back(sectorComposition[i]);
            dataRow.push_back(basePDxWeight[i] / weight[i]);
            dataRow.push_back(currentPDxWeight[i] / weight[i]);
            dataRow.push_back(changeInPD[i]);
            double ratingsChange = log(changeInPD[i]) / log(2.0); // log base 2
            ratingsChange *= -2; // 2 notches = double or half PD
            dataRow.push_back(ratingsChange);
            data.push_back(dataRow);
        }
        return;
    }