2015-07-18から1日間の記事一覧

C++写経用メモ

少しC++がわかってきたので、写経をしてもよい頃かも知れない こちらに数値計算系のサイトがあって、おもしろそう Advanced RのRcppのセクションも助走によい→Rcppの準備の確認はこちらで

C++ -> Rcpp 写経その3『配列で大量のデータ処理』

http://www-cms.phys.s.u-tokyo.ac.jp/~naoki/CIPINTRO/CBEG/cbeg4.html:『配列で大量のデータ処理』 その6 intからdoubleへ変換 // sample06.cpp #include <stdio.h> main(void) { int score1, score2; double mean; printf("Input the score of No.1 = "); scanf("</stdio.h>…

C++ -> Rcpp 写経その2『ループで繰り返し計算』

『ループで繰り返し計算』 その4 ループで加算 // sample04.cpp #include <stdio.h> main(void) { int n; // 変数の宣言 int sum = 0; // 変数の宣言と初期化 // for ループ for( n=1 ; n<=10 ; n++ ){ sum += n; // 足し上げる } printf("The sum is %d\n", sum ); </stdio.h>…

C++ -> Rcpp 写経その1『簡単な計算』

『簡単な計算』 その1 文字列を表示・文字列を返す // sample01.cpp #include <stdio.h> main(void) { printf("Computer in Physics\n"); } // sample01R.cpp #include <stdio.h> #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] CharacterVector sample01() { //printf</rcpp.h></stdio.h></stdio.h>…

C++が使えてRcppパッケージがワークすることの確認

資料 C++が使えてRcppパッケージがワークすることの確認 library(Rcpp) cppFunction('int add(int x, int y, int z) { int sum = x + y + z; return sum; }') add add(3,4,5) c++コードになっている'int...'がコンパイルされて、pointer: 0x0000000005d81770…