Skip to content

Instantly share code, notes, and snippets.

@ffloyd
Created April 20, 2014 16:05
Show Gist options
  • Save ffloyd/11117713 to your computer and use it in GitHub Desktop.
Save ffloyd/11117713 to your computer and use it in GitHub Desktop.
metacl result
#include <stdlib.h>
#include <stdio.h>
int main()
{
float *a = malloc(100 * sizeof(float)); // N = 10, M = 10
for (int i = 0; i < 100; i++) {
a[i] = 1;
}
float *b = malloc(100 * sizeof(float)); // N = 10, M = 10
for (int i = 0; i < 100; i++) {
b[i] = 2;
}
float *c = malloc(100 * sizeof(float)); // N = 10, M = 10
for (int i = 0; i < 100; i++) {
c[i] = 3;
}
float *d = malloc(100 * sizeof(float)); // N = 10, M = 10
for (int i = 0; i < 100; i++) {
d[i] = 4;
}
float *result = malloc(100 * sizeof(float)); // N = 10, M = 10
for (int i=0; i < 10; i++)
{
for (int j=0; j < 10; j++)
{
float t1 = a[i*10 + j] + b[i*10 + j];
float t2 = c[i*10 + j] - d[i*10 + j];
float t3 = t1 + t2;
result[i*10 + j] = t3;
}
}
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
printf("%f ", result[j + 10*i]);
}
printf("\n");
}
free(a);
free(b);
free(c);
free(d);
free(result);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment