MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / sum_array

Function sum_array

src/testapi_userdataset.c:126–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126double sum_array (void *vector, unsigned int type) {
127 /* Print one row with the output data */
128 double *d = NULL;
129 float *f = NULL;
130 uint64_t *ul = NULL;
131 int64_t *sl = NULL;
132 unsigned int *ui = NULL;
133 int *si = NULL;
134 unsigned short int *uh = NULL;
135 short int *sh = NULL;
136 unsigned char *uc = NULL;
137 char *sc = NULL;
138 unsigned int k;
139 double sum = 0.0;
140 switch (type) {
141 case GMT_DOUBLE:
142 d = vector; for (k = 0; k < NM; k++) sum += d[k];
143 break;
144 case GMT_FLOAT:
145 f = vector; for (k = 0; k < NM; k++) sum += f[k];
146 break;
147 case GMT_ULONG:
148 ul = vector; for (k = 0; k < NM; k++) sum += ul[k];
149 break;
150 case GMT_LONG:
151 sl = vector; for (k = 0; k < NM; k++) sum += sl[k];
152 break;
153 case GMT_UINT:
154 ui = vector; for (k = 0; k < NM; k++) sum += ui[k];
155 break;
156 case GMT_INT:
157 si = vector; for (k = 0; k < NM; k++) sum += si[k];
158 break;
159 case GMT_USHORT:
160 uh = vector; for (k = 0; k < NM; k++) sum += uh[k];
161 break;
162 case GMT_SHORT:
163 sh = vector; for (k = 0; k < NM; k++) sum += sh[k];
164 break;
165 case GMT_UCHAR:
166 uc = vector; for (k = 0; k < NM; k++) sum += uc[k];
167 break;
168 case GMT_CHAR:
169 sc = vector; for (k = 0; k < NM; k++) sum += sc[k];
170 break;
171 }
172 return (sum);
173}
174
175int deploy_test (unsigned int intype, unsigned int outtype, int alloc_in_GMT, int V) {
176 /* Run the test using the specified in and out types */

Callers 1

deploy_testFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected