Skip to content

Instantly share code, notes, and snippets.

@arjones6
Last active December 17, 2015 02:09
Show Gist options
  • Save arjones6/5533811 to your computer and use it in GitHub Desktop.
Save arjones6/5533811 to your computer and use it in GitHub Desktop.
Simple C functions taking arrays as arguments.
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