Top Tutorial 2

Tutorial 1: Demonstrating vector arithmetics

In this trivial example, we define two 2-D vectors of different type (integer and floating point), perform an addition and print the results.
    #include <sl/vector.h>
    #include <iostream>
    int main() { 
        sl::vector< int > iv = {1, 2};
        sl::vector< double > dv = {1.2, 3.2};
        sl::vector< double > resv = iv + dv;
        std::cout << resv << std::endl;
        return 0;
    }
This code is from the file 'vector-arithmetics.cpp' in the mcmll/examples directory. Switch to the mcmll/examples directory and compile all examples by the command 'scons', or alternatively, compile it with:
  g++ vector-arithmetics.cpp  -I path-to-mcmll/lib -std=c++0x -D__SL_USE_CXX0X__ -o vector-arithmetics
where path-to-mcmll is the installation path of the MCMLL library (for example: /home/me/cpp/mcmll). Run example with:
  ./vector-arithmetics
The result should look like:
  (2.2, 5.2)

Explanation of the code