Git Product home page Git Product logo

entropy's Introduction

entropy's People

Contributors

ifgpuelse avatar merces avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

entropy's Issues

Large file support

Because I read the whole file at once, currently entropy does not support large files. I believe the solution would be reading the file in chunks. Here's what I tried:

vector<char> buff(1024, 0);
streamsize total = 0;

// Count occurrence of each possible byte, from zero to 255.
unsigned int counted_bytes[256] = { 0 };

while (!f.eof()) {
    f.read(buff.data(), buff.size());

    for (int j = 0; j < buff.size(); j++) {
        unsigned char c = buff[j];
        counted_bytes[c]++;
    }
    total += f.gcount();
}

f.close();

cout << calculate_entropy(counted_bytes, total) << " " << argv[i] << "\n";

However, the final entropy is not correctly calculated. Any ideas why?

Wrong entropy for multiple files at once

This is critical. If you try to calculate the entropy for more than one file, the first file entropy is correct, but the others are not. See:

./entropy /bin/ls
2.71 /bin/ls

./entropy /bin/pwd
1.12 /bin/pwd

./entropy /bin/ls /bin/pwd
2.71 /bin/ls
2.09 /bin/pwd

Compiling under Debian 10.11 (Buster)

do not forget -lstdc++fs in the one line compilation directive:

g++ -std=c++2a -o entropy entropy.cpp -lstdc++fs

Also, using std::setprecision requires:
#include // std::setprecision

Error message reports the wrong file in certain conditions

If you provide entropy with more than one path where at least one of them is not a regular file, entropy will correctly fail for this file, but it will report the wrong file in the error message:

./entropy /bin/ls /bin
2.71 /bin/ls
"/bin/ls" isn't a regular file, skipping.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.