ウィンドウズでアルマジロ

  • How to work Armadillo library on your Windows; a successful episode, no guarantee for your Windows setting.
  • 1成功例なので、うまくいくかの保障はありません
  • 事前準備 prep
    • g++が動くこと g++ should work fine.
  • Armadillo for windowsのダウンロード Download Armadillo DLsite
  • 解凍 unpack it
  • includeフォルダの中にヘッダーファイルがあるので、それを、「自分が決めたところ」に置くHeader files are in the folder "include" and copy all under the "include" to somewhere you decide.
  • その置き場、はg++ -I hogehogeとして、インクルードするべきヘッダファイルの参照パスを書くべき置き場 The folder you selected should be told to g++ command by "g++ -I hogehoge" as the site to look for the header files.
  • Windowsの場合、この-I hogehogeが
C:\Users\ryamada\Desktop\CppTest>g++ testmain0714_2.cpp -I "C:\Users\ryamada\include"
    • のように文字列指定になる
  • In case of windows, you may have to tell the include path as a string "C:\Users\ryamada\include"
  • 実際にg++コマンドで使う前に、armadilloをコンパイルしないといけない。".configure"というコマンドを発行するということ。Before using armadillo with g++ command, you have to compile the downloaded with the command "configure".
  • だけれどもこのconfigureがWindowsではうまくいかないので、CMakeをダウンロードして、やってもらう。Because this configure is not easy for windows, let's download CMake to do this.
  • CMakeのダウンロード先はこちら You can download CMake.
  • CMakeをインストールすると、それはグラフィカルインターフェース Cmake can be easily installed and it has Graphical Intreface.

  • Armadilloのダウンロードフォルダの中にconfigureという名前のファイルがあるので、そのファイルがある場所を"Where is the source code:"に入れる。Check where the file names "configure" is located under the downloaded Armadillo file set, and input the path to the "Where is the source code:"
  • "Where to build the binaries:" は出来上がるライブラリの置き場と思う。"Where to build the binaries:" tells the CMake where to place the library of Armadillo.
  • ここまで終わったら、次のようなarmadilloを使ったソースをコンパイルしてみる Now let's compile a cpp file with armadillo.
#include <iostream>
#include <armadillo>
 
using namespace std;
using namespace arma;
 
 
/* compile:
 * g++ example1.cpp -larmadillo
 */
 
int
main(int argc, char** argv)
  {
  cout << "Armadillo version: " << arma_version::as_string() << endl;
 
  int n = 8;
  mat M = zeros<mat>(n, n);  // directly specify the matrix size (elements are uninitialised)
  M.print("M:");
  int v = 0;
  for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
          M(i, j) = v;
          v++;
      }
  }
  M.print("M:");
  return 0;
  }
  
  • 結果 Result
C:\Users\ryamada\Desktop\CppTest>g++ testmain0714_2.cpp -I "C:\Users\ryamada\include"
  • これにより、a.exeという実行ファイルができるので、実行する。"a.exe" file should be generated. Run it.
C:\Users\ryamada\Desktop\CppTest>a
Armadillo version: 5.200.2 (Boston Tea Smuggler)
M:
        0        0        0        0        0        0        0        0
        0        0        0        0        0        0        0        0
        0        0        0        0        0        0        0        0
        0        0        0        0        0        0        0        0
        0        0        0        0        0        0        0        0
        0        0        0        0        0        0        0        0
        0        0        0        0        0        0        0        0
        0        0        0        0        0        0        0        0
M:
         0    1.0000    2.0000    3.0000    4.0000    5.0000    6.0000    7.0000

    8.0000    9.0000   10.0000   11.0000   12.0000   13.0000   14.0000   15.0000

   16.0000   17.0000   18.0000   19.0000   20.0000   21.0000   22.0000   23.0000
  • 注意。CLAPACKとかいわゆる線形代数ライブラリがうまく参照できるかどうか、とか、細かい設定については、全く未確認のママです。No care about relation with other libraries including CLAPACK and any troubles related to it may likely to happen.