evoalgs-r-practise/w1/mat.c

12 lines
284 B
C
Raw Permalink Normal View History

2024-05-06 06:54:48 +00:00
#include <R.h>
#include <Rinternals.h>
void c_sum_matrix(double *matrix, int *nrow, int *ncol, double *result) {
int i, j;
*result = 0.0;
for (i = 0; i < *nrow; i++) {
for (j = 0; j < *ncol; j++) {
*result += matrix[i * (*ncol) + j];
}
}
}