Displaying 1 result from an estimated 1 matches for "quad_form_sp".
2009 Jan 06
1
C dll compilation + S Poetry example
...e code is basically the calculation of the
quadratic form x'Qx:
static double quad_form(double *Q, double *x, long n)
{
long i, j, ij;
double ans = 0.0;
for(i=0; i < n; i++) {
for(j=0, ij = i * n; j < n; j++, ij++) {
ans = ans + x[i] * Q[ij] * x[j];
}
}
return(ans);
}
void quad_form_Sp(double *Q, double *x, long *xdim, double *ans)
{
long i, ii, n;
double quad_form(double*, double*, long);
n = xdim[0];
for(i=0, ii=0; i < xdim[1]; i++, ii += n) {
ans[i] = quad_form(Q, x + ii, n);
}
}
The dll was compiled (in Win XP, R-2.8.1) using the command: rcmd
SHLIB qform.c. Then...