Changeset 361 for cpp


Ignore:
Timestamp:
04/18/15 17:31:31 (10 years ago)
Author:
Maciej Komosinski
Message:

Signed/unsigned int issues (r352) resolved differently - in most cases no (int)size() cast

Location:
cpp/frams
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/_demos/simil_test.cpp

    r359 r361  
    3636    ...
    3737    <row_n>
    38 
    39     Last modified: 2015-04-16
    4038 */
    4139int main(int argc, char *argv[])
     
    160158    // create the empty array of similarities
    161159    aaSimil = new pDouble [pvGenos->size()];
    162     for (int k = 0; k < (int) pvGenos->size(); k++)
     160    for (unsigned int k = 0; k < pvGenos->size(); k++)
    163161    {
    164162        aaSimil[k] = new double [pvGenos->size()];
    165         for (int l = 0; l < (int) pvGenos->size(); l++)
     163                for (unsigned int l = 0; l < pvGenos->size(); l++)
    166164            aaSimil[k][l] = 0.0;
    167165    }
    168166
    169167    // compute and remember similarities
    170     int i, j;
    171     for (i = 0; i < (int) pvGenos->size(); i++)
    172     {
    173         for (j = 0; j < (int) pvGenos->size(); j++)
     168        for (unsigned int i = 0; i < pvGenos->size(); i++)
     169    {
     170                for (unsigned int j = 0; j < pvGenos->size(); j++)
    174171        {
    175172            dSimilarity = M.EvaluateDistance(pvGenos->operator[](i), pvGenos->operator[](j));
     
    183180        // print the number of genotypes and their names
    184181        printf("%li\n", pvGenos->size());
    185         int iGen;
    186         for (iGen = 0; iGen < (int) pvNames->size(); iGen++)
     182                for (unsigned int iGen = 0; iGen < pvNames->size(); iGen++)
    187183        {
    188184            printf("%s\n", pvNames->at(iGen));
    189185        }
    190     } // if (bPrintNames)
     186    }
    191187
    192188    // print out the matrix of similarities
    193     for (i = 0; i < (int) pvGenos->size(); i++)
    194     {
    195         for (j = 0; j < (int) pvGenos->size(); j++)
     189        for (unsigned int i = 0; i < pvGenos->size(); i++)
     190    {
     191                for (unsigned int j = 0; j < pvGenos->size(); j++)
    196192        {
    197193            printf("%.2lf\t", aaSimil[i][j]);
     
    201197
    202198    // delete vectors and arrays
    203     for (i = 0; i < (int) pvGenos->size(); i++)
     199        for (unsigned int i = 0; i < pvGenos->size(); i++)
    204200    {
    205201        delete pvGenos->operator[](i);
  • cpp/frams/model/similarity/simil_match.cpp

    r357 r361  
    2626
    2727    // fill vectors with "unmatched" indicator
    28     int i;
    29     for (i = 0; i < (int) m_apvMatched[0]->size(); i++)
     28        for (unsigned int i = 0; i < m_apvMatched[0]->size(); i++)
    3029    {
    3130        m_apvMatched[0]->operator[](i) = -1;
    3231    }
    33     for (i = 0; i < (int) m_apvMatched[1]->size(); i++)
     32        for (unsigned int i = 0; i < m_apvMatched[1]->size(); i++)
    3433    {
    3534        m_apvMatched[1]->operator[](i) = -1;
     
    149148    // index of the smallest object
    150149    int nObj;
    151     // index of an element
    152     int nElem;
    153150
    154151    // find the smallest object (its index)
     
    163160
    164161    // check if all elements of the smallest object are matched
    165     for (nElem = 0; nElem < (int) m_apvMatched[ nObj ]->size(); nElem++)
     162        for (unsigned int nElem = 0; nElem < m_apvMatched[nObj]->size(); nElem++)
    166163    {
    167164        if (m_apvMatched[ nObj ]->operator[](nElem) < 0)
     
    184181    // result - assume that matching is empty
    185182    bool bResult = true;
    186     int nElem;
    187183
    188184    // matching is empty if either of objects has only unmatched elements
    189185    // so it may be first object
    190186    int nObj = 0;
    191     for (nElem = 0; nElem < (int) m_apvMatched[ nObj ]->size(); nElem++)
     187        for (unsigned int nElem = 0; nElem < m_apvMatched[nObj]->size(); nElem++)
    192188    {
    193189        if (m_apvMatched[ nObj ]->operator[](nElem) >= 0)
     
    207203void SimilMatching::Empty()
    208204{
    209     int iObj; // a counter of objects
    210     int iElem; // a counter of objects' elements
    211     for (iObj = 0; iObj < 2; iObj++)
     205    for (int iObj = 0; iObj < 2; iObj++) // a counter of objects
    212206    {
    213207        // for each object in the matching
    214         for (iElem = 0; iElem < (int) m_apvMatched[ iObj ]->size(); iElem++)
     208                for (unsigned int iElem = 0; iElem < m_apvMatched[iObj]->size(); iElem++) // a counter of objects' elements
    215209        {
    216210            // for each element iElem for the object iObj
     
    228222void SimilMatching::PrintMatching()
    229223{
    230     int i;
    231224    int nBigger;
    232225
     
    243236    // print first line - indices of objects
    244237    printf("[ ");
    245     for (i = 0; i < (int) m_apvMatched[ nBigger ]->size(); i++)
    246     {
    247         printf("%2i ", i);
     238        for (unsigned int i = 0; i < m_apvMatched[nBigger]->size(); i++)
     239    {
     240        printf("%2d ", i);
    248241    }
    249242    printf("]\n");
     
    254247        // for both objects - print out lines of matched elements
    255248        printf("[ ");
    256         for (i = 0; i < (int) m_apvMatched[ nObj ]->size(); i++)
     249                for (unsigned int i = 0; i < m_apvMatched[nObj]->size(); i++)
    257250        {
    258251            if (IsMatched(nObj, i))
    259252            {
    260253                // if the element is matched - print the index
    261                 printf("%2i ", GetMatchedIndex(nObj, i));
     254                printf("%2d ", GetMatchedIndex(nObj, i));
    262255            }
    263256            else
  • cpp/frams/model/similarity/simil_model.cpp

    r356 r361  
    734734                {
    735735                    GetNeighbIndexes(mod, partInd, nIndexes);
    736                     for (int k = 0; k < (int) nIndexes.size(); k++)
     736                                        for (unsigned int k = 0; k < nIndexes.size(); k++)
    737737                    {
    738738                        newDeg += m_fuzzyNeighb[mod][nIndexes.at(k)][depth - 1];
     
    17221722        // wartości orginalne transformacji dOrig uzyskuje się przez:
    17231723        // for ( iTrans = 0; iTrans <= TRANS_INDEX; iTrans++ ) dOrig *= dMul[ iTrans ];
     1724        //const char *szTransformNames[NO_OF_TRANSFORM] = { "ID", "S_yz", "S_xz", "S_xy", "R180_z", "R180_y", "R180_z", "S_(0,0,0)" };
    17241725        const int dMulX[ NO_OF_TRANSFORM ] = {1, -1, -1, 1, -1, 1, -1, -1};
    17251726        const int dMulY[ NO_OF_TRANSFORM ] = {1, 1, -1, -1, -1, -1, -1, 1};
    17261727        const int dMulZ[ NO_OF_TRANSFORM ] = {1, 1, 1, -1, -1, -1, 1, 1};
    17271728
    1728 #undef max
     1729#ifdef max
     1730 #undef max //this macro would conflict with line below
     1731#endif
    17291732        double dMinSimValue = std::numeric_limits<double>::max(); // minimum value of similarity
    17301733        int iMinSimTransform = -1; // index of the transformation with the minimum similarity
Note: See TracChangeset for help on using the changeset viewer.