September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,14 @@
#include <stdlib.h>
#include "stplugin.h"
STDLL stata_call(int argc, char *argv[]) {
int i, j, n = strtol(argv[1], NULL, 0);
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
// Don't forget array indices are 1-based in Stata.
SF_mat_store(argv[0], i, j, 1.0/(double)(i+j-1));
}
}
return 0;
}

View file

@ -0,0 +1,6 @@
program hilbert
matrix define `1'=J(`2',`2',0)
plugin call hilbertmat, `1' `2'
end
program hilbertmat, plugin

View file

@ -0,0 +1,10 @@
. hilbert mymat 4
. matrix list mymat
symmetric mymat[4,4]
c1 c2 c3 c4
r1 1
r2 .5 .33333333
r3 .33333333 .25 .2
r4 .25 .2 .16666667 .14285714

View file

@ -0,0 +1,16 @@
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;
}
}

View file

@ -0,0 +1,10 @@
. javacall HilbertMatrix run, classpath(K:\java) args(mymat 4)
. matrix list mymat
symmetric mymat[4,4]
c1 c2 c3 c4
r1 1
r2 .5 .33333333
r3 .33333333 .25 .2
r4 .25 .2 .16666667 .14285714

View file

@ -0,0 +1,9 @@
. mata: Hilbert(4)
[symmetric]
1 2 3 4
+---------------------------------------------------------+
1 | 1 |
2 | .5 .3333333333 |
3 | .3333333333 .25 .2 |
4 | .25 .2 .1666666667 .1428571429 |
+---------------------------------------------------------+