/[escript]/trunk/finley/src/Util.c
ViewVC logotype

Annotation of /trunk/finley/src/Util.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2425 - (hide annotations)
Thu May 14 09:06:35 2009 UTC (10 years, 4 months ago) by gross
File MIME type: text/plain
File size: 18674 byte(s)
bug in getListOfTags fixed and some tested added
1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 jgs 82
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17 ksteube 1312 /* Some utility routines: */
18 jgs 82
19     /**************************************************************/
20    
21     #include "Finley.h"
22     #include "Util.h"
23 woo409 757
24 jgs 113 #ifdef _OPENMP
25     #include <omp.h>
26     #endif
27 jgs 82
28     /**************************************************************/
29    
30 jgs 147 /* returns true if any of the values in the short array values is not equalt to Zero */
31    
32     bool_t Finley_Util_anyNonZeroDouble(dim_t N, double* values) {
33     dim_t q;
34     for (q=0;q<N;++q) if (ABS(values[q])>0) return TRUE;
35     return FALSE;
36     }
37     /**************************************************************/
38    
39 jgs 82 /* gathers double values out from in by index: */
40    
41     /* out(1:numData,1:len)=in(1:numData,index(1:len)) */
42    
43 jgs 123 void Finley_Util_Gather_double(dim_t len,index_t* index,dim_t numData,double* in, double * out){
44     dim_t s,i;
45 jgs 82 for (s=0;s<len;s++) {
46     for (i=0;i<numData;i++) {
47     out[INDEX2(i,s,numData)]=in[INDEX2(i,index[s],numData)];
48     }
49     }
50     }
51    
52     /**************************************************************/
53    
54    
55     /* gathers maybelong values out from in by index: */
56    
57     /* out(1:numData,1:len)=in(1:numData,index(1:len)) */
58    
59 jgs 123 void Finley_Util_Gather_int(dim_t len,index_t* index,dim_t numData, index_t* in, index_t * out){
60     dim_t s,i;
61 jgs 82 for (s=0;s<len;s++) {
62     for (i=0;i<numData;i++) {
63     out[INDEX2(i,s,numData)]=in[INDEX2(i,index[s],numData)];
64     }
65     }
66     }
67    
68     /**************************************************************/
69    
70     /* adds a vector in into out using and index. */
71    
72 gross 798 /* out(1:numData,index[p])+=in(1:numData,p) where p = {k=1...len , index[k]<upperBound}*/
73 jgs 82
74 gross 798
75     void Finley_Util_AddScatter(dim_t len,index_t* index,dim_t numData,double* in,double * out, index_t upperBound){
76 jgs 123 dim_t i,s;
77 jgs 82 for (s=0;s<len;s++) {
78     for(i=0;i<numData;i++) {
79 ksteube 799 if( index[s]<upperBound ) {
80 bcumming 751 out[INDEX2(i,index[s],numData)]+=in[INDEX2(i,s,numData)];
81 ksteube 799 }
82 bcumming 751 }
83     }
84 gross 798 }
85 bcumming 751
86 jgs 82 /* multiplies two matrices */
87    
88     /* A(1:A1,1:A2)=B(1:A1,1:B2)*C(1:B2,1:A2) */
89    
90 jgs 123 void Finley_Util_SmallMatMult(dim_t A1,dim_t A2, double* A, dim_t B2, double*B, double* C) {
91     dim_t i,j,s;
92 jgs 82 for (i=0;i<A1*A2;i++) A[i]=0;
93     for (i=0;i<A1;i++) {
94     for (j=0;j<A2;j++) {
95     for (s=0;s<B2;s++) {
96     A[INDEX2(i,j,A1)]+=B[INDEX2(i,s,A1)]*C[INDEX2(s,j,B2)];
97     }
98     }
99     }
100     }
101    
102     /* multiplies a two sets of matries: */
103    
104     /* A(1:A1,1:A2,i)=B(1:A1,1:B2,i)*C(1:B2,1:A2,i) i=1,len */
105    
106 jgs 123 void Finley_Util_SmallMatSetMult(dim_t len,dim_t A1,dim_t A2, double* A, dim_t B2, double*B, double* C) {
107     dim_t q,i,j,s;
108 jgs 82 for (i=0;i<A1*A2*len;i++) A[i]=0;
109     for (q=0;q<len;q++) {
110     for (i=0;i<A1;i++) {
111     for (j=0;j<A2;j++) {
112     for (s=0;s<B2;s++) {
113     A[INDEX3(i,j,q,A1,A2)]+=B[INDEX3(i,s,q,A1,B2)]*C[INDEX3(s,j,q,B2,A2)];
114     }
115     }
116     }
117     }
118     }
119     /* inverts the set of dim x dim matrices A(:,:,1:len) with dim=1,2,3 */
120     /* the determinante is returned. */
121    
122 jgs 123 void Finley_Util_InvertSmallMat(dim_t len,dim_t dim,double* A,double *invA, double* det){
123     dim_t q;
124     register double D,A11,A12,A13,A21,A22,A23,A31,A32,A33;
125 jgs 82
126     switch(dim) {
127     case 1:
128     for (q=0;q<len;q++) {
129 jgs 115 D=A[q];
130 jgs 102 if (ABS(D) > 0 ){
131     det[q]=D;
132     D=1./D;
133 jgs 115 invA[q]=D;
134 jgs 102 } else {
135 jgs 150 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: Non-regular matrix");
136 jgs 82 return;
137     }
138     }
139     break;
140    
141     case 2:
142     for (q=0;q<len;q++) {
143 jgs 115 A11=A[INDEX3(0,0,q,2,2)];
144     A12=A[INDEX3(0,1,q,2,2)];
145     A21=A[INDEX3(1,0,q,2,2)];
146     A22=A[INDEX3(1,1,q,2,2)];
147 jgs 82
148     D = A11*A22-A12*A21;
149 jgs 102 if (ABS(D) > 0 ){
150     det[q]=D;
151     D=1./D;
152 jgs 115 invA[INDEX3(0,0,q,2,2)]= A22*D;
153     invA[INDEX3(1,0,q,2,2)]=-A21*D;
154     invA[INDEX3(0,1,q,2,2)]=-A12*D;
155     invA[INDEX3(1,1,q,2,2)]= A11*D;
156 jgs 102 } else {
157 jgs 150 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: Non-regular matrix");
158 jgs 82 return;
159     }
160     }
161     break;
162    
163     case 3:
164     for (q=0;q<len;q++) {
165 jgs 115 A11=A[INDEX3(0,0,q,3,3)];
166     A21=A[INDEX3(1,0,q,3,3)];
167     A31=A[INDEX3(2,0,q,3,3)];
168     A12=A[INDEX3(0,1,q,3,3)];
169     A22=A[INDEX3(1,1,q,3,3)];
170     A32=A[INDEX3(2,1,q,3,3)];
171     A13=A[INDEX3(0,2,q,3,3)];
172     A23=A[INDEX3(1,2,q,3,3)];
173     A33=A[INDEX3(2,2,q,3,3)];
174 jgs 82
175     D = A11*(A22*A33-A23*A32)+ A12*(A31*A23-A21*A33)+A13*(A21*A32-A31*A22);
176 jgs 102 if (ABS(D) > 0 ){
177     det[q] =D;
178     D=1./D;
179 jgs 115 invA[INDEX3(0,0,q,3,3)]=(A22*A33-A23*A32)*D;
180     invA[INDEX3(1,0,q,3,3)]=(A31*A23-A21*A33)*D;
181     invA[INDEX3(2,0,q,3,3)]=(A21*A32-A31*A22)*D;
182     invA[INDEX3(0,1,q,3,3)]=(A13*A32-A12*A33)*D;
183     invA[INDEX3(1,1,q,3,3)]=(A11*A33-A31*A13)*D;
184     invA[INDEX3(2,1,q,3,3)]=(A12*A31-A11*A32)*D;
185     invA[INDEX3(0,2,q,3,3)]=(A12*A23-A13*A22)*D;
186     invA[INDEX3(1,2,q,3,3)]=(A13*A21-A11*A23)*D;
187     invA[INDEX3(2,2,q,3,3)]=(A11*A22-A12*A21)*D;
188 jgs 102 } else {
189 jgs 150 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: Non-regular matrix");
190 jgs 82 return;
191     }
192     }
193     break;
194    
195     }
196     return;
197     }
198    
199     /* sets the derterminate of a set of dim x dim matrices A(:,:,1:len) with dim=1,2,3 */
200    
201 jgs 123 void Finley_Util_DetOfSmallMat(dim_t len,dim_t dim,double* A, double* det){
202     dim_t q;
203     register double A11,A12,A13,A21,A22,A23,A31,A32,A33;
204 jgs 82
205     switch(dim) {
206     case 1:
207     for (q=0;q<len;q++) {
208 jgs 115 det[q]=A[q];
209 jgs 82 }
210     break;
211    
212     case 2:
213     for (q=0;q<len;q++) {
214 jgs 115 A11=A[INDEX3(0,0,q,2,2)];
215     A12=A[INDEX3(0,1,q,2,2)];
216     A21=A[INDEX3(1,0,q,2,2)];
217     A22=A[INDEX3(1,1,q,2,2)];
218 jgs 82
219     det[q] = A11*A22-A12*A21;
220     }
221     break;
222    
223     case 3:
224     for (q=0;q<len;q++) {
225 jgs 115 A11=A[INDEX3(0,0,q,3,3)];
226     A21=A[INDEX3(1,0,q,3,3)];
227     A31=A[INDEX3(2,0,q,3,3)];
228     A12=A[INDEX3(0,1,q,3,3)];
229     A22=A[INDEX3(1,1,q,3,3)];
230     A32=A[INDEX3(2,1,q,3,3)];
231     A13=A[INDEX3(0,2,q,3,3)];
232     A23=A[INDEX3(1,2,q,3,3)];
233     A33=A[INDEX3(2,2,q,3,3)];
234 jgs 82
235     det[q] = A11*(A22*A33-A23*A32)+ A12*(A31*A23-A21*A33)+A13*(A21*A32-A31*A22);
236     }
237     break;
238    
239     }
240     return;
241     }
242     /* returns the normalized vector Normal[dim,len] orthogonal to A(:,0,q) and A(:,1,q) in the case of dim=3 */
243     /* or the vector A(:,0,q) in the case of dim=2 */
244    
245 jgs 123 void Finley_NormalVector(dim_t len, dim_t dim, dim_t dim1, double* A,double* Normal) {
246     dim_t q;
247     register double A11,A12,CO_A13,A21,A22,CO_A23,A31,A32,CO_A33,length,invlength;
248 jgs 82
249     switch(dim) {
250     case 1:
251 jgs 115 for (q=0;q<len;q++) Normal[q] =1;
252 jgs 82 break;
253     case 2:
254     for (q=0;q<len;q++) {
255 jgs 115 A11=A[INDEX3(0,0,q,2,dim1)];
256     A21=A[INDEX3(1,0,q,2,dim1)];
257 jgs 82 length = sqrt(A11*A11+A21*A21);
258     if (! length>0) {
259 jgs 150 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: area equals zero.");
260 jgs 82 return;
261     } else {
262     invlength=1./length;
263 jgs 115 Normal[INDEX2(0,q,2)]=A21*invlength;
264     Normal[INDEX2(1,q,2)]=-A11*invlength;
265 jgs 82 }
266     }
267     break;
268     case 3:
269     for (q=0;q<len;q++) {
270 jgs 115 A11=A[INDEX3(0,0,q,3,dim1)];
271     A21=A[INDEX3(1,0,q,3,dim1)];
272     A31=A[INDEX3(2,0,q,3,dim1)];
273     A12=A[INDEX3(0,1,q,3,dim1)];
274     A22=A[INDEX3(1,1,q,3,dim1)];
275     A32=A[INDEX3(2,1,q,3,dim1)];
276 jgs 82 CO_A13=A21*A32-A31*A22;
277     CO_A23=A31*A12-A11*A32;
278     CO_A33=A11*A22-A21*A12;
279     length=sqrt(CO_A13*CO_A13+CO_A23*CO_A23+CO_A33*CO_A33);
280     if (! length>0) {
281 jgs 150 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: area equals zero.");
282 jgs 82 return;
283     } else {
284     invlength=1./length;
285 jgs 115 Normal[INDEX2(0,q,3)]=CO_A13*invlength;
286     Normal[INDEX2(1,q,3)]=CO_A23*invlength;
287     Normal[INDEX2(2,q,3)]=CO_A33*invlength;
288 jgs 82 }
289    
290     }
291     break;
292    
293     }
294     return;
295     }
296    
297     /* return the length of the vector which is orthogonal to the vectors A(:,0,q) and A(:,1,q) in the case of dim=3 */
298     /* or the vector A(:,0,q) in the case of dim=2 */
299    
300 jgs 123 void Finley_LengthOfNormalVector(dim_t len, dim_t dim, dim_t dim1, double* A,double* length) {
301     dim_t q;
302 jgs 82 double A11,A12,CO_A13,A21,A22,CO_A23,A31,A32,CO_A33;
303    
304     switch(dim) {
305     case 1:
306 jgs 115 for (q=0;q<len;q++) length[q] =1;
307 jgs 82 break;
308     case 2:
309     for (q=0;q<len;q++) {
310 jgs 115 A11=A[INDEX3(0,0,q,2,dim1)];
311     A21=A[INDEX3(1,0,q,2,dim1)];
312 jgs 82 length[q] = sqrt(A11*A11+A21*A21);
313     }
314     break;
315     case 3:
316     for (q=0;q<len;q++) {
317 jgs 115 A11=A[INDEX3(0,0,q,3,dim1)];
318     A21=A[INDEX3(1,0,q,3,dim1)];
319     A31=A[INDEX3(2,0,q,3,dim1)];
320     A12=A[INDEX3(0,1,q,3,dim1)];
321     A22=A[INDEX3(1,1,q,3,dim1)];
322     A32=A[INDEX3(2,1,q,3,dim1)];
323 jgs 82 CO_A13=A21*A32-A31*A22;
324     CO_A23=A31*A12-A11*A32;
325     CO_A33=A11*A22-A21*A12;
326     length[q]=sqrt(CO_A13*CO_A13+CO_A23*CO_A23+CO_A33*CO_A33);
327     }
328     break;
329    
330     }
331     return;
332     }
333    
334     /* inverts the map map of length len */
335     /* there is no range checking! */
336     /* at output Map[invMap[i]]=i for i=0:lenInvMap */
337    
338 jgs 123 void Finley_Util_InvertMap(dim_t lenInvMap, index_t* invMap,dim_t lenMap, index_t* Map) {
339     dim_t i;
340 jgs 82 for (i=0;i<lenInvMap;i++) invMap[i]=0;
341     for (i=0;i<lenMap;i++) {
342     if (Map[i]>=0) invMap[Map[i]]=i;
343     }
344     }
345    
346     /* orders a Finley_Util_ValueAndIndex array by value */
347     /* it is assumed that n is large */
348    
349     int Finley_Util_ValueAndIndex_compar(const void *arg1 , const void *arg2 ) {
350     Finley_Util_ValueAndIndex *e1,*e2;
351     e1=(Finley_Util_ValueAndIndex*) arg1;
352     e2=(Finley_Util_ValueAndIndex*) arg2;
353     if (e1->value < e2->value) return -1;
354     if (e1->value > e2->value) return 1;
355 gross 763 if (e1->index < e2->index) return -1;
356     if (e1->index > e2->index) return 1;
357 jgs 82 return 0;
358     }
359 woo409 757
360 jgs 123 void Finley_Util_sortValueAndIndex(dim_t n,Finley_Util_ValueAndIndex* array) {
361 jgs 82 /* OMP : needs parallelization !*/
362     qsort(array,n,sizeof(Finley_Util_ValueAndIndex),Finley_Util_ValueAndIndex_compar);
363     }
364    
365    
366     /**************************************************************/
367    
368     /* calculates the minimum value from a dim X N integer array */
369    
370 jgs 123 index_t Finley_Util_getMinInt(dim_t dim,dim_t N,index_t* values) {
371     dim_t i,j;
372     index_t out,out_local;
373     out=INDEX_T_MAX;
374 jgs 82 if (values!=NULL && dim*N>0 ) {
375     out=values[0];
376 jgs 115 #pragma omp parallel private(out_local)
377     {
378     out_local=out;
379     #pragma omp for private(i,j) schedule(static)
380     for (j=0;j<N;j++) {
381     for (i=0;i<dim;i++) out_local=MIN(out_local,values[INDEX2(i,j,dim)]);
382     }
383     #pragma omp critical
384     out=MIN(out_local,out);
385 jgs 82 }
386     }
387     return out;
388     }
389    
390     /* calculates the maximum value from a dim X N integer array */
391    
392 jgs 123 index_t Finley_Util_getMaxInt(dim_t dim,dim_t N,index_t* values) {
393     dim_t i,j;
394     index_t out,out_local;
395     out=-INDEX_T_MAX;
396 jgs 82 if (values!=NULL && dim*N>0 ) {
397     out=values[0];
398 jgs 115 #pragma omp parallel private(out_local)
399     {
400     out_local=out;
401     #pragma omp for private(i,j) schedule(static)
402     for (j=0;j<N;j++) {
403     for (i=0;i<dim;i++) out_local=MAX(out_local,values[INDEX2(i,j,dim)]);
404     }
405     #pragma omp critical
406     out=MAX(out_local,out);
407     }
408 jgs 82 }
409     return out;
410     }
411 ksteube 1312 /**************************************************************/
412 jgs 82
413 ksteube 1312 /* calculates the minimum value from a dim X N integer array */
414    
415     index_t Finley_Util_getFlaggedMinInt(dim_t dim,dim_t N,index_t* values, index_t ignore) {
416     dim_t i,j;
417     index_t out,out_local;
418     out=INDEX_T_MAX;
419     if (values!=NULL && dim*N>0 ) {
420     out=values[0];
421     #pragma omp parallel private(out_local)
422     {
423     out_local=out;
424     #pragma omp for private(i,j) schedule(static)
425     for (j=0;j<N;j++) {
426     for (i=0;i<dim;i++) if (values[INDEX2(i,j,dim)]!=ignore) out_local=MIN(out_local,values[INDEX2(i,j,dim)]);
427     }
428     #pragma omp critical
429     out=MIN(out_local,out);
430     }
431     }
432     return out;
433     }
434    
435     /* calculates the maximum value from a dim X N integer array */
436    
437     index_t Finley_Util_getFlaggedMaxInt(dim_t dim,dim_t N,index_t* values, index_t ignore) {
438     dim_t i,j;
439     index_t out,out_local;
440     out=-INDEX_T_MAX;
441     if (values!=NULL && dim*N>0 ) {
442     out=values[0];
443     #pragma omp parallel private(out_local)
444     {
445     out_local=out;
446     #pragma omp for private(i,j) schedule(static)
447     for (j=0;j<N;j++) {
448     for (i=0;i<dim;i++) if (values[INDEX2(i,j,dim)]!=ignore) out_local=MAX(out_local,values[INDEX2(i,j,dim)]);
449     }
450     #pragma omp critical
451     out=MAX(out_local,out);
452     }
453     }
454     return out;
455     }
456    
457 jgs 82 /* set the index of the positive entries in mask. The length of index is returned. */
458    
459 jgs 123 dim_t Finley_Util_packMask(dim_t N,index_t* mask,index_t* index) {
460     dim_t out,k;
461 jgs 82 out=0;
462     /*OMP */
463     for (k=0;k<N;k++) {
464     if (mask[k]>=0) {
465     index[out]=k;
466     out++;
467     }
468     }
469     return out;
470     }
471    
472     /* returns true if array contains value */
473 jgs 123 bool_t Finley_Util_isAny(dim_t N,index_t* array,index_t value) {
474     bool_t out=FALSE;
475     dim_t i;
476 jgs 82 #pragma omp parallel for private(i) schedule(static) reduction(||:out)
477 jgs 115 for (i=0;i<N;i++) out = out || (array[i]==value);
478 jgs 82 return out;
479     }
480 jgs 113 /* calculates the cummultative sum in array and returns the total sum */
481 jgs 123 index_t Finley_Util_cumsum(dim_t N,index_t* array) {
482     index_t out=0,tmp;
483     dim_t i;
484 jgs 113 #ifdef _OPENMP
485 gross 1564 index_t *partial_sums=NULL, sum;
486     partial_sums=TMPMEMALLOC(omp_get_max_threads(),index_t);
487 jgs 113 #pragma omp parallel private(sum,i,tmp)
488     {
489     sum=0;
490 jgs 115 #pragma omp for schedule(static)
491     for (i=0;i<N;++i) sum+=array[i];
492 jgs 113 partial_sums[omp_get_thread_num()]=sum;
493 jgs 115 #pragma omp barrier
494 jgs 113 #pragma omp master
495     {
496     out=0;
497     for (i=0;i<omp_get_max_threads();++i) {
498     tmp=out;
499     out+=partial_sums[i];
500     partial_sums[i]=tmp;
501     }
502     }
503 jgs 115 #pragma omp barrier
504 jgs 113 sum=partial_sums[omp_get_thread_num()];
505 jgs 115 #pragma omp for schedule(static)
506     for (i=0;i<N;++i) {
507     tmp=sum;
508     sum+=array[i];
509     array[i]=tmp;
510     }
511 jgs 113 }
512 gross 1564 TMPMEMFREE(partial_sums);
513 jgs 113 #else
514     for (i=0;i<N;++i) {
515     tmp=out;
516     out+=array[i];
517     array[i]=tmp;
518     }
519     #endif
520     return out;
521     }
522 gross 1716 void Finley_Util_setValuesInUse(const index_t *values, const dim_t numValues, dim_t *numValuesInUse, index_t **valuesInUse, Paso_MPIInfo* mpiinfo)
523     {
524     dim_t i;
525     index_t lastFoundValue=INDEX_T_MIN, minFoundValue, local_minFoundValue, *newValuesInUse=NULL;
526     register index_t itmp;
527     bool_t allFound=FALSE;
528     dim_t nv=0;
529 jgs 82
530 gross 1716 while (! allFound) {
531     /*
532     * find smallest value bigger than lastFoundValue
533     */
534     minFoundValue=INDEX_T_MAX;
535     #pragma omp parallel private(local_minFoundValue)
536     {
537     local_minFoundValue=minFoundValue;
538     #pragma omp for private(i,itmp) schedule(static)
539     for (i=0;i< numValues;i++) {
540     itmp=values[i];
541     if ((itmp>lastFoundValue) && (itmp<local_minFoundValue)) local_minFoundValue=itmp;
542     }
543     #pragma omp critical
544 gross 2425 {
545     if (local_minFoundValue<minFoundValue) minFoundValue=local_minFoundValue;
546     }
547    
548 gross 1716 }
549     #ifdef PASO_MPI
550     local_minFoundValue=minFoundValue;
551 gross 2425 MPI_Allreduce(&local_minFoundValue,&minFoundValue, 1, MPI_INT, MPI_MIN, mpiinfo->comm );
552 gross 1716 #endif
553     /* if we found a new tag we need to add this too the valuesInUseList */
554    
555     if (minFoundValue < INDEX_T_MAX) {
556     newValuesInUse=MEMALLOC(nv+1,index_t);
557     if (*valuesInUse!=NULL) {
558     memcpy(newValuesInUse,*valuesInUse,sizeof(index_t)*nv);
559     MEMFREE(*valuesInUse);
560     }
561     newValuesInUse[nv]=minFoundValue;
562     *valuesInUse=newValuesInUse;
563     newValuesInUse=NULL;
564     nv++;
565     lastFoundValue=minFoundValue;
566     } else {
567     allFound=TRUE;
568     }
569     }
570     *numValuesInUse=nv;
571     }
572    
573    
574 bcumming 751 #ifdef PASO_MPI
575     void Finley_printDoubleArray( FILE *fid, dim_t n, double *array, char *name )
576     {
577     index_t i;
578    
579     if( name )
580     fprintf( fid, "%s [ ", name );
581     else
582     fprintf( fid, "[ " );
583 bcumming 782 for( i=0; i<(n<60 ? n : 60); i++ )
584 bcumming 751 fprintf( fid, "%g ", array[i] );
585     if( n>=30 )
586     fprintf( fid, "... " );
587     fprintf( fid, "]\n" );
588     }
589     void Finley_printIntArray( FILE *fid, dim_t n, int *array, char *name )
590     {
591     index_t i;
592    
593     if( name )
594     fprintf( fid, "%s [ ", name );
595     else
596     fprintf( fid, "[ " );
597 bcumming 782 for( i=0; i<(n<60 ? n : 60); i++ )
598 bcumming 751 fprintf( fid, "%d ", array[i] );
599     if( n>=30 )
600     fprintf( fid, "... " );
601     fprintf( fid, "]\n" );
602     }
603     void Finley_printMaskArray( FILE *fid, dim_t n, int *array, char *name )
604     {
605     index_t i;
606    
607     if( name )
608     fprintf( fid, "%s [ ", name );
609     else
610     fprintf( fid, "[ " );
611 bcumming 782 for( i=0; i<(n<60 ? n : 60); i++ )
612 bcumming 751 if( array[i]!=-1 )
613 bcumming 782 fprintf( fid, "%3d ", array[i] );
614 bcumming 751 else
615 bcumming 782 fprintf( fid, " * " );
616 bcumming 751 if( n>=30 )
617     fprintf( fid, "... " );
618     fprintf( fid, "]\n" );
619     }
620     #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26