Last active
December 17, 2015 02:09
-
-
Save arjones6/5533811 to your computer and use it in GitHub Desktop.
Simple C functions taking arrays as arguments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void single_test(double *x, int n); | |
void array_math_test(double *x, int n, int m); | |
void multi_test(double **x, int n, int m); | |
void single_test(double *x, int n) | |
{ | |
int i; | |
for (i = 0; i < n; i++) | |
x[i] += i; | |
} | |
void array_math_test(double *x, int n, int m) | |
{ | |
int i, j; | |
for (i = 0; i < n; i++) | |
for (j = 0; j < m; j++) | |
x[i*m + j] += 10*i + j; | |
} | |
void multi_test(double **x, int n, int m) | |
{ | |
int i, j; | |
for (i = 0; i < n; i++) | |
for (j = 0; j < m; j++) | |
x[i][j] += 10*i + j; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment