RosettaCodeData/Task/Call-a-foreign-language-fun.../Stata/call-a-foreign-language-fun...

17 lines
486 B
Plaintext

import com.stata.sfi.*;
public class HilbertMatrix {
public static int run(String[] args) {
int n, i, j;
n = Integer.parseInt(args[1]);
Matrix.createMatrix(args[0], n, n, 0.0);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
// Unlike Stata and the C API, indices are 0-based in the Java API.
Matrix.storeMatrixAt(args[0], i, j, 1.0/(double)(i+j+1));
}
}
return 0;
}
}