source: CIVL/examples/amg/csr/csr_add_spec.c@ acdd55c

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since acdd55c was bb2f977, checked in by Stephen Siegel <siegel@…>, 10 years ago

Trying TASS versions of CSR.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@3748 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.0 KB
Line 
1
2#include <stdlib.h>
3
4// Dense matrix spec...
5
6#pragma TASS input {N==3}
7int N;
8#pragma TASS input {M==3}
9int M;
10
11#pragma TASS input
12double A0[N*M];
13#pragma TASS input
14double B0[N*M];
15#pragma TASS output
16double C_OUT[N*M];
17
18/*
19struct DM_struct {
20 double * data;
21 int num_rows;
22 int num_cols;
23};
24*/
25
26typedef double DenseMatrix;
27
28//typedef struct DM_struct DenseMatrix;
29//typedef DenseMatrix * DM;
30
31
32double * dense_create(int n, int m) {
33 double * mat;
34
35 mat = (double*)malloc(n*m*sizeof(double));
36 /*
37 mat->num_rows = n;
38 mat->num_cols = m;
39 mat->data = (double*) malloc(n*m*sizeof(double));
40 */
41 return mat;
42}
43
44
45DenseMatrix * dense_add(int n, int m, DenseMatrix *A, DenseMatrix *B) {
46 int i;
47 DenseMatrix * C;
48
49 C = dense_create(n,m);
50 for (i=0; i<n*m; i++)
51 C[i] = A[i] + B[i];
52 return C;
53}
54
55void free_dense(DenseMatrix *matrix) {
56 //free(matrix->data);
57 free(matrix);
58}
59
60int main() {
61 int i;
62 DenseMatrix * C;
63
64 C = dense_add(N,M,&A0[0],&B0[0]);
65 for (i=0; i<N*M; i++)
66 C_OUT[i] = C[i];
67 free_dense(C);
68 return 0;
69}
Note: See TracBrowser for help on using the repository browser.