Javaに挑戦
C++/CLIでDirectShowを扱う方法は情報が少なく現在挫折中。ていうかDIrectXSDK付属のmanaged用のマニュアルには一切記述なし。DirectShowはDirectXの内の一つじゃないのか?
というわけで唐突にJavaに挑戦。
とりあえずなんだからニュートン法で方程式を解くクラスを作ってみる。
まず慣れたC++で作るとこんな感じ。
#ifndef NEWTON_H_ #define NEWTON_H_ namespace MasaH { namespace Math { typedef double (*func1d)(double); class Newton { public: Newton(); ~Newton(); double throw_solve(double x0=10.0);//solve y=0 bool setf(func1d);//Set f(x) and unset df(x). bool setdf(func1d); bool seteps(double); bool seth(double); private: func1d f; //y=f(x) func1d df; //dy/dx=df(x) double edf(double);//dy/dx neary equal edf(x) bool exist_df;//set df? double eps;//epsilon. double h;//related to edf() }; } } #endif /*NEWTON_H_*/
これをJavaで書き直そうかと思ったのだけれど関数ポインタって多分使えないんだよね。となるとinterfaceで宣言するか、解くべき関数を含んだ別のクラスのインスタンスを引数として渡すしかないのか?どちらがスマートか考え中。