CPP/Boost/Numeric/Matrix

From ProgrammingExamples

< CPP
Jump to: navigation, search

Matrix.cpp

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
 
int main () 
{
  using namespace boost::numeric::ublas;
  matrix<double> m (3, 3);
 
  for (unsigned i = 0; i < m.size1 (); ++ i)
  {
    for (unsigned j = 0; j < m.size2 (); ++ j)
    {
      m (i, j) = 3 * i + j;
    }
  }
 
  std::cout << m << std::endl;
 
  return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
 
Project(Matrix)
ADD_EXECUTABLE(Matrix Matrix.cpp)
Personal tools