我正在嘗試使用CUSP作爲Mathematica的外部線性求解器來使用GPU的功能。 這是CUSP Project webpage。我在尋求一些建議,我們如何將CUSP與Mathematica集成在一起。我相信你們中的很多人會有興趣討論這個問題。我認爲編寫一個輸入矩陣,然後將它提供給CUSP程序是不可行的。使用Mathematica的LibrarayFunctionLoad
將是一種更好的方式來將輸入矩陣傳輸到基於GPU的求解器。直接從Mathematica提供矩陣和右側矩陣的方式是什麼?Mathematica的庫函數功能
這是一些CUSP代碼片段。
#include <cusp/hyb_matrix.h>
#include <cusp/io/matrix_market.h>
#include <cusp/krylov/cg.h>
int main(void)
{
// create an empty sparse matrix structure (HYB format)
cusp::hyb_matrix<int, float, cusp::device_memory> A;
// load a matrix stored in MatrixMarket format
cusp::io::read_matrix_market_file(A, "5pt_10x10.mtx");
// allocate storage for solution (x) and right hand side (b)
cusp::array1d<float, cusp::device_memory> x(A.num_rows, 0);
cusp::array1d<float, cusp::device_memory> b(A.num_rows, 1);
// solve the linear system A * x = b with the Conjugate Gradient method
cusp::krylov::cg(A, x, b);
return 0;
}
這個問題使我們有可能討論的Mathematica 8的編譯功能也可以調用MMA的MathLink的接口的話題。我希望這裏的人們發現這個問題值得而且有趣,足以思考。
BR
請注意,StackOverflow格式不適合討論。這不是一個論壇。儘量保持問答格式。 –
@belisarius我明白你的觀點。給我一些時間會構成一個具體問題。但問題是如何解決這個問題。感謝提醒.. – PlatoManiac