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