ESYS13
Revision_
|
00001 00002 /******************************************************* 00003 * 00004 * Copyright (c) 2003-2012 by University of Queensland 00005 * Earth Systems Science Computational Center (ESSCC) 00006 * http://www.uq.edu.au/esscc 00007 * 00008 * Primary Business: Queensland, Australia 00009 * Licensed under the Open Software License version 3.0 00010 * http://www.opensource.org/licenses/osl-3.0.php 00011 * 00012 *******************************************************/ 00013 00014 /**************************************************************/ 00015 00016 /* Some utility routines: */ 00017 00018 /**************************************************************/ 00019 00020 #ifndef INC_DUDLEY_UTIL 00021 #define INC_DUDLEY_UTIL 00022 00023 #include "Dudley.h" 00024 00025 /**************************************************************/ 00026 00027 void Dudley_Util_Gather_double(dim_t len, index_t * index, dim_t numData, double *in, double *out); 00028 void Dudley_Util_Gather_int(dim_t len, index_t * index, dim_t numData, index_t * in, index_t * out); 00029 void Dudley_Util_AddScatter(const dim_t len, const index_t * index, const dim_t numData, const double *in, double *out, const index_t upperBound); 00030 void Dudley_Util_SmallMatMult(dim_t A1, dim_t A2, double *A, dim_t B2, const double *B, const double *C); 00031 void Dudley_Util_SmallMatSetMult(dim_t len, dim_t A1, dim_t A2, double *A, dim_t B2, const double *B, const double *C); 00032 void Dudley_Util_SmallMatSetMult1(dim_t len, dim_t A1, dim_t A2, double *A, dim_t B2, const double *B, const double *C); 00033 void Dudley_Util_InvertSmallMat(dim_t len, dim_t dim, double *A, double *invA, double *det); 00034 void Dudley_Util_DetOfSmallMat(dim_t len, dim_t dim, double *A, double *det); 00035 void Dudley_NormalVector(dim_t len, dim_t dim, dim_t dim1, double *A, double *Normal); 00036 void Dudley_LengthOfNormalVector(dim_t len, dim_t dim, dim_t dim1, double *A, double *length); 00037 void Dudley_Util_InvertMap(dim_t, index_t *, dim_t, index_t *); 00038 index_t Dudley_Util_getMaxInt(dim_t dim, dim_t N, index_t * values); 00039 index_t Dudley_Util_getMinInt(dim_t dim, dim_t N, index_t * values); 00040 index_t Dudley_Util_getFlaggedMaxInt(dim_t dim, dim_t N, index_t * values, index_t ignore); 00041 index_t Dudley_Util_getFlaggedMinInt(dim_t dim, dim_t N, index_t * values, index_t ignore); 00042 dim_t Dudley_Util_packMask(dim_t N, bool_t * mask, index_t * index); 00043 bool_t Dudley_Util_isAny(dim_t N, index_t * array, index_t value); 00044 index_t Dudley_Util_cumsum(dim_t, index_t *); 00045 bool_t Dudley_Util_anyNonZeroDouble(dim_t N, double *values); 00046 void Dudley_Util_setValuesInUse(const index_t * values, const dim_t numValues, dim_t * numValuesInUse, 00047 index_t ** valuesInUse, Esys_MPIInfo * mpiinfo); 00048 00049 #ifdef ESYS_MPI 00050 void Dudley_printDoubleArray(FILE * fid, dim_t n, double *array, char *name); 00051 void Dudley_printIntArray(FILE * fid, dim_t n, int *array, char *name); 00052 void Dudley_printMaskArray(FILE * fid, dim_t n, int *array, char *name); 00053 #endif 00054 00055 /* Dudley_Util_orderValueAndIndex is used to sort items by a value */ 00056 /* index points to the location of the original item array. */ 00057 /* it can be used to reorder the array */ 00058 struct Dudley_Util_ValueAndIndex { 00059 index_t index; 00060 index_t value; 00061 }; 00062 typedef struct Dudley_Util_ValueAndIndex Dudley_Util_ValueAndIndex; 00063 00064 void Dudley_Util_sortValueAndIndex(dim_t n, Dudley_Util_ValueAndIndex * array); 00065 int Dudley_Util_ValueAndIndex_compar(const void *, const void *); 00066 00067 #endif /* #ifndef INC_UTIL_UTIL */