Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) HelloBoostUblasQtCreatorLubuntu

 

BoostQt CreatorLubuntu

 

Hello Boost.uBLAS using Qt Creator under Lubuntu is a Hello Boost.uBLAS program.

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppHelloBoostUblasQtCreatorLubuntu/CppHelloBoostUblasQtCreatorLubuntu.pro

 

include(../../ConsoleApplication.pri) #Or use the code below
# QT += core
# QT += gui
# greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
# CONFIG   += console
# CONFIG   -= app_bundle
# TEMPLATE = app
# CONFIG(release, debug|release) {
#   DEFINES += NDEBUG NTRACE_BILDERBIKKEL
# }
# QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra -Weffc++
# unix {
#   QMAKE_CXXFLAGS += -Werror
# }

include(../../Libraries/Boost.pri) #Or use the code below
# win32 {
#   INCLUDEPATH += \
#     ../../Libraries/boost_1_54_0
# }

SOURCES += main.cpp

 

 

 

 

 

./CppHelloBoostUblasQtCreatorLubuntu/main.cpp

 

#include <iostream>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#pragma GCC diagnostic pop

int main()
{
  const int n_cols = 2;
  const int n_rows = 3;
  {
    boost::numeric::ublas::matrix<int> m(n_rows,n_cols);
    assert(n_rows == static_cast<int>(m.size1()));
    assert(n_cols == static_cast<int>(m.size2()));
    for (int y = 0; y != n_rows; ++y)
    {
      for (int x = 0; x != n_cols; ++x)
      {
        m(y,x) = (y * 10) + x;
      }
    }
    std::cout << m << std::endl;
    assert(m(0,0) ==  0); assert(m(0,1) ==  1);
    assert(m(1,0) == 10); assert(m(1,1) == 11);
    assert(m(2,0) == 20); assert(m(2,1) == 21);
  }
  {
    boost::numeric::ublas::matrix<int,boost::numeric::ublas::column_major> m(n_cols,n_rows);
    assert(n_cols == static_cast<int>(m.size1()));
    assert(n_rows == static_cast<int>(m.size2()));
    for (int x = 0; x != n_cols; ++x)
    {
      for (int y = 0; y != n_rows; ++y)
      {
        m(x,y) = (y * 10) + x;
      }
    }
    std::cout << m << std::endl;
    assert(m(0,0) ==  0); assert(m(1,0) ==  1);
    assert(m(0,1) == 10); assert(m(1,1) == 11);
    assert(m(0,2) == 20); assert(m(1,2) == 21);
  }
}

/*

[3,2]((0,1),(10,11),(20,21))
[2,3]((0,10,20),(1,11,21))

*/

 

 

 

 

 

./CppHelloBoostUblasQtCreatorLubuntu/CppHelloBoostUblasQtCreatorLubuntu.sh

 

#!/bin/bash
myfile="qmake"
mytarget="CppHelloBoostUblasQtCreatorLubuntu"
myprofile=$mytarget.pro

if [ ! -e $myprofile ]
then
  echo "Qt Creator project '$myprofile' not found"
  exit
fi

$myfile $myprofile

if [ ! -e Makefile ]
then
  echo "FAIL: $myfile $myprofile"
  exit
fi

make

if [ -e $mytarget ]
then
  echo $mytarget": SUCCESS"
else
  echo $mytarget": FAIL"
fi

#Cleaning up
rm *.o
rm Makefile
rm $mytarget

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml