Sunday, March 24, 2013

C++ string tokenizer

The advanced tokenizer:

void Tokenize(const string& str,
                      vector& tokens,
                      const string& delimiters = " ")
{
    // Skip delimiters at beginning.
    string::size_type lastPos = str.find_first_not_of(delimiters, 0);
    // Find first "non-delimiter".
    string::size_type pos     = str.find_first_of(delimiters, lastPos);

    while (string::npos != pos || string::npos != lastPos)
    {
        // Found a token, add it to the vector.
        tokens.push_back(str.substr(lastPos, pos - lastPos));
        // Skip delimiters.  Note the "not_of"
        lastPos = str.find_first_not_of(delimiters, pos);
        // Find next "non-delimiter"
        pos = str.find_first_of(delimiters, lastPos);
    }
}

Source: http://oopweb.com/CPP/Documents/CPPHOWTO/Volume/C++Programming-HOWTO-7.html

C++ string to double and vice versa

The C++ 11 way is to use std::stod and std::to_string. Both work in Visual Studio 11.


The STL offers the desired functionality:
std::string  s  = "0.6"
std::wstring ws = "0.7"
double d  = std::stod(s);
double dw = std::stod(ws);


http://stackoverflow.com/questions/1012571/stdstring-to-float-or-double

Monday, March 4, 2013

Latex packages: 9 essential

http://www.howtotex.com/packages/9-essential-latex-packages-everyone-should-use/

Monday, July 23, 2012

Wednesday, February 8, 2012

Perl

Download perl from ActivePerl website and install it. It will automatically set the path and environment variable.

Perl is useful as it process one line from the file at a time. Each line is stored in $_ variable.

Saturday, February 4, 2012

Combinatorial Optimization

Combinatorial Optimization
http://en.wikipedia.org/wiki/Combinatorial_optimization

My research

Research Interests:
·         Combinatorial Machine Learning,
·         Decision tree, test & rules,
·         Many Valued Decisions,
·         Artificial Intelligence,
·         Artificial Neural Network (ANN)