覚え書き
デフォルトのgccであることを最初に確認しておく。
また、python24に依存したportsを全てアンインストールするときは
特定のパッケージを無視するときは
参考サイト
[追記]2017/02/25
OSをmacOS Sierra v10.12にアップグレードしたあとこのサイトの項目「Migration procedure」の1と2だけを実行した。macports.confは触っていない。
2012年12月24日月曜日
2012年12月1日土曜日
std::listとstd::vectorのベンチマーク
isocppのサイトにstd::listとstd::vectorのベンチマークの記事が紹介されていました。
http://www.baptiste-wicht.com/2012/11/cpp-benchmark-vector-vs-list/
作者は実際に測定を行い、こう結論しています。
http://www.baptiste-wicht.com/2012/11/cpp-benchmark-vector-vs-list/
作者は実際に測定を行い、こう結論しています。
- std::vector is insanely faster than std::list to find an element
- std::vector performs always faster than std::list with very small data
- std::vector is always faster to push elements at the back than std::list
- std::list handles very well large elements, especially for sorting or inserting in the front
- Number crunching: use std::vector
- Linear search: use std::vector
- Random Insert/Remove: use std::list (if data size very small (< 64B on my computer), use std::vector)
- Big data size: use std::list (not if intended for searching)
C++11を使ってOpenCV-2.4.3をコンパイルする。
CentOS5.8上でC++11(gcc-4.7.2)を使ってOpenCV-2.4.3をコンパイルしました。以下覚え書きとして記します。
.bashrcには以下の記述が既にあります。 すなわち、gcc-4.7.2へのパスをシステムは認識しています。
今いる場所はここ。 以下を実行。
.bashrcには以下の記述が既にあります。 すなわち、gcc-4.7.2へのパスをシステムは認識しています。
今いる場所はここ。 以下を実行。
C++11を使ってBoost-1.52.0をコンパイルする。
CentOS5.8上でC++11(gcc-4.7.2)を使ってBoost-1.52.0をコンパイルしました。以下覚え書きとして記します。
.bashrcには以下の記述が既にあります。 すなわち、gcc-4.7.2へのパスをシステムは認識しています。そして、今いる場所はここ。 ここに従ってboost.buildをインストールします。 PATHに/usr/local/boost.build/binを追加します。そして、以下を実行します。 しばらくすると、「pyconfig.hがない」と出ました。なのでこれを実行します。 あらためて 今度は「zlib.hがない」「bzlib.hがない」と出ました。これらをインストールします。 あらためて 出来ました。stageディレクトリの下にライブラリができています。これをcpコマンドを使って「手動で」目的の場所にコピーしました。
最初は手動ではなく、このコマンドを使ってインストール(コピー)を行いました。 このコマンドを実行すると、コピーだけでなくコンパイルも始めます。それもデフォルトのgcc(4.1.2)を使って。 コンパイルは終わってるはずです。よくわかりません。なので、上記のように「手動インストール」しました。
.bashrcには以下の記述が既にあります。 すなわち、gcc-4.7.2へのパスをシステムは認識しています。そして、今いる場所はここ。 ここに従ってboost.buildをインストールします。 PATHに/usr/local/boost.build/binを追加します。そして、以下を実行します。 しばらくすると、「pyconfig.hがない」と出ました。なのでこれを実行します。 あらためて 今度は「zlib.hがない」「bzlib.hがない」と出ました。これらをインストールします。 あらためて 出来ました。stageディレクトリの下にライブラリができています。これをcpコマンドを使って「手動で」目的の場所にコピーしました。
最初は手動ではなく、このコマンドを使ってインストール(コピー)を行いました。 このコマンドを実行すると、コピーだけでなくコンパイルも始めます。それもデフォルトのgcc(4.1.2)を使って。 コンパイルは終わってるはずです。よくわかりません。なので、上記のように「手動インストール」しました。
2012年11月29日木曜日
CentOS5.8にgcc-4.7.2をインストールする。
CentOS5.8上でgcc-4.7.2をコンパイルしました。
こちらのサイトを参考にしています。以下覚え書きとして記します。
前準備として、以下のパッケージをupdateします。gccだけでなく、gcc-c++も必要です。
最初に、gmpをコンパイルします。 次に、mpfrをコンパイルします。 さらに、mpcをコンパイルします。 これでgccをコンパイルする準備が整いました。 make中にこんなエラーが発生しました。 LD_LIBRARY_PATHに/usr/local/gcc-4.7.2/lib(mpc,gmp,mpfrのライブラリがあるディレクトリ)を追加すれば良いです。 あらためて しばらくすると、また、エラーが発生しました(内容は...記録し忘れました)。 対処方法はこれです。 32ビット版のglibcのヘッダが必要です。configureの時に明示的に64ビットに限定しないと32ビットもコンパイルされるのですね。知りませんでした。 再度 できました。64ビット版のgccは--prefixで指定したディレクトリ、今の場合、/usr/local/gcc-4.7.2/lib64の下にあります。
前準備として、以下のパッケージをupdateします。gccだけでなく、gcc-c++も必要です。
- gcc
- gcc-c++
- binutils
- bzip2
- gzip
- m4
- make
- unzip
- zip
最初に、gmpをコンパイルします。 次に、mpfrをコンパイルします。 さらに、mpcをコンパイルします。 これでgccをコンパイルする準備が整いました。 make中にこんなエラーが発生しました。 LD_LIBRARY_PATHに/usr/local/gcc-4.7.2/lib(mpc,gmp,mpfrのライブラリがあるディレクトリ)を追加すれば良いです。 あらためて しばらくすると、また、エラーが発生しました(内容は...記録し忘れました)。 対処方法はこれです。 32ビット版のglibcのヘッダが必要です。configureの時に明示的に64ビットに限定しないと32ビットもコンパイルされるのですね。知りませんでした。 再度 できました。64ビット版のgccは--prefixで指定したディレクトリ、今の場合、/usr/local/gcc-4.7.2/lib64の下にあります。
2012年11月25日日曜日
Level Set Method
Introduction
Several years ago I implemented a command line application of the Level Set Method. In this page, I would like to introduce it.Demo
I start with showing three demonstrations:demo-1
Verification Environment(Mac)
- Mac OS X 10.8.2
- Processor:3.06 GHz Intel Core 2 Duo
- Memory:4GB
- Xcode4.5.2 with Apple LLVM 4.1(C++ Language Dialect → C++11, C++ Standard Library → libc++)
- boost-1.51.0 compiled by the above compiler (See also here)
Verification Environment(Windows)
- Windows XP Professional Version 2002 Service Pack 3
- Processor:Pentium(R) D CPU 3.20GHz
- Memory:3GB
- Visual Studio 2005
- boost-1.51.0 (binaries for the VS2005)
Source Code
Here is my source code. I verified it on the above two machines.Usage
An execution file name isLevelSetMethod. In the case of Windows, it's named LevelSetMethod.exe. Running it without any arguments, it writes the following usage statements on the standard output:
The Level Set Method is carried out by using some of these parameters. The procedure is as follows:
- see the size of an input image.
- set an initial closed curve.
- run the Level Set Method.
①Size of Image
In order to give the application an initial closed curve, we have to know the size of an input image. To do so, the following command is used. The output indicates the size of the input image(./input/sample3.jpg).
②Setting Initial Closed Curve
We can draw an circle with a center
(X, Y) and a radius R by the following command.
In this command, -C indicates color of the circle, whose range is [0,255]. The circle is drawn on the input image. It is saved in the directory(./output) with the name "initial_loop.jpg" (see the below image).
The circle corresponds to the initial closed curve. We can put it either outside an object or inside one. If it is placed outside the object, the Level Set Method shrinks it. On the other hand, if it is placed inside the object, the Level Set Method expands it. We have to decide appropriate values (X, Y, R) through a trial and error process.
③Running Level Set Method
We have to make a setting file in which six parameters are described. The file name is arbitrary. In this page, we name it "params" to make the explanation easy. The sample of "params" is as follows: The meanings of the parameters are
time_step: time steptime_step_number: iteration of time evolutionspace_step: space step. the same value for both x-axis and y-axisconstant_speed: a constant part of a speed function as we will discuss laterepsilon: a value of ε which appears in the definition of a speed functionsigma: a degree of the Gaussian blur
where,
The parameter
epsilon indicates
constant_speed corresponds to
-F, we type the path to "params." During execution, the progress bar is displayed. Under the above parameters, the time evolution is repeated up to 400 steps, and one image is saved per 10, which is a value after -T, time steps. The output directory is ./output and the file name is front_xxx.jpg, where xxx represents integer. The calculation time is displayed in the last line of the standard output. In the current parameters, 40 images are saved. I converted these images into a movie by use of ffmpeg to show the demonstration at the beginning of this page.P.S. See also this page. 2013/01/25
Compilation of Boost by clang with C++11
My procedure is as follows:
When using it on the Xcode, we need to add a variable
DYLD_LIBRARY to "Product→Edit Scheme→Arguments→Environment Variables" and set the path to dylib to the variable.
登録:
投稿 (Atom)
