2013-07-01から1ヶ月間の記事一覧
rubyでkeyの行の置き換え f=open("test1.txt"); a=Hash.new(); f.readlines.each{|i| i.chomp!; j=i.split(" ") a[j[0]+" "+j[1]]=i; # puts i; } f2=open("test2.txt"); f2.readlines.each{|i| i.chomp! j=i.split(" ") if a.has_key?(j[0]+" "+j[1]) then …
JNAを使ってc++のシャッフル関数と連携. c_shuff_test.scala import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.NativeLibrary; object c_shuff_test{ def main(args: Array[String]): Unit={ val lib=NativeLibrary.getInstance…
scalaからjnaでc++関数を使う。 少しはまった.ポイントは関数にextern "C" をつけること. C++では、関数のオーバーロード(多重定義)などが原因で 関数名で関数が特定できない(識別子がつくらしい)。そこで、C方式の関数名として宣言しておく. http://…
cpp_test.scala import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.NativeLibrary; object cpp_test{ def main(args: Array[String]): Unit={ var a=Array(1.0,2.0,3.0); println("Input"); a.foreach{println} val lib=NativeLib…
scalaからcの関数をよび内積を計算loop.c #include<stdio.h> #include<stdlib.h> #include<math.h> #include"loop.h" int loop2(double* v1, double* v2,int n){ double tmp=0; int i; for(i=0;i</math.h></stdlib.h></stdio.h>
はじめてC言語 .hファイルの意味を理解した! cのヘッダーファイルの意味 http://www.geocities.jp/ky_webid/ProgrammingPlacePlus/c/023.html ポイントは, 各ファイルで関数宣言をしないと関数を使用できない →これが.hファイル実態は,.cファイルで定義す…
まず、普通にダウンロードすると wget https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/3.5.2/jna-3.5.2.jar エラー: `maven.java.net' の証明書は信用されません。 エラー: `maven.java.net' の証明書の発行者が不明です。とな…
(1)まず準備。 C言語のダイナミックリンクライブラリ(dll)を作る #include<stdio.h> void test_hello(char* v){ printf(v); } dll化する gcc -c test_hello.c gcc -shared -o test_hello.dll test_hello.o 実行用プログラム void main(){ test_hello("This is test</stdio.h>…