Changeset 2698


Ignore:
Timestamp:
Feb 15, 2011, 9:31:28 PM (11 years ago)
Author:
Sven Rech
Message:

hopefully faster entropy calculation in NativeCryptography by using float instead of double (float is precise enough)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/Libs/NativeCryptography/NativeCryptography.cpp

    r2075 r2698  
    220220        }
    221221
    222         double *xlogx = 0;
     222        float *xlogx = 0;
    223223
    224224        void prepareEntropy(int size)
     
    226226                if (xlogx != 0)
    227227                        free(xlogx);
    228         xlogx = (double*)malloc((size + 1)*sizeof(double));
     228        xlogx = (float*)malloc((size + 1)*sizeof(float));
    229229        //precomputations for fast entropy calculation 
    230230        xlogx[0] = 0.0;
    231231        for (int i = 1; i <= size; i++)
    232                         xlogx[i] = -1.0 * i * Math::Log(i / (double)size) / Math::Log(2.0);
     232                        xlogx[i] = -1.0 * i * Math::Log(i / (float)size) / Math::Log(2.0);
    233233    }
    234234
     
    267267        }
    268268
    269         double entropy = 0;
     269        float entropy = 0;
    270270        //calculate probabilities and sum entropy
    271271        for (short i = 0; i < 256; i++)                 
Note: See TracChangeset for help on using the changeset viewer.