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

Function sum_array

src/testapi_usergrid.c:137–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137double sum_array (void *vector, unsigned int type) {
138 /* Print one row with the output data */
139 double *d = NULL;
140 float *f = NULL;
141 uint64_t *ul = NULL;
142 int64_t *sl = NULL;
143 unsigned int *ui = NULL;
144 int *si = NULL;
145 unsigned short int *uh = NULL;
146 short int *sh = NULL;
147 unsigned char *uc = NULL;
148 char *sc = NULL;
149 unsigned int k;
150 double sum = 0.0;
151 switch (type) {
152 case GMT_DOUBLE:
153 d = vector; for (k = 0; k < NM; k++) sum += d[k];
154 break;
155 case GMT_FLOAT:
156 f = vector; for (k = 0; k < NM; k++) sum += f[k];
157 break;
158 case GMT_ULONG:
159 ul = vector; for (k = 0; k < NM; k++) sum += ul[k];
160 break;
161 case GMT_LONG:
162 sl = vector; for (k = 0; k < NM; k++) sum += sl[k];
163 break;
164 case GMT_UINT:
165 ui = vector; for (k = 0; k < NM; k++) sum += ui[k];
166 break;
167 case GMT_INT:
168 si = vector; for (k = 0; k < NM; k++) sum += si[k];
169 break;
170 case GMT_USHORT:
171 uh = vector; for (k = 0; k < NM; k++) sum += uh[k];
172 break;
173 case GMT_SHORT:
174 sh = vector; for (k = 0; k < NM; k++) sum += sh[k];
175 break;
176 case GMT_UCHAR:
177 uc = vector; for (k = 0; k < NM; k++) sum += uc[k];
178 break;
179 case GMT_CHAR:
180 sc = vector; for (k = 0; k < NM; k++) sum += sc[k];
181 break;
182 }
183 return (sum);
184}
185
186int deploy_test (unsigned int intype, unsigned int outtype, int alloc_in_GMT, int def_mode, int V) {
187 /* 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