とらりもんHOME  Index  Search  Changes  Login

boost

パッケージからインストール

sudo apt-get install libboost-all-dev

ソースからインストール

  • boost_1_55_0.tar.bz2などをダウンロードし, 展開し, ディレクトリ内に入る。
$ ./bootstrap.sh
↑ すぐ終わる。
$ ./b2 -j8
↑ 数分かかる。
$ sudo ./b2 install -j8 --prefix=/usr/local

動作確認

#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

using namespace boost::numeric::ublas;

/* "y = Ax" example */
int main () 
{
 vector<double> x (2);
 x(0) = 1; x(1) = 2;

 matrix<double> A(2,2);
 A(0,0) = 0; A(0,1) = 1;
 A(1,0) = 2; A(1,1) = 3;

 vector<double> y = prod(A, x);

 std::cout << y << std::endl;
 return 0;
}
  • そしてコンパイルして実行 (オプションは不要):
$ g++ test.cpp
$ ./a.out
[2](2,8)
Last modified:2014/11/05 13:12:33
Keyword(s):
References:[とらりもんHOME]