c++

C++で自然スプライン補完

c++

C++で自然スプライン補完 #include<stdio.h> #include<gsl/gsl_linalg.h> void f(double* x,int size,double* x_knots,int knots_size,double* a,double* b,double* c,double* d,double* output){ //x should be sorted; int j=0; double r3; double r2; double r1; double r0; int k=0;</gsl/gsl_linalg.h></stdio.h>…

gslで線形方程式、連立一次方程式をとく。

c c++

gslで線形方程式、連立一次方程式をとく。 #include<stdio.h> #include<gsl/gsl_linalg.h> void solve(double** m,double* v,int len){ using namespace std; int s; double *mb; int k=0; mb=(double*)malloc(sizeof(double)*len*len); for(int i=0;i</gsl/gsl_linalg.h></stdio.h>

setの使い方 要素の削除

c++

setの使い方 #include<stdio.h> #include<stdlib.h> #include<iostream> #include<set> #include<map> #include<vector> #include<algorithm> #include<math.h> int main(){ using namespace std; std::set<int> nodelist; int i; int nodeno=10; for(i=0;i</int></math.h></algorithm></vector></map></set></iostream></stdlib.h></stdio.h>

scalaからc++関数を使う

scalaからjnaでc++関数を使う。 少しはまった.ポイントは関数にextern "C" をつけること. C++では、関数のオーバーロード(多重定義)などが原因で 関数名で関数が特定できない(識別子がつくらしい)。そこで、C方式の関数名として宣言しておく. http://…

C++からRの関数を呼び出す. cygwin,gcc,g++版

R c++

C++からRの関数を呼び出す. cygwin,gcc,g++版: 時間計測: これ http://d.hatena.ne.jp/teramonagi/20101213/1292253192 を参考にtest.cpp #include <windows.h> #include <iostream> //doubleの引数一個取ってdoubleの値返す関数ポインタをRFuncと定義 typedef double(*RFunc)(</iostream></windows.h>…

ファイル出力 c++

c++

ベクトルのファイル。 http://www.cplusplus.com/forum/beginner/25121/使うときは\*ifでflush は cout

ブーストで文字列をカンマで分割

http://www.kab-studio.biz/Programing/Codian/STL/02.html ブーストで文字列をカンマで分割 #include <iostream> #include <vector> #include <boost/algorithm/string.hpp> using namespace std; int main(){ string str="abc,efg,hij"; vector<string> v; boost::algorithm::split(v,str,boost::is_any_of(","));</string></boost/algorithm/string.hpp></vector></iostream>…

C++でユニコード文字列を扱う。 (この方法じゃぁだめだそうです)

wstringというクラスを使う。 代入の時にはL"xxx"とする。 cygwin ではwstringだとコンパイルできないので std::basic_stringとする.http://www.geocities.co.jp/bleis_tift/cpp/string.html http://others2.blog.so-net.ne.jp/2010-09-24 http://wisdom.sa…

boostで対数正規分布乱数の発生。

boostで対数正規分布乱数の発生。 g++ test.cpp -L/usr/include/boost/random test.cpp #include<boost/random.hpp> #include<stdio.h> #include<stdlib.h> #include<iostream> int main(){ using namespace std; using namespace boost; mt19937 gen(1); lognormal_distribution<> dst(1,1); //normal_distr</iostream></stdlib.h></stdio.h></boost/random.hpp>…

c++のグラフ理論系(ネットワーク系)ライブラリ

c++

ブーストグラフ。バイナリサーチができる。 Boost.Graph