c++ - Java program to mulitiply matrices by calling C code -
so i'm interested in concept. have lot of experience programming in c , fortran, little no java experience. feasible able call c code (even c++) multiply matrices within java code?
my idea, in concept, this
public class matrixmultiplication { public static void main(string[] args) { // parameters int matrix_size_m = 5000; int matrix_size_n = 5000; // allocate matrices multiplication double matrixa[][] = new double[matrix_size_m][matrix_size_n]; double matrixb[][] = new double[matrix_size_n][matrix_size_m]; double matrixc[][] = new double[matrix_size_m][matrix_size_n]; // initialize matrices ... // call c code here multiply c=a*b ... // other stuff a, b, , c ... } } if can accomplished, next step call mkl linear algebra computations, pretty cool.
thoughts?
is feasible call
ccode multiply matrices out
can it? yes can. don't understand why you'd need to. multiply matrices out in java.
int alength = a[0].length; // column length int browlength = b.length; // b row length int newrowl = a.length; // m result rows length int newcoll = b[0].length; // m result columns length double[][] matrixc = new double[newrowl][newcoll]; if(alength == browlength) { for( int = 0; < newroll; i++) for(int j = 0; j < newcoll; j++) for(int k = 0; k < alength; k++) matrixc[i][j] += a[i][k] * b[k][j]; } return matrixc
Comments
Post a Comment