#include "petscmat.h"
#include "anamodtypes.h"
Go to the source code of this file.
Defines | |
#define | ANAMOD_FORMAT_VERSION "1.0" |
#define | TRUTH(x) ( (x) ? PETSC_TRUE : PETSC_FALSE ) |
#define | HASTOEXIST(h) |
#define | ANAMODCHECKVALID(i, c, s) {if (!i) SETERRQ(1,"Null pointer"); if (i->cookie!=c) SETERRQ1(1,"Not a valid <%s>",s);} |
Typedefs | |
typedef struct FeatureSet_ * | FeatureSet |
typedef struct FeatureValues_ * | FeatureValues |
Functions | |
PetscErrorCode | AnaModInitialize () |
PetscErrorCode | AnaModFinalize () |
PetscErrorCode | AnaModGetTypeName (int id, char **name) |
PetscErrorCode | AnaModGetTypeMySQLName (int id, char **name) |
PetscErrorCode | AnaModRegisterStandardModules () |
PetscErrorCode | RegisterModule (const char *, const char *, AnalysisDataType, PetscErrorCode(*f)(AnaModNumericalProblem, AnalysisItem *, int *, PetscTruth *)) |
PetscErrorCode | DeRegisterCategory (char *cat) |
PetscErrorCode | DeregisterModules (void) |
PetscErrorCode | GetCategories (char ***, int *) |
PetscErrorCode | CategoryGetModules (char *, char ***, AnalysisDataType **, int **, int *) |
PetscErrorCode | HasComputeCategory (char *cat, PetscTruth *f) |
PetscErrorCode | HasComputeModule (char *cat, char *cmp, PetscTruth *f) |
PetscErrorCode | GetDataID (const char *, const char *, int *, PetscTruth *) |
PetscErrorCode | GetDataType (const char *, const char *, AnalysisDataType *) |
PetscErrorCode | ComputeQuantity (AnaModNumericalProblem, const char *, const char *, AnalysisItem *, int *, PetscTruth *) |
PetscErrorCode | ComputeQuantityByID (AnaModNumericalProblem, int, int, AnalysisItem *, int *, PetscTruth *) |
PetscErrorCode | HasQuantity (AnaModNumericalProblem, char *, char *, PetscTruth *) |
PetscErrorCode | HasQuantityByID (AnaModNumericalProblem, int, AnalysisDataType, PetscTruth *) |
PetscErrorCode | RetrieveQuantity (AnaModNumericalProblem, char *, char *, AnalysisItem *, PetscTruth *) |
PetscErrorCode | RetrieveQuantityByID (AnaModNumericalProblem, int, int, AnalysisItem *, PetscTruth *) |
PetscErrorCode | QuantityAsString (AnalysisItem *, AnalysisDataType, char **) |
PetscErrorCode | AnaModOptionsHandling (void) |
PetscErrorCode | AnaModShowOptions (MPI_Comm) |
PetscErrorCode | DeclareCategoryOptionFunction (char *cat, PetscErrorCode(*f)(char *)) |
PetscErrorCode | GetCategoryOptionFunction (char *cat, PetscErrorCode(**f)(char *)) |
PetscErrorCode | AnaModHasForcedSequentialComputation (PetscTruth *) |
PetscErrorCode | AnaModHasForcedExpensiveComputation (PetscTruth *) |
PetscErrorCode | AnaModGetSequentialMatrix (Mat A, Mat *Awork, PetscTruth *mem, PetscTruth *local, PetscTruth *global) |
PetscErrorCode | AnaModDeclareTraceFunction (PetscErrorCode(*)(void *, char *, va_list)) |
PetscErrorCode | AnaModDeclareTraceContext (void *) |
PetscErrorCode | AnaModTraceMessage (const char *fmt,...) |
PetscErrorCode | AnaModHasTrace (PetscTruth *flg) |
PetscErrorCode | AnaModSetTraceArrays (PetscTruth f) |
PetscErrorCode | AnaModTraceArrays (PetscTruth *f) |
PetscErrorCode | TabReportModules (Mat, char **, char **, int) |
PetscErrorCode | PurgeAttachedArrays (Mat A) |
PetscErrorCode | NewFeatureSet (FeatureSet *) |
PetscErrorCode | DeleteFeatureSet (FeatureSet) |
PetscErrorCode | AddToFeatureSet (FeatureSet, char *, char *, int *) |
PetscErrorCode | NewFeatureValues (FeatureValues *) |
PetscErrorCode | DeleteFeatureValues (FeatureValues) |
PetscErrorCode | InstantiateFeatureSet (AnaModNumericalProblem, FeatureSet, FeatureValues) |
PetscErrorCode | GetFeatureValue (FeatureValues, int, AnalysisItem *, PetscTruth *) |
PetscErrorCode | AnaModSetRetrievalFunction (PetscErrorCode(*)(void *, char *, char *, AnalysisItem *, AnalysisDataType *, PetscTruth *)) |
PetscErrorCode | AnaModGetRetrievalFunction (PetscErrorCode(**)(void *, char *, char *, AnalysisItem *, AnalysisDataType *, PetscTruth *), PetscTruth *) |
PetscErrorCode | CreateIntArray (const char *, int, IntArray *) |
PetscErrorCode | DeleteIntArray (IntArray) |
PetscErrorCode | IntArrayAdd (IntArray, int, int *) |
PetscErrorCode | IntArraySetAt (IntArray, int, int) |
PetscErrorCode | IntArrayTryGetAt (IntArray, int, int *, PetscTruth *) |
PetscErrorCode | IntArrayGetAt (IntArray, int, int *) |
PetscErrorCode | IntArrayGetFill (IntArray, int *) |
PetscErrorCode | CreateStringArray (const char *, int, StringArray *) |
PetscErrorCode | DeleteStringArray (StringArray) |
PetscErrorCode | StringArrayAdd (StringArray, char *, int *) |
PetscErrorCode | StringArraySetAt (StringArray, int, char *) |
PetscErrorCode | StringArrayTryGetAt (StringArray, int, char **, PetscTruth *) |
PetscErrorCode | StringArrayGetAt (StringArray, int, char **) |
PetscErrorCode | StringArrayGetFill (StringArray, int *) |
PetscErrorCode | CreateAnalysisItemArray (char *, int, AnalysisItemArray *) |
PetscErrorCode | DeleteAnalysisItemArray (AnalysisItemArray) |
PetscErrorCode | AnalysisItemArrayAdd (AnalysisItemArray, AnalysisItem, int *) |
PetscErrorCode | AnalysisItemArraySetAt (AnalysisItemArray, int, AnalysisItem) |
PetscErrorCode | AnalysisItemArrayTryGetAt (AnalysisItemArray, int, AnalysisItem *, PetscTruth *) |
PetscErrorCode | AnalysisItemArrayGetAt (AnalysisItemArray, int, AnalysisItem *) |
PetscErrorCode | CreateAnalysisDataTypeArray (char *, int, AnalysisDataTypeArray *) |
PetscErrorCode | DeleteAnalysisDataTypeArray (AnalysisDataTypeArray) |
PetscErrorCode | AnalysisDataTypeArrayAdd (AnalysisDataTypeArray, AnalysisDataType, int *) |
PetscErrorCode | AnalysisDataTypeArraySetAt (AnalysisDataTypeArray, int, AnalysisDataType) |
PetscErrorCode | AnalysisDataTypeArrayTryGetAt (AnalysisDataTypeArray, int, AnalysisDataType *, PetscTruth *) |
PetscErrorCode | AnalysisDataTypeArrayGetAt (AnalysisDataTypeArray, int, AnalysisDataType *) |
PetscErrorCode | CategoryLogEventRegister (char *cat, int icat) |
This file defines the functions for defining and querying analysis modules.
Definition in file anamod.h.
#define ANAMOD_FORMAT_VERSION "1.0" |
#define ANAMODCHECKVALID | ( | i, | |||
c, | |||||
s | ) | {if (!i) SETERRQ(1,"Null pointer"); if (i->cookie!=c) SETERRQ1(1,"Not a valid <%s>",s);} |
#define HASTOEXIST | ( | h | ) |
Value:
if (!h) { \ printf("ERROR asking for unknown module\n"); \ PetscFunctionReturn(1); \ }
Definition at line 16 of file anamod.h.
Referenced by AvgDiagDist(), AvgDistFromDiag(), AvgNnzpRow(), BlockSize(), ColourOffsets(), Colours(), ColourSizes(), ColVariability(), Commutator(), compute_dd(), compute_dummy_rows(), compute_eigenvalues(), compute_ellipse_from_Ritz_values(), compute_icm_splits(), compute_nnz_structure(), compute_posdiag(), compute_singularvalues(), compute_tracea2(), ComputeDiagonal(), computennz(), computetrace(), ComputeVariability(), Departure(), DepartureLee95(), DepartureLee96L(), DepartureLee96U(), DepartureRuhe75(), DiagDefinite(), DiagonalAverage(), DiagonalDominance(), DiagonalSign(), DiagonalVariance(), DiagZeroStart(), DummyRows(), DummyRowsKind(), eigenvaluecomp(), Kappa(), LBandWidth(), Lee95bounds(), Lee96bounds(), LeftSkyline(), LoBand(), MatCommutatorNormF(), MatSymmPartNormInf(), MaxEVbyImIm(), MaxEVbyImRe(), MaxEVbyMagIm(), MaxEVbyMagRe(), MaxEVbyRealIm(), MaxEVbyRealRe(), MaxNNonZerosPerRow(), MinEVbyMagIm(), MinEVbyMagRe(), MinNNonZerosPerRow(), NColours(), NDiags(), NDummyRows(), NNonZeros(), Nnz(), NnzDia(), NnzLow(), NnzUp(), norm1(), normF(), normInf(), NRitzValues(), nRows(), NSplits(), NUnstruct(), PosFraction(), RBandWidth(), regularblocks(), RelSymm(), RightSkyline(), RitzValuesC(), RitzValuesR(), RowVariability(), SigmaDiagDist(), SigmaMax(), SigmaMin(), SpectrumAX(), SpectrumAY(), SpectrumCX(), SpectrumCY(), Splits(), Symmetry(), SymmetryANorm(), SymmetryFANorm(), SymmetryFSNorm(), SymmetrySNorm(), Trace(), TraceA2(), TraceAbs(), UpBand(), and Version().
#define TRUTH | ( | x | ) | ( (x) ? PETSC_TRUE : PETSC_FALSE ) |
typedef struct FeatureSet_* FeatureSet |
typedef struct FeatureValues_* FeatureValues |
PetscErrorCode AddToFeatureSet | ( | FeatureSet | set, | |
char * | cat, | |||
char * | cmp, | |||
int * | idx | |||
) |
Add a requested feature to a featureset object. See Feature sets
Arguments:
set
: the featuresetcat
,cmp : the category and component name. It is an error to supply unknown namesidx
: the index under which the feature is known in this featureset. This index can be supplied to GetFeatureValue(). This parameter can be null. Definition at line 114 of file feature.c.
References CHECKVALIDFSET, name, and StringArrayAdd().
00115 { 00116 PetscErrorCode ierr; 00117 char *name; int l1,l2; 00118 PetscFunctionBegin; 00119 CHECKVALIDFSET(set); 00120 00121 l1 = strlen(cat); l2 = strlen(cmp); 00122 ierr = PetscMalloc((l1+l2+1)*sizeof(char),&name); CHKERRQ(ierr); 00123 sprintf(name,"%s/%s",cat,cmp); 00124 ierr = StringArrayAdd(set->features,name,idx); CHKERRQ(ierr); 00125 ierr = PetscFree(name); CHKERRQ(ierr); 00126 PetscFunctionReturn(0); 00127 }
PetscErrorCode AnalysisDataTypeArrayAdd | ( | AnalysisDataTypeArray | array, | |
AnalysisDataType | val, | |||
int * | idx | |||
) |
Add a new value and return the index. Right now we do not yet dynamically reallocate the array if there is no more space.
Definition at line 370 of file anamodutils.c.
References AnalysisDataTypeArray_::alloc, AnalysisDataTypeArray_::data, AnalysisDataTypeArray_::fill, and AnalysisDataTypeArray_::has.
00371 { 00372 int ins; 00373 PetscFunctionBegin; 00374 if (array->fill>=array->alloc-1) SETERRQ(1,"No more space"); 00375 ins = array->fill++; 00376 array->data[ins] = val; 00377 array->has[ins] = PETSC_TRUE; 00378 PetscFunctionReturn(0); 00379 }
PetscErrorCode AnalysisDataTypeArrayGetAt | ( | AnalysisDataTypeArray | array, | |
int | idx, | |||
AnalysisDataType * | val | |||
) |
As AnalysisDataTypeArrayTryGetAt(), except that it is an error to ask for an index where no value has been set.
Definition at line 422 of file anamodutils.c.
References AnalysisDataTypeArray_::alloc, AnalysisDataTypeArray_::data, and AnalysisDataTypeArray_::has.
00423 { 00424 PetscFunctionBegin; 00425 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00426 if (!array->has[idx]) SETERRQ1(1,"Asking for non-set element: %d",idx); 00427 *val = array->data[idx]; 00428 PetscFunctionReturn(0); 00429 }
PetscErrorCode AnalysisDataTypeArraySetAt | ( | AnalysisDataTypeArray | array, | |
int | idx, | |||
AnalysisDataType | val | |||
) |
Set a value at a given index. Right now we do not yet dynamically reallocate the array if the index is out of bound.
Definition at line 386 of file anamodutils.c.
References AnalysisDataTypeArray_::alloc, AnalysisDataTypeArray_::data, AnalysisDataTypeArray_::fill, and AnalysisDataTypeArray_::has.
Referenced by InstantiateFeatureSet().
00387 { 00388 PetscFunctionBegin; 00389 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00390 array->data[idx] = val; array->has[idx] = PETSC_TRUE; 00391 if (idx>array->fill) array->fill = idx; 00392 PetscFunctionReturn(0); 00393 }
PetscErrorCode AnalysisDataTypeArrayTryGetAt | ( | AnalysisDataTypeArray | array, | |
int | idx, | |||
AnalysisDataType * | val, | |||
PetscTruth * | has | |||
) |
Retrieve data from a given index.
Arguments:
array
: the AnalysisDataTypeArray objectidx
: the index; it is an error to ask out of bounds, but not to ask beyond the highest position filled; in that case failure will be reportedval
(output) : the value retrieved. This argument is allowed to be null.has
(output) : true if a value was stored at this index. This argument is allowed to be null. Definition at line 408 of file anamodutils.c.
References AnalysisDataTypeArray_::alloc, AnalysisDataTypeArray_::data, and AnalysisDataTypeArray_::has.
00409 { 00410 PetscFunctionBegin; 00411 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00412 if (has) *has = (PetscTruth)array->has[idx]; 00413 if (array->has[idx] && val) *val = array->data[idx]; 00414 PetscFunctionReturn(0); 00415 }
PetscErrorCode AnalysisItemArrayAdd | ( | AnalysisItemArray | array, | |
AnalysisItem | val, | |||
int * | idx | |||
) |
Add a new value and return the index. Right now we do not yet dynamically reallocate the array if there is no more space.
Definition at line 266 of file anamodutils.c.
References AnalysisItemArray_::alloc, AnalysisItemArray_::data, AnalysisItemArray_::fill, and AnalysisItemArray_::has.
00267 { 00268 int ins; 00269 PetscFunctionBegin; 00270 if (array->fill>=array->alloc-1) SETERRQ(1,"No more space"); 00271 ins = array->fill++; 00272 array->data[ins] = val; 00273 array->has[ins] = PETSC_TRUE; 00274 PetscFunctionReturn(0); 00275 }
PetscErrorCode AnalysisItemArrayGetAt | ( | AnalysisItemArray | array, | |
int | idx, | |||
AnalysisItem * | val | |||
) |
As AnalysisItemArrayTryGetAt(), except that it is an error to ask for an index where no value has been set.
Definition at line 318 of file anamodutils.c.
References AnalysisItemArray_::alloc, AnalysisItemArray_::data, and AnalysisItemArray_::has.
00319 { 00320 PetscFunctionBegin; 00321 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00322 if (!array->has[idx]) SETERRQ1(1,"Asking for non-set element: %d",idx); 00323 *val = array->data[idx]; 00324 PetscFunctionReturn(0); 00325 }
PetscErrorCode AnalysisItemArraySetAt | ( | AnalysisItemArray | array, | |
int | idx, | |||
AnalysisItem | val | |||
) |
Set a value at a given index. Right now we do not yet dynamically reallocate the array if the index is out of bound.
Definition at line 282 of file anamodutils.c.
References AnalysisItemArray_::alloc, AnalysisItemArray_::data, AnalysisItemArray_::fill, and AnalysisItemArray_::has.
Referenced by InstantiateFeatureSet().
00283 { 00284 PetscFunctionBegin; 00285 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00286 array->data[idx] = val; array->has[idx] = PETSC_TRUE; 00287 if (idx>array->fill) array->fill = idx; 00288 PetscFunctionReturn(0); 00289 }
PetscErrorCode AnalysisItemArrayTryGetAt | ( | AnalysisItemArray | array, | |
int | idx, | |||
AnalysisItem * | val, | |||
PetscTruth * | has | |||
) |
Retrieve data from a given index.
Arguments:
array
: the AnalysisItemArray objectidx
: the index; it is an error to ask out of bounds, but not to ask beyond the highest position filled; in that case failure will be reportedval
(output) : the value retrieved. This argument is allowed to be null.has
(output) : true if a value was stored at this index. This argument is allowed to be null. Definition at line 304 of file anamodutils.c.
References AnalysisItemArray_::alloc, AnalysisItemArray_::data, and AnalysisItemArray_::has.
Referenced by GetFeatureValue().
00305 { 00306 PetscFunctionBegin; 00307 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00308 if (has) *has = (PetscTruth)array->has[idx]; 00309 if (array->has[idx] && val) *val = array->data[idx]; 00310 PetscFunctionReturn(0); 00311 }
PetscErrorCode AnaModDeclareTraceContext | ( | void * | ) |
Definition at line 69 of file tracing.c.
References anamodtracectx.
00070 { 00071 PetscFunctionBegin; 00072 anamodtracectx = (size_t)ctx; 00073 PetscFunctionReturn(0); 00074 }
PetscErrorCode AnaModDeclareTraceFunction | ( | PetscErrorCode(*)(void *, char *, va_list) | fn | ) |
Specify a trace function.
The trace function has a prototype
PetscErrorCode tracefunction(void*,char*,va_list)
printf
. The first argument is a context, which can be set by AnaModDeclareTraceContext().Here is an example of how you would write a trace function:
#include <stdarg.h> PetscErrorCode tracefunction(void *ctx,char *fmt,va_list argp) { char *prefix = (char*)ctx; PetscFunctionBegin; printf("%s ",prefix); vprintf(fmt, argp); PetscFunctionReturn(0); }
string.h
(probably in /usr/include
) to see which "v" versions of printf
are available.You can undeclare a trace function by passing NULL.
Definition at line 56 of file tracing.c.
References anamodtrace.
00057 { 00058 PetscFunctionBegin; 00059 anamodtrace = fn; 00060 PetscFunctionReturn(0); 00061 }
PetscErrorCode AnaModFinalize | ( | ) |
PetscErrorCode AnaModGetRetrievalFunction | ( | PetscErrorCode(**)(void *, char *, char *, AnalysisItem *, AnalysisDataType *, PetscTruth *) | , | |
PetscTruth * | ||||
) |
Definition at line 229 of file feature.c.
References retriever.
Referenced by InstantiateFeatureSet().
00230 { 00231 PetscTruth has; 00232 PetscFunctionBegin; 00233 has = (PetscTruth)(retriever!=NULL); 00234 if (flg) *flg = has; 00235 if (has &&fun) *fun = retriever; 00236 PetscFunctionReturn(0); 00237 }
PetscErrorCode AnaModGetSequentialMatrix | ( | Mat | A, | |
Mat * | Awork, | |||
PetscTruth * | mem, | |||
PetscTruth * | local, | |||
PetscTruth * | global | |||
) |
Collect the matrix on processor zero.
There is an implicit assumption here that processor zero is the one that will do the actual work.
Argument:
A
: input matrixAwork
: pointer to the sequential matrix, this can be a pointer to the original matrix if it was already sequential; it is NULL if no forced sequential computation is asked (see Commandline options)mem
: true if Awork
is newly allocatedlocal
: true if this processor needs to do the workglobal
: true if any processor does work; this condition is false in the case of a distributed matrix and no forced sequential operation Definition at line 154 of file options.c.
References AnaModHasForcedSequentialComputation().
Referenced by compute_tracea2(), MatCommutatorNormF(), and MatSymmPartNormInf().
00155 { 00156 MPI_Comm comm; const MatType type; int mytid; 00157 PetscTruth flg; PetscErrorCode ierr; 00158 PetscFunctionBegin; 00159 00160 ierr = PetscObjectGetComm((PetscObject)A,&comm); CHKERRQ(ierr); 00161 MPI_Comm_rank(comm,&mytid); 00162 ierr = MatGetType(A,&type); CHKERRQ(ierr); 00163 ierr = PetscStrcmp(type,MATSEQAIJ,&flg); CHKERRQ(ierr); 00164 if (flg) { 00165 *Awork = A; *mem = PETSC_FALSE; 00166 *local = PETSC_TRUE; *global = PETSC_TRUE; 00167 } else { 00168 ierr = AnaModHasForcedSequentialComputation(&flg); CHKERRQ(ierr); 00169 if (!flg) { 00170 *Awork = NULL; 00171 *mem = PETSC_FALSE; *local = PETSC_FALSE; *global = PETSC_FALSE; 00172 PetscFunctionReturn(0); 00173 } 00174 *global = PETSC_TRUE; 00175 { 00176 Mat *Arow; IS is[1]; int N,M; 00177 ierr = MatGetSize(A,&M,&N); CHKERRQ(ierr); 00178 if (mytid==0) { 00179 ierr = ISCreateStride(MPI_COMM_SELF,M,0,1,is); CHKERRQ(ierr); 00180 *local = PETSC_TRUE; 00181 } else { 00182 ierr = ISCreateStride(MPI_COMM_SELF,0,0,1,is); CHKERRQ(ierr); 00183 *local = PETSC_FALSE; 00184 } 00185 ierr = MatGetSubMatrices 00186 (A,1,is,is,MAT_INITIAL_MATRIX,&Arow); CHKERRQ(ierr); 00187 ierr = ISDestroy(is[0]); CHKERRQ(ierr); 00188 *Awork = Arow[0]; *mem = PETSC_TRUE; 00189 } 00190 } 00191 PetscFunctionReturn(0); 00192 }
PetscErrorCode AnaModGetTypeMySQLName | ( | int | id, | |
char ** | name | |||
) |
Definition at line 372 of file module_functions.c.
References AnaModIsInitialized, anamodtypenames, mysqlname, and nAnaModTypeNames.
Referenced by main().
00373 { 00374 int i; 00375 PetscFunctionBegin; 00376 if (AnaModIsInitialized<1) 00377 SETERRQ(1,"AnaMod has not been not formally initialized.\nInsert a call to AnaModInitialize() in your code"); 00378 for (i=0; i<nAnaModTypeNames; i++) { 00379 if (id==anamodtypenames[i].id) { 00380 *name = (char*)anamodtypenames[i].mysqlname; goto exit; 00381 } 00382 } 00383 SETERRQ1(1,"Unknown AnaMod datatype %d",id); 00384 exit: 00385 PetscFunctionReturn(0); 00386 }
PetscErrorCode AnaModGetTypeName | ( | int | id, | |
char ** | name | |||
) |
Definition at line 356 of file module_functions.c.
References anamodtypenames, and nAnaModTypeNames.
00357 { 00358 int i; 00359 PetscFunctionBegin; 00360 for (i=0; i<nAnaModTypeNames; i++) { 00361 if (id==anamodtypenames[i].id) { 00362 *name = (char*)anamodtypenames[i].name; goto exit; 00363 } 00364 } 00365 SETERRQ1(1,"Unknown AnaMod datatype %d",id); 00366 exit: 00367 PetscFunctionReturn(0); 00368 }
PetscErrorCode AnaModHasForcedExpensiveComputation | ( | PetscTruth * | flg | ) |
Query whether certain expensive operations should be done regardless the cost.
Definition at line 200 of file options.c.
References expensive.
Referenced by MatCommutatorNormF_seq().
00201 { 00202 PetscFunctionBegin; 00203 *flg = expensive; 00204 PetscFunctionReturn(0); 00205 }
PetscErrorCode AnaModHasForcedSequentialComputation | ( | PetscTruth * | flg | ) |
Query whether parallel modules should be done on processor zero.
Definition at line 127 of file options.c.
References single_proc.
Referenced by AnaModGetSequentialMatrix().
00128 { 00129 PetscFunctionBegin; 00130 *flg = single_proc; 00131 PetscFunctionReturn(0); 00132 }
PetscErrorCode AnaModHasTrace | ( | PetscTruth * | flg | ) |
Test whether a trace function has been declared; see AnaModDeclareTraceFunction(). Normally you would use AnaModTraceMessage() which performs this test internally, but this function can be useful if a large amount of processing has to be performed to construct the trace message to begin with.
Definition at line 127 of file tracing.c.
References anamodtrace.
Referenced by ComputeQuantity(), and RetrieveQuantity().
00128 { 00129 PetscFunctionBegin; 00130 if (anamodtrace) 00131 *flg = PETSC_TRUE; 00132 else 00133 *flg = PETSC_FALSE; 00134 PetscFunctionReturn(0); 00135 }
PetscErrorCode AnaModInitialize | ( | ) |
Definition at line 319 of file module_functions.c.
References AnaModIsInitialized, anamodtypenames, and nAnaModTypeNames.
Referenced by main().
00320 { 00321 PetscFunctionBegin; 00322 anamodtypenames[0].id = NMDString; 00323 anamodtypenames[0].name="string"; 00324 anamodtypenames[0].mysqlname="VARCHAR(256)"; 00325 00326 anamodtypenames[1].id = NMDInt; 00327 anamodtypenames[1].name="int"; 00328 anamodtypenames[1].mysqlname="INTEGER"; 00329 00330 anamodtypenames[2].id = NMDReal; 00331 anamodtypenames[2].name="real"; 00332 anamodtypenames[2].mysqlname="DOUBLE"; 00333 00334 anamodtypenames[3].id = NMDIntarray; 00335 anamodtypenames[3].name="intarray"; 00336 anamodtypenames[3].mysqlname="VARCHAR(1024)"; 00337 00338 anamodtypenames[4].id = NMDRealarray; 00339 anamodtypenames[4].name="realarray"; 00340 anamodtypenames[4].mysqlname="VARCHAR(1024)"; 00341 00342 AnaModIsInitialized = 1; nAnaModTypeNames = 5; 00343 PetscFunctionReturn(0); 00344 }
PetscErrorCode AnaModOptionsHandling | ( | void | ) |
Process any commandline options that were given for AnaMod. These use the regular Petsc commandline options database.
This routine handles general options and module-specific options, so it has to be called after all modules have been declared.
See DeclareCategoryOptionFunction(),GetCategoryOptionFunction(), AnaModOptionsHandling() and section Commandline Options for Runtime Control.
Definition at line 38 of file options.c.
References categories, expensive, GetCategories(), GetCategoryOptionFunction(), single_proc, and VALUELEN.
00039 { 00040 PetscTruth flg; PetscErrorCode ierr; 00041 char *value; 00042 PetscFunctionBegin; 00043 00044 #define VALUELEN 150 00045 ierr = PetscMalloc(VALUELEN*sizeof(char),&value); CHKERRQ(ierr); 00046 00047 { 00048 ierr = PetscOptionsHasName(PETSC_NULL,"-anamod_force",&flg); CHKERRQ(ierr); 00049 if (flg) { 00050 ierr = PetscOptionsGetString 00051 (PETSC_NULL,"-anamod_force",value,VALUELEN,&flg); CHKERRQ(ierr); 00052 if (flg) { 00053 char *c; 00054 c = strtok(value,","); 00055 while (c) { 00056 ierr = PetscStrcmp(c,"sequential",&flg); CHKERRQ(ierr); 00057 if (flg) single_proc = PETSC_TRUE; 00058 ierr = PetscStrcmp(c,"expensive",&flg); CHKERRQ(ierr); 00059 if (flg) expensive = PETSC_TRUE; 00060 c = strtok(NULL,","); 00061 } 00062 } 00063 } 00064 } 00065 00066 { 00067 char **categories,*option; int icat,ncats; 00068 ierr = PetscMalloc(30*sizeof(char),&option); CHKERRQ(ierr); 00069 ierr = GetCategories(&categories,&ncats); CHKERRQ(ierr); 00070 for (icat=0; icat<ncats; icat++) { 00071 ierr = PetscMemzero(value,VALUELEN*sizeof(char)); CHKERRQ(ierr); 00072 ierr = PetscMemzero(option,30*sizeof(char)); CHKERRQ(ierr); 00073 sprintf(option,"-anamod_%s",categories[icat]); 00074 ierr = PetscOptionsGetString 00075 (PETSC_NULL,option,value,VALUELEN,&flg); CHKERRQ(ierr); 00076 if (flg) { 00077 PetscErrorCode (*f)(char*); 00078 ierr = GetCategoryOptionFunction(categories[icat],&f); CHKERRQ(ierr); 00079 if (f) { 00080 ierr = (*f)(value); CHKERRQ(ierr); 00081 } 00082 } 00083 } 00084 ierr = PetscFree(option); CHKERRQ(ierr); 00085 } 00086 00087 ierr = PetscFree(value); CHKERRQ(ierr); 00088 00089 PetscFunctionReturn(0); 00090 }
PetscErrorCode AnaModRegisterStandardModules | ( | ) |
Register all standard and nonstandard analysis modules.
Definition at line 44 of file anamodsalsa.c.
References RegisterIprsModules(), RegisterJPLModules(), RegisterLapackModules(), RegisterNormalityModules(), RegisterSimpleModules(), RegisterSpectrumModules(), RegisterStructureModules(), and RegisterVarianceModules().
00045 { 00046 PetscErrorCode ierr; 00047 PetscFunctionBegin; 00048 00049 /* standard set */ 00050 ierr = RegisterSimpleModules(); CHKERRQ(ierr); 00051 ierr = RegisterVarianceModules(); CHKERRQ(ierr); 00052 ierr = RegisterStructureModules(); CHKERRQ(ierr); 00053 ierr = RegisterSpectrumModules(); CHKERRQ(ierr); 00054 ierr = RegisterNormalityModules(); CHKERRQ(ierr); 00055 CHKMEMQ; 00056 00057 /* UKY iprs set */ 00058 ierr = RegisterIprsModules(); CHKERRQ(ierr); 00059 00060 /* Eijkhout's ICMK */ 00061 /*ierr = RegisterICMKModules(); CHKERRQ(ierr);*/ 00062 00063 #if defined(HAVE_LAPACK) 00064 /* Lapack eigenvalue calculations */ 00065 ierr = RegisterLapackModules(); CHKERRQ(ierr); 00066 #endif 00067 00068 /* Jones/Plassmann multi-colouring */ 00069 ierr = RegisterJPLModules(); CHKERRQ(ierr); 00070 CHKMEMQ; 00071 00072 PetscFunctionReturn(0); 00073 }
PetscErrorCode AnaModSetRetrievalFunction | ( | PetscErrorCode(*)(void *, char *, char *, AnalysisItem *, AnalysisDataType *, PetscTruth *) | ) |
PetscErrorCode AnaModSetTraceArrays | ( | PetscTruth | f | ) |
Definition at line 82 of file tracing.c.
References anamodtracearrays.
00083 { 00084 PetscFunctionBegin; 00085 anamodtracearrays = f; 00086 PetscFunctionReturn(0); 00087 }
PetscErrorCode AnaModShowOptions | ( | MPI_Comm | comm | ) |
Display all available options. This depends on the installed modules, so you need to do the various register calls first. See Use of the analysis modules.
For options see Commandline Options for Runtime Control.
Definition at line 99 of file options.c.
References categories, and GetCategories().
00100 { 00101 PetscErrorCode ierr; 00102 PetscFunctionBegin; 00103 PetscPrintf(comm,"Available AnaMod options\n Global:\n"); 00104 PetscPrintf(comm," -anamod_force sequential : do sequential computations\n even in parallel runs\n"); 00105 PetscPrintf(comm," -anamod_force expensive : do certain calculations no matter how expensive\n"); 00106 PetscPrintf(comm,"\n Categories and modules:\n"); 00107 { 00108 char **categories,*option; int icat,ncats; 00109 ierr = PetscMalloc(30*sizeof(char),&option); CHKERRQ(ierr); 00110 ierr = GetCategories(&categories,&ncats); CHKERRQ(ierr); 00111 for (icat=0; icat<ncats; icat++) { 00112 ierr = PetscMemzero(option,30*sizeof(char)); CHKERRQ(ierr); 00113 PetscPrintf 00114 (comm," -anamod_%s : options for category %s\n", 00115 categories[icat],categories[icat]); 00116 } 00117 ierr = PetscFree(option); CHKERRQ(ierr); 00118 } 00119 PetscFunctionReturn(0); 00120 }
PetscErrorCode AnaModTraceArrays | ( | PetscTruth * | f | ) |
Definition at line 95 of file tracing.c.
References anamodtracearrays.
Referenced by ComputeQuantity(), ReportAnamodContent(), and RetrieveQuantity().
00096 { 00097 PetscFunctionBegin; 00098 *f = anamodtracearrays; 00099 PetscFunctionReturn(0); 00100 }
PetscErrorCode AnaModTraceMessage | ( | const char * | fmt, | |
... | ||||
) |
This function prints a trace message if a trace function has been declared; see AnaModDeclareTraceFunction().
Definition at line 107 of file tracing.c.
References anamodtrace, and anamodtracectx.
Referenced by compute_eigenvalues_petsc(), ComputeQuantity(), and RetrieveQuantity().
00108 { 00109 va_list argp; PetscErrorCode ierr; 00110 PetscFunctionBegin; 00111 if (anamodtrace) { 00112 va_start(argp, fmt); 00113 ierr = (*anamodtrace)((void*)anamodtracectx,(char*)fmt,argp); CHKERRQ(ierr); 00114 va_end(argp); 00115 } 00116 PetscFunctionReturn(0); 00117 }
PetscErrorCode CategoryGetModules | ( | char * | cat, | |
char *** | ms, | |||
AnalysisDataType ** | t, | |||
int ** | id, | |||
int * | n | |||
) |
Query the modules in a specified category.
The category name has to exist. The routine will call the Petsc error handler if the name is invalid.
Parameters:
cat
: the category that is being queriedms
(optional) : the names of the modules in the categoryt
(optional) : the corresponding list of datatypesid
(optional) : the list of module IDs (see RetrieveQuantityByID())n
(optional) : the number of modules in the categorySee also GetCategories() and HasComputeCategory().
Definition at line 711 of file module_functions.c.
References categories, components, ids, ncategories, ncomponents, and types.
Referenced by analyze_matrix(), main(), and ReportAnamodContent().
00712 { 00713 int i; PetscErrorCode ierr; 00714 PetscFunctionBegin; 00715 *ms = NULL; *n = 0; 00716 for (i=0; i<ncategories; i++) { 00717 PetscTruth flg; 00718 ierr = PetscStrcmp(cat,categories[i],&flg); CHKERRQ(ierr); 00719 if (flg) { 00720 if (ms) *ms = components[i]; 00721 if (t) *t = types[i]; 00722 if (id) *id = ids[i]; 00723 if (n) *n = ncomponents[i]; 00724 PetscFunctionReturn(0); 00725 } 00726 } 00727 SETERRQ1(1,"Unknown category <%s>\n",cat); 00728 }
PetscErrorCode CategoryLogEventRegister | ( | char * | cat, | |
int | icat | |||
) |
Definition at line 20 of file logging.c.
00021 { 00022 PetscLogEvent catevent; PetscCookie cookie; PetscErrorCode ierr; 00023 PetscFunctionBegin; 00024 ierr = PetscCookieRegister("Anamod events",&cookie); CHKERRQ(ierr); 00025 ierr = PetscLogEventRegister(cat,cookie,&catevent); CHKERRQ(ierr); 00026 // catevents[icat] = catevent; 00027 PetscFunctionReturn(0); 00028 }
PetscErrorCode ComputeQuantity | ( | AnaModNumericalProblem | prob, | |
const char * | cat, | |||
const char * | cmp, | |||
AnalysisItem * | res, | |||
int * | rreslen, | |||
PetscTruth * | success | |||
) |
Compute a computational module from a certain category.
Argument:
"(AnalysisItem*)&res"
; see types for the definition of the AnalysisItem data typeA call to this routine need not involve actual computation: the requested quantity can already be attached to the matrix object (see attached quantities for details). This mechanism is used in all the standard modules that come with the AnaMod package.
The workings of this function can be traced by specifying a trace function; see Tracing the analysis modules.
Definition at line 866 of file module_functions.c.
References ANALYSISINTARRAY, AnaModHasTrace(), AnaModTraceArrays(), AnaModTraceMessage(), GetCategoryIndex(), GetModuleIndex(), hasval, modules, QuantityAsString(), TYPEii, and types.
Referenced by analyze_matrix(), DepartureRuhe75(), LoBand(), MatrixComputeQuantity(), MaxEVbyImIm(), MaxEVbyImRe(), MaxEVbyMagIm(), MaxEVbyMagRe(), MaxEVbyRealIm(), MaxEVbyRealRe(), MinEVbyMagIm(), MinEVbyMagRe(), RelSymm(), and UpBand().
00868 { 00869 PetscTruth flg,trace; 00870 int icat,icmp,reslen; PetscErrorCode ierr; 00871 00872 PetscFunctionBegin; 00873 00874 /* 00875 * Get the location of the module for this quantity 00876 */ 00877 ierr = GetCategoryIndex((char*)cat,&icat,&flg); CHKERRQ(ierr); 00878 if (!flg) 00879 SETERRQ1(1,"Could not find category <%s>",cat); 00880 ierr = GetModuleIndex(icat,(char*)cmp,&icmp,&flg); CHKERRQ(ierr); 00881 if (!flg) 00882 SETERRQ2(1,"Could not find module <%s:%s>",cat,cmp); 00883 00884 /* 00885 * Compute 00886 */ 00887 if (modules[icat][icmp]) { 00888 ierr = (modules[icat][icmp])(prob,res,&reslen,&flg); CHKERRQ(ierr); 00889 } else flg = PETSC_FALSE; 00890 00891 hasval[icat][icmp] = flg; 00892 00893 if (!flg) goto nosuccess; 00894 /* 00895 * Tracing 00896 */ 00897 ierr = AnaModHasTrace(&trace); CHKERRQ(ierr); 00898 if (trace) { 00899 if (flg) { 00900 char *string; PetscTruth trace_arrays; 00901 AnalysisDataType t = TYPEii(icat,icmp); 00902 00903 ierr = AnaModTraceArrays(&trace_arrays); CHKERRQ(ierr); 00904 if (t<ANALYSISINTARRAY || trace_arrays) { 00905 ierr = QuantityAsString 00906 (res,types[icat][icmp],&string); CHKERRQ(ierr); 00907 ierr = AnaModTraceMessage 00908 ("Anamod computed <%s:%s> = <%s>\n",cat,cmp,string); CHKERRQ(ierr); 00909 ierr = PetscFree(string); CHKERRQ(ierr); 00910 } 00911 } else { 00912 ierr = AnaModTraceMessage 00913 ("Anamod failed to compute <%s:%s>\n",cat,cmp); CHKERRQ(ierr); 00914 } 00915 } 00916 00917 if (rreslen) *rreslen = reslen; 00918 nosuccess: 00919 if (success) *success = flg; 00920 00921 PetscFunctionReturn(0); 00922 }
PetscErrorCode ComputeQuantityByID | ( | AnaModNumericalProblem | , | |
int | , | |||
int | , | |||
AnalysisItem * | , | |||
int * | , | |||
PetscTruth * | ||||
) |
PetscErrorCode CreateAnalysisDataTypeArray | ( | char * | , | |
int | , | |||
AnalysisDataTypeArray * | ||||
) |
Definition at line 336 of file anamodutils.c.
References AnalysisDataTypeArray_::alloc, AnalysisDataTypeArray_::data, AnalysisDataTypeArray_::fill, AnalysisDataTypeArray_::has, NALLOC, and AnalysisDataTypeArray_::name.
Referenced by NewFeatureValues().
00337 { 00338 AnalysisDataTypeArray anew; PetscErrorCode ierr; 00339 PetscFunctionBegin; 00340 ierr = PetscMalloc(sizeof(struct AnalysisDataTypeArray_),&anew); CHKERRQ(ierr); 00341 ierr = PetscMemzero(anew,sizeof(struct AnalysisDataTypeArray_)); CHKERRQ(ierr); 00342 if (name) anew->name = strdup(name); 00343 anew->fill = 0; anew->alloc = NALLOC; 00344 ierr = PetscMalloc(anew->alloc*sizeof(PetscTruth),&(anew->has)); CHKERRQ(ierr); 00345 ierr = PetscMemzero(anew->has,anew->alloc*sizeof(PetscTruth)); CHKERRQ(ierr); 00346 ierr = PetscMalloc(anew->alloc*sizeof(AnalysisDataType),&(anew->data)); CHKERRQ(ierr); 00347 ierr = PetscMemzero(anew->data,anew->alloc*sizeof(AnalysisDataType)); CHKERRQ(ierr); 00348 *array = anew; 00349 PetscFunctionReturn(0); 00350 }
PetscErrorCode CreateAnalysisItemArray | ( | char * | , | |
int | , | |||
AnalysisItemArray * | ||||
) |
Definition at line 232 of file anamodutils.c.
References AnalysisItemArray_::alloc, AnalysisItemArray_::data, AnalysisItemArray_::fill, AnalysisItemArray_::has, NALLOC, and AnalysisItemArray_::name.
Referenced by NewFeatureValues().
00233 { 00234 AnalysisItemArray anew; PetscErrorCode ierr; 00235 PetscFunctionBegin; 00236 ierr = PetscMalloc(sizeof(struct AnalysisItemArray_),&anew); CHKERRQ(ierr); 00237 ierr = PetscMemzero(anew,sizeof(struct AnalysisItemArray_)); CHKERRQ(ierr); 00238 if (name) anew->name = strdup(name); 00239 anew->fill = 0; anew->alloc = NALLOC; 00240 ierr = PetscMalloc(anew->alloc*sizeof(PetscTruth),&(anew->has)); CHKERRQ(ierr); 00241 ierr = PetscMemzero(anew->has,anew->alloc*sizeof(PetscTruth)); CHKERRQ(ierr); 00242 ierr = PetscMalloc(anew->alloc*sizeof(AnalysisItem),&(anew->data)); CHKERRQ(ierr); 00243 ierr = PetscMemzero(anew->data,anew->alloc*sizeof(AnalysisItem)); CHKERRQ(ierr); 00244 *array = anew; 00245 PetscFunctionReturn(0); 00246 }
PetscErrorCode CreateIntArray | ( | const char * | , | |
int | , | |||
IntArray * | ||||
) |
Definition at line 13 of file anamodutils.c.
References IntArray_::alloc, IntArray_::data, IntArray_::fill, IntArray_::has, NALLOC, and IntArray_::name.
Referenced by NewFeatureSet().
00014 { 00015 IntArray inew; PetscErrorCode ierr; 00016 PetscFunctionBegin; 00017 ierr = PetscMalloc(sizeof(struct IntArray_),&inew); CHKERRQ(ierr); 00018 ierr = PetscMemzero(inew,sizeof(struct IntArray_)); CHKERRQ(ierr); 00019 if (name) inew->name = strdup(name); 00020 inew->fill = 0; inew->alloc = NALLOC; 00021 ierr = PetscMalloc(inew->alloc*sizeof(PetscTruth),&(inew->has)); CHKERRQ(ierr); 00022 ierr = PetscMemzero(inew->has,inew->alloc*sizeof(PetscTruth)); CHKERRQ(ierr); 00023 ierr = PetscMalloc(inew->alloc*sizeof(int),&(inew->data)); CHKERRQ(ierr); 00024 ierr = PetscMemzero(inew->data,inew->alloc*sizeof(int)); CHKERRQ(ierr); 00025 *array = inew; 00026 PetscFunctionReturn(0); 00027 }
PetscErrorCode CreateStringArray | ( | const char * | , | |
int | , | |||
StringArray * | ||||
) |
Definition at line 117 of file anamodutils.c.
References StringArray_::alloc, StringArray_::data, StringArray_::fill, StringArray_::has, NALLOC, and StringArray_::name.
Referenced by NewFeatureSet().
00118 { 00119 StringArray snew; PetscErrorCode ierr; 00120 PetscFunctionBegin; 00121 ierr = PetscMalloc(sizeof(struct StringArray_),&snew); CHKERRQ(ierr); 00122 ierr = PetscMemzero(snew,sizeof(struct StringArray_)); CHKERRQ(ierr); 00123 if (name) snew->name = strdup(name); 00124 snew->fill = 0; snew->alloc = NALLOC; 00125 ierr = PetscMalloc(snew->alloc*sizeof(PetscTruth),&(snew->has)); CHKERRQ(ierr); 00126 ierr = PetscMemzero(snew->has,snew->alloc*sizeof(PetscTruth)); CHKERRQ(ierr); 00127 ierr = PetscMalloc(snew->alloc*sizeof(char*),&(snew->data)); CHKERRQ(ierr); 00128 ierr = PetscMemzero(snew->data,snew->alloc*sizeof(char*)); CHKERRQ(ierr); 00129 *array = snew; 00130 PetscFunctionReturn(0); 00131 }
PetscErrorCode DeclareCategoryOptionFunction | ( | char * | cat, | |
PetscErrorCode(*)(char *) | f | |||
) |
This function allows the module developer to give the user commandline options for control of a module.
See DeclareCategoryOptionFunction(),GetCategoryOptionFunction(), AnaModOptionsHandling() and section Commandline Options for Runtime Control.
Definition at line 807 of file module_functions.c.
References GetCategoryIndex(), and optionfunctions.
Referenced by RegisterSpectrumModules().
00808 { 00809 PetscTruth flg; int icat; PetscErrorCode ierr; 00810 PetscFunctionBegin; 00811 ierr = GetCategoryIndex(cat,&icat,&flg); CHKERRQ(ierr); 00812 if (flg) { 00813 optionfunctions[icat] = f; 00814 } 00815 PetscFunctionReturn(0); 00816 }
PetscErrorCode DeleteAnalysisDataTypeArray | ( | AnalysisDataTypeArray | ) |
Definition at line 354 of file anamodutils.c.
References AnalysisDataTypeArray_::data, AnalysisDataTypeArray_::has, and AnalysisDataTypeArray_::name.
Referenced by DeleteFeatureValues().
00355 { 00356 PetscErrorCode ierr; 00357 PetscFunctionBegin; 00358 ierr = PetscFree(array->data); CHKERRQ(ierr); 00359 ierr = PetscFree(array->has); CHKERRQ(ierr); 00360 if (array->name) free(array->name); 00361 ierr = PetscFree(array); CHKERRQ(ierr); 00362 PetscFunctionReturn(0); 00363 }
PetscErrorCode DeleteAnalysisItemArray | ( | AnalysisItemArray | ) |
Definition at line 250 of file anamodutils.c.
References AnalysisItemArray_::data, AnalysisItemArray_::has, and AnalysisItemArray_::name.
Referenced by DeleteFeatureValues().
00251 { 00252 PetscErrorCode ierr; 00253 PetscFunctionBegin; 00254 ierr = PetscFree(array->data); CHKERRQ(ierr); 00255 ierr = PetscFree(array->has); CHKERRQ(ierr); 00256 if (array->name) free(array->name); 00257 ierr = PetscFree(array); CHKERRQ(ierr); 00258 PetscFunctionReturn(0); 00259 }
PetscErrorCode DeleteFeatureSet | ( | FeatureSet | set | ) |
Delete a featureset object. See Feature sets
Definition at line 90 of file feature.c.
References CHECKVALIDFSET, DeleteIntArray(), and DeleteStringArray().
00091 { 00092 PetscErrorCode ierr; 00093 PetscFunctionBegin; 00094 CHECKVALIDFSET(set); 00095 ierr = DeleteIntArray(set->IDs); CHKERRQ(ierr); 00096 ierr = DeleteStringArray(set->features); CHKERRQ(ierr); 00097 ierr = PetscFree(set); CHKERRQ(ierr); 00098 PetscFunctionReturn(0); 00099 }
PetscErrorCode DeleteFeatureValues | ( | FeatureValues | values | ) |
Free a featurevalues object. See Feature sets
Definition at line 148 of file feature.c.
References CHECKVALIDFVAL, DeleteAnalysisDataTypeArray(), DeleteAnalysisItemArray(), FeatureValues_::types, and FeatureValues_::values.
00149 { 00150 PetscErrorCode ierr; 00151 PetscFunctionBegin; 00152 CHECKVALIDFVAL(values); 00153 ierr = DeleteAnalysisItemArray(values->values); CHKERRQ(ierr); 00154 ierr = DeleteAnalysisDataTypeArray(values->types); CHKERRQ(ierr); 00155 ierr = PetscFree(values); CHKERRQ(ierr); 00156 PetscFunctionReturn(0); 00157 }
PetscErrorCode DeleteIntArray | ( | IntArray | ) |
Definition at line 31 of file anamodutils.c.
References IntArray_::data, IntArray_::has, and IntArray_::name.
Referenced by DeleteFeatureSet().
00032 { 00033 PetscErrorCode ierr; 00034 PetscFunctionBegin; 00035 ierr = PetscFree(array->data); CHKERRQ(ierr); 00036 ierr = PetscFree(array->has); CHKERRQ(ierr); 00037 if (array->name) free(array->name); 00038 ierr = PetscFree(array); CHKERRQ(ierr); 00039 PetscFunctionReturn(0); 00040 }
PetscErrorCode DeleteStringArray | ( | StringArray | ) |
Definition at line 135 of file anamodutils.c.
References StringArray_::data, StringArray_::fill, StringArray_::has, and StringArray_::name.
Referenced by DeleteFeatureSet().
00136 { 00137 int i; PetscErrorCode ierr; 00138 PetscFunctionBegin; 00139 for (i=0; i<array->fill; i++) 00140 if (array->has[i]) free(array->data[i]); 00141 ierr = PetscFree(array->data); CHKERRQ(ierr); 00142 ierr = PetscFree(array->has); CHKERRQ(ierr); 00143 if (array->name) free(array->name); 00144 ierr = PetscFree(array); CHKERRQ(ierr); 00145 PetscFunctionReturn(0); 00146 }
PetscErrorCode DeRegisterCategory | ( | char * | cat | ) |
Deallocate the storage for a particular category of analysis modules
Definition at line 612 of file module_functions.c.
References categories, components, hasval, ids, modules, ncategories, ncomponents, and types.
Referenced by DeregisterModules().
00613 { 00614 PetscTruth flg; int icat,i; PetscErrorCode ierr; 00615 PetscFunctionBegin; 00616 00617 flg = PETSC_FALSE; 00618 for (i=0; i<ncategories && !flg; i++) { 00619 ierr = PetscStrcmp(cat,categories[i],&flg); CHKERRQ(ierr); 00620 if (flg) { 00621 icat = i; goto found; 00622 } 00623 } 00624 SETERRQ(1,"Trying to deregister unknown category"); 00625 found: 00626 00627 for (i=0; i<ncomponents[icat]; i++) { 00628 ierr = PetscFree(components[icat][i]); CHKERRQ(ierr); 00629 } 00630 ierr = PetscFree(categories[icat]); CHKERRQ(ierr); 00631 ierr = PetscFree(components[icat]); CHKERRQ(ierr); 00632 ierr = PetscFree(modules[icat]); CHKERRQ(ierr); 00633 ierr = PetscFree(types[icat]); CHKERRQ(ierr); 00634 ierr = PetscFree(hasval[icat]); CHKERRQ(ierr); 00635 ierr = PetscFree(ids[icat]); CHKERRQ(ierr); 00636 00637 PetscFunctionReturn(0); 00638 }
PetscErrorCode DeregisterModules | ( | void | ) |
Definition at line 642 of file module_functions.c.
References categories, components, DeRegisterCategory(), GetCategories(), hasval, ids, maxcomponents, modules, ncategories, ncomponents, optionfunctions, and types.
00643 { 00644 int icat,ncat; char **cat; 00645 PetscErrorCode ierr; 00646 PetscFunctionBegin; 00647 00648 /* ierr = DeregisterSpectrumModules(); CHKERRQ(ierr); */ 00649 00650 ierr = GetCategories(&cat,&ncat); CHKERRQ(ierr); 00651 for (icat=0; icat<ncat; icat++) { 00652 ierr = DeRegisterCategory(cat[icat]); CHKERRQ(ierr); 00653 } 00654 ierr = PetscFree(categories); CHKERRQ(ierr); 00655 ncategories = 0; /* inelegant */ 00656 ierr = PetscFree(maxcomponents); CHKERRQ(ierr); 00657 ierr = PetscFree(ncomponents); CHKERRQ(ierr); 00658 ierr = PetscFree(components); CHKERRQ(ierr); 00659 ierr = PetscFree(types); CHKERRQ(ierr); 00660 ierr = PetscFree(modules); CHKERRQ(ierr); 00661 ierr = PetscFree(optionfunctions); CHKERRQ(ierr); 00662 ierr = PetscFree(hasval); CHKERRQ(ierr); 00663 ierr = PetscFree(ids); CHKERRQ(ierr); 00664 PetscFunctionReturn(0); 00665 }
PetscErrorCode GetCategories | ( | char *** | cats, | |
int * | n | |||
) |
Query the number of defined categories and their names.
Parameters:
cats
(optional) output: list of category namesn
output: number of currently installed categoriesSee also CategoryGetModules().
Definition at line 687 of file module_functions.c.
References categories, and ncategories.
Referenced by analyze_matrix(), AnaModOptionsHandling(), AnaModShowOptions(), DeregisterModules(), main(), and ReportAnamodContent().
00688 { 00689 PetscFunctionBegin; 00690 *n = ncategories; if (cats) *cats = categories; 00691 PetscFunctionReturn(0); 00692 }
PetscErrorCode GetCategoryOptionFunction | ( | char * | cat, | |
PetscErrorCode(**)(char *) | f | |||
) |
This function is called in AnaModOptionsHandling(). There is probably no reason for the user ever to call it.
See DeclareCategoryOptionFunction(),GetCategoryOptionFunction(), AnaModOptionsHandling() and section Commandline Options for Runtime Control.
Definition at line 827 of file module_functions.c.
References GetCategoryIndex(), and optionfunctions.
Referenced by AnaModOptionsHandling().
00828 { 00829 PetscTruth flg; int icat; PetscErrorCode ierr; 00830 PetscFunctionBegin; 00831 ierr = GetCategoryIndex(cat,&icat,&flg); CHKERRQ(ierr); 00832 if (flg) { 00833 *f = optionfunctions[icat]; 00834 } else *f = NULL; 00835 PetscFunctionReturn(0); 00836 }
PetscErrorCode GetDataID | ( | const char * | cat, | |
const char * | cmp, | |||
int * | id, | |||
PetscTruth * | flg | |||
) |
Get the numerical id under which a module is stored.
The flag parameter returns false if the category or cat/cmp does not exist. The flag parameter is optional, but the routine will exit if the cat/cmp is not found and the flag parameter is not provided.
This is not a user level function.
Definition at line 1164 of file module_functions.c.
References GetCategoryIndex(), GetModuleIndex(), and ids.
Referenced by AvgDiagDist(), AvgDistFromDiag(), AvgNnzpRow(), BlockSize(), ColourOffsets(), Colours(), ColourSizes(), ColVariability(), Commutator(), compute_dd(), compute_dummy_rows(), compute_eigenvalues(), compute_ellipse_from_Ritz_values(), compute_icm_splits(), compute_nnz_structure(), compute_posdiag(), compute_singularvalues(), compute_tracea2(), ComputeDiagonal(), computennz(), computetrace(), ComputeVariability(), Departure(), DepartureLee95(), DepartureLee96L(), DepartureLee96U(), DepartureRuhe75(), DiagDefinite(), DiagonalAverage(), DiagonalDominance(), DiagonalSign(), DiagonalVariance(), DiagZeroStart(), DummyRows(), DummyRowsKind(), eigenvaluecomp(), HasQuantity(), JonesPlassmannColouring(), Kappa(), LBandWidth(), Lee95bounds(), Lee96bounds(), LeftSkyline(), LoBand(), MatCommutatorNormF(), MatSymmPartNormInf(), MaxEVbyImIm(), MaxEVbyImRe(), MaxEVbyMagIm(), MaxEVbyMagRe(), MaxEVbyRealIm(), MaxEVbyRealRe(), MaxNNonZerosPerRow(), MinEVbyMagIm(), MinEVbyMagRe(), MinNNonZerosPerRow(), NColours(), NDiags(), NDummyRows(), NNonZeros(), Nnz(), NnzDia(), NnzLow(), NnzUp(), norm1(), normF(), normInf(), NRitzValues(), nRows(), NSplits(), NUnstruct(), PosFraction(), RBandWidth(), regularblocks(), RelSymm(), RightSkyline(), RitzValuesC(), RitzValuesR(), RowVariability(), SigmaDiagDist(), SigmaMax(), SigmaMin(), SpectrumAX(), SpectrumAY(), SpectrumCX(), SpectrumCY(), Splits(), Symmetry(), SymmetryANorm(), SymmetryFANorm(), SymmetryFSNorm(), SymmetrySNorm(), Trace(), TraceA2(), TraceAbs(), UpBand(), and Version().
01165 { 01166 PetscTruth f; int icat,icmp; PetscErrorCode ierr; 01167 PetscFunctionBegin; 01168 ierr = GetCategoryIndex((char*)cat,&icat,&f); CHKERRQ(ierr); 01169 if (!f) { 01170 goto out; 01171 } 01172 ierr = GetModuleIndex(icat,(char*)cmp,&icmp,&f); CHKERRQ(ierr); 01173 if (!f) { 01174 goto out; 01175 } 01176 *id = ids[icat][icmp]; 01177 out: 01178 if (flg) 01179 *flg = f; 01180 else if (!f) 01181 SETERRQ2(1,"cat/cmp <%s;%s> not found, but no flag give to report this", 01182 cat,cmp); 01183 PetscFunctionReturn(0); 01184 }
PetscErrorCode GetDataType | ( | const char * | cat, | |
const char * | cmp, | |||
AnalysisDataType * | t | |||
) |
Retrieve the AnalysisDataType
of a computational module
Definition at line 1191 of file module_functions.c.
References GetCategoryIndex(), GetModuleIndex(), and TYPEii.
Referenced by analyze_matrix(), and HasQuantity().
01192 { 01193 PetscTruth flg; int icat,icmp; PetscErrorCode ierr; 01194 PetscFunctionBegin; 01195 ierr = GetCategoryIndex((char*)cat,&icat,&flg); CHKERRQ(ierr); 01196 if (!flg) 01197 SETERRQ(1,"Could not find category"); 01198 ierr = GetModuleIndex(icat,(char*)cmp,&icmp,&flg); CHKERRQ(ierr); 01199 if (!flg) 01200 SETERRQ(1,"Could not find module"); 01201 *t = TYPEii(icat,icmp); 01202 PetscFunctionReturn(0); 01203 }
PetscErrorCode GetFeatureValue | ( | FeatureValues | values, | |
int | index, | |||
AnalysisItem * | val, | |||
PetscTruth * | f | |||
) |
Extract a value from a featurevalues object. See Feature sets.
Arguments:
values
: the FeatureValues object.index
: the index, as returned by AddToFeatureSet().val
(output) : the value; this argument can be null.f
(output) : indicates whether the return value was indeed preset in the featurevalues object; this argument can be null. Definition at line 206 of file feature.c.
References AnalysisItemArrayTryGetAt(), CHECKVALIDFVAL, and FeatureValues_::values.
00207 { 00208 PetscErrorCode ierr; 00209 PetscFunctionBegin; 00210 CHECKVALIDFVAL(values); 00211 ierr = AnalysisItemArrayTryGetAt(values->values,index,val,f); CHKERRQ(ierr); 00212 PetscFunctionReturn(0); 00213 }
PetscErrorCode HasComputeCategory | ( | char * | cat, | |
PetscTruth * | f | |||
) |
Query whether a specified category has been declared.
Definition at line 773 of file module_functions.c.
References GetCategoryIndex().
00774 { 00775 int icat; PetscErrorCode ierr; 00776 PetscFunctionBegin; 00777 ierr = GetCategoryIndex(cat,&icat,f); CHKERRQ(ierr); 00778 PetscFunctionReturn(0); 00779 }
PetscErrorCode HasComputeModule | ( | char * | cat, | |
char * | cmp, | |||
PetscTruth * | f | |||
) |
Query whether a specified module exists inside a specified category. The category need not itself have been declared.
Definition at line 787 of file module_functions.c.
References GetCategoryIndex(), and GetModuleIndex().
Referenced by LoBand(), and UpBand().
00788 { 00789 int icat,icmp; PetscErrorCode ierr; 00790 PetscFunctionBegin; 00791 ierr = GetCategoryIndex(cat,&icat,f); CHKERRQ(ierr); 00792 if (*f) { 00793 ierr = GetModuleIndex(icat,cmp,&icmp,f); CHKERRQ(ierr); 00794 } 00795 PetscFunctionReturn(0); 00796 }
PetscErrorCode HasQuantity | ( | AnaModNumericalProblem | prob, | |
char * | cat, | |||
char * | cmp, | |||
PetscTruth * | f | |||
) |
Check if a certain quantity is precomputed, meaning that it can be retrieved (with a call to ComputeQuantity()) at no computational cost.
The category and module names have to exist. The routine will call the Petsc error handler if either name is invalid. Use HasComputeModule() to test whether a category and module is known to the system.
See the page on attached quantities for an explanation of the mechanism behind this routine.
Definition at line 1017 of file module_functions.c.
References GetDataID(), GetDataType(), and HasQuantityByID().
Referenced by computennz().
01018 { 01019 AnalysisDataType t; int id; PetscErrorCode ierr; 01020 PetscFunctionBegin; 01021 ierr = GetDataID(cat,cmp,&id,f); CHKERRQ(ierr); 01022 if (!*f) 01023 SETERRQ2(1,">>>> Warning: undeclared module <%s:%s>\n",cat,cmp); 01024 ierr = GetDataType(cat,cmp,&t); CHKERRQ(ierr); 01025 ierr = HasQuantityByID(prob,id,t,f); CHKERRQ(ierr); 01026 PetscFunctionReturn(0); 01027 }
PetscErrorCode HasQuantityByID | ( | AnaModNumericalProblem | prob, | |
int | id, | |||
AnalysisDataType | type, | |||
PetscTruth * | f | |||
) |
Auxiliary routine with lookup by ID, which is much faster than by string indexing.
Definition at line 1035 of file module_functions.c.
References ANALYSISDBLARRAY, ANALYSISDOUBLE, ANALYSISINTARRAY, and ANALYSISINTEGER.
Referenced by HasQuantity().
01036 { 01037 Mat A = (Mat)prob; PetscReal rv,*rsv; int iv,*isv; 01038 PetscErrorCode ierr; 01039 PetscFunctionBegin; 01040 switch (type) { 01041 case ANALYSISINTEGER : 01042 ierr = PetscObjectComposedDataGetInt 01043 ((PetscObject)A,id,iv,*f); CHKERRQ(ierr); 01044 break; 01045 case ANALYSISDOUBLE : 01046 ierr = PetscObjectComposedDataGetReal 01047 ((PetscObject)A,id,rv,*f); CHKERRQ(ierr); 01048 break; 01049 case ANALYSISINTARRAY : 01050 ierr = PetscObjectComposedDataGetIntstar 01051 ((PetscObject)A,id,isv,*f); CHKERRQ(ierr); 01052 break; 01053 case ANALYSISDBLARRAY : 01054 ierr = PetscObjectComposedDataGetRealstar 01055 ((PetscObject)A,id,rsv,*f); CHKERRQ(ierr); 01056 break; 01057 default : SETERRQ1(1,"Unknown data type %d",type); 01058 } 01059 PetscFunctionReturn(0); 01060 }
PetscErrorCode InstantiateFeatureSet | ( | AnaModNumericalProblem | prob, | |
FeatureSet | set, | |||
FeatureValues | values | |||
) |
Fill in a featurevalues object. See Feature sets
Definition at line 163 of file feature.c.
References AnalysisDataTypeArraySetAt(), AnalysisItemArraySetAt(), AnaModGetRetrievalFunction(), CHECKVALIDFSET, CHECKVALIDFVAL, retriever, StringArrayGetAt(), StringArrayGetFill(), FeatureValues_::types, and FeatureValues_::values.
00164 { 00165 PetscErrorCode (*retriever) 00166 (void*,char*,char*,AnalysisItem*,AnalysisDataType*,PetscTruth*); 00167 int nval,ival; PetscTruth flg; PetscErrorCode ierr; 00168 PetscFunctionBegin; 00169 CHECKVALIDFSET(set); 00170 CHECKVALIDFVAL(values); 00171 ierr = AnaModGetRetrievalFunction(&retriever,&flg); CHKERRQ(ierr); 00172 if (!flg) PetscFunctionReturn(0); 00173 ierr = StringArrayGetFill(set->features,&nval); CHKERRQ(ierr); 00174 for (ival=0; ival<nval; ival++) { 00175 char *feature,*cat,*cmp; int l; 00176 AnalysisItem res; AnalysisDataType t; 00177 ierr = StringArrayGetAt(set->features,ival,&feature); CHKERRQ(ierr); 00178 for (l=0; l<strlen(feature); l++) { 00179 if (feature[l]=='/') { 00180 feature[l] = 0; cat = feature; cmp = feature+l+1; 00181 ierr = (*retriever)(prob,cat,cmp,&res,&t,&flg); CHKERRQ(ierr); 00182 if (flg) { 00183 ierr = AnalysisItemArraySetAt(values->values,ival,res); CHKERRQ(ierr); 00184 ierr = AnalysisDataTypeArraySetAt(values->types,ival,t); CHKERRQ(ierr); 00185 } 00186 feature[l] = '/'; break; 00187 } 00188 } 00189 } 00190 PetscFunctionReturn(0); 00191 }
PetscErrorCode IntArrayAdd | ( | IntArray | array, | |
int | val, | |||
int * | idx | |||
) |
Add a new value and return the index. Right now we do not yet dynamically reallocate the array if there is no more space.
Definition at line 47 of file anamodutils.c.
References IntArray_::alloc, IntArray_::data, IntArray_::fill, and IntArray_::has.
00048 { 00049 int ins; 00050 PetscFunctionBegin; 00051 if (array->fill>=array->alloc-1) SETERRQ(1,"No more space"); 00052 ins = array->fill++; 00053 array->data[ins] = val; 00054 array->has[ins] = PETSC_TRUE; 00055 PetscFunctionReturn(0); 00056 }
PetscErrorCode IntArrayGetAt | ( | IntArray | array, | |
int | idx, | |||
int * | val | |||
) |
As IntArrayTryGetAt(), except that it is an error to ask for an index where no value has been set.
Definition at line 99 of file anamodutils.c.
References IntArray_::alloc, IntArray_::data, and IntArray_::has.
00100 { 00101 PetscFunctionBegin; 00102 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00103 if (!array->has[idx]) SETERRQ1(1,"Asking for non-set element: %d",idx); 00104 *val = array->data[idx]; 00105 PetscFunctionReturn(0); 00106 }
PetscErrorCode IntArrayGetFill | ( | IntArray | , | |
int * | ||||
) |
PetscErrorCode IntArraySetAt | ( | IntArray | array, | |
int | idx, | |||
int | val | |||
) |
Set a value at a given index. Right now we do not yet dynamically reallocate the array if the index is out of bound.
Definition at line 63 of file anamodutils.c.
References IntArray_::alloc, IntArray_::data, IntArray_::fill, and IntArray_::has.
00064 { 00065 PetscFunctionBegin; 00066 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00067 array->data[idx] = val; array->has[idx] = PETSC_TRUE; 00068 if (idx>array->fill) array->fill = idx; 00069 PetscFunctionReturn(0); 00070 }
PetscErrorCode IntArrayTryGetAt | ( | IntArray | array, | |
int | idx, | |||
int * | val, | |||
PetscTruth * | has | |||
) |
Retrieve data from a given index.
Arguments:
array
: the IntArray objectidx
: the index; it is an error to ask out of bounds, but not to ask beyond the highest position filled; in that case failure will be reportedval
(output) : the value retrieved. This argument is allowed to be null.has
(output) : true if a value was stored at this index. This argument is allowed to be null. Definition at line 85 of file anamodutils.c.
References IntArray_::alloc, IntArray_::data, and IntArray_::has.
00086 { 00087 PetscFunctionBegin; 00088 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00089 if (has) *has = array->has[idx]; 00090 if (array->has[idx] && val) *val = array->data[idx]; 00091 PetscFunctionReturn(0); 00092 }
PetscErrorCode NewFeatureSet | ( | FeatureSet * | set | ) |
Allocate a featureset object. See Feature sets
Definition at line 74 of file feature.c.
References FeatureSet_::cookie, CreateIntArray(), CreateStringArray(), FeatureSet_::features, FSETCOOKIE, and FeatureSet_::IDs.
00075 { 00076 FeatureSet fnew; PetscErrorCode ierr; 00077 PetscFunctionBegin; 00078 ierr = PetscMalloc(sizeof(struct FeatureSet_),&fnew); CHKERRQ(ierr); 00079 ierr = PetscMemzero(fnew,sizeof(struct FeatureSet_)); CHKERRQ(ierr); 00080 fnew->cookie = FSETCOOKIE; 00081 ierr = CreateIntArray("IDs",50,&(fnew->IDs)); CHKERRQ(ierr); 00082 ierr = CreateStringArray("features",50,&(fnew->features)); CHKERRQ(ierr); 00083 *set = fnew; 00084 PetscFunctionReturn(0); 00085 }
PetscErrorCode NewFeatureValues | ( | FeatureValues * | values | ) |
Allocate a featurevalues object. See Feature sets
Definition at line 132 of file feature.c.
References FeatureValues_::cookie, CreateAnalysisDataTypeArray(), CreateAnalysisItemArray(), FVALCOOKIE, FeatureValues_::types, and FeatureValues_::values.
00133 { 00134 FeatureValues fnew; PetscErrorCode ierr; 00135 PetscFunctionBegin; 00136 ierr = PetscMalloc(sizeof(struct FeatureValues_),&fnew); CHKERRQ(ierr); 00137 ierr = PetscMemzero(fnew,sizeof(struct FeatureValues_)); CHKERRQ(ierr); 00138 fnew->cookie = FVALCOOKIE; 00139 ierr = CreateAnalysisItemArray("values",50,&fnew->values); CHKERRQ(ierr); 00140 ierr = CreateAnalysisDataTypeArray("values",50,&fnew->types); CHKERRQ(ierr); 00141 *values = fnew; 00142 PetscFunctionReturn(0); 00143 }
PetscErrorCode PurgeAttachedArrays | ( | Mat | A | ) |
PetscErrorCode QuantityAsString | ( | AnalysisItem * | q, | |
AnalysisDataType | t, | |||
char ** | s | |||
) |
Generate a character string for a given quantity.
Definition at line 1101 of file module_functions.c.
References ANALYSISDBLARRAY, ANALYSISDOUBLE, ANALYSISINTARRAY, ANALYSISINTEGER, ANALYSISSTRING, AnalysisItem::c, AnalysisItem::i, AnalysisItem::ii, AnalysisItem::len, AnalysisItem::r, and AnalysisItem::rr.
Referenced by ComputeQuantity(), ReportAnamodContent(), and RetrieveQuantity().
01102 { 01103 PetscErrorCode ierr; size_t l; 01104 01105 PetscFunctionBegin; 01106 switch (t) { 01107 case ANALYSISINTEGER : 01108 ierr = PetscMalloc(12*sizeof(char),s); CHKERRQ(ierr); 01109 ierr = PetscMemzero(*s,12*sizeof(char)); CHKERRQ(ierr); 01110 sprintf(*s,"%d",q->i); 01111 break; 01112 case ANALYSISDOUBLE : 01113 ierr = PetscMalloc(22*sizeof(char),s); CHKERRQ(ierr); 01114 ierr = PetscMemzero(*s,22*sizeof(char)); CHKERRQ(ierr); 01115 sprintf(*s,"%e",q->r); 01116 break; 01117 case ANALYSISSTRING : 01118 ierr = PetscMalloc((strlen(q->c)+1)*sizeof(char),s); CHKERRQ(ierr); 01119 ierr = PetscMemzero(*s,(strlen(q->c)+1)*sizeof(char)); CHKERRQ(ierr); 01120 sprintf(*s,"%s",q->c); 01121 break; 01122 case ANALYSISINTARRAY : 01123 { 01124 int i,n,*iar; 01125 iar = q->ii; 01126 n = q->len; 01127 ierr = PetscMalloc((10*n+1)*sizeof(char),s); CHKERRQ(ierr); 01128 ierr = PetscMemzero(*s,(10*n+1)*sizeof(char)); CHKERRQ(ierr); 01129 for (i=0; i<=n; i++) { 01130 ierr = PetscStrlen(*s,&l); CHKERRQ(ierr); 01131 sprintf(*s+l,"%d,",iar[i]); 01132 } 01133 } 01134 break; 01135 case ANALYSISDBLARRAY : 01136 { 01137 int i,n; PetscReal *rar; 01138 rar = q->rr; 01139 n = q->len; 01140 ierr = PetscMalloc((15*n+1)*sizeof(char),s); CHKERRQ(ierr); 01141 ierr = PetscMemzero(*s,(15*n+1)*sizeof(char)); CHKERRQ(ierr); 01142 for (i=0; i<=n; i++) { 01143 ierr = PetscStrlen(*s,&l); CHKERRQ(ierr); 01144 sprintf(*s+l,"%e,",rar[i]); 01145 } 01146 } 01147 break; 01148 default : SETERRQ1(1,"Cannot string quantity type %d",t); 01149 } 01150 PetscFunctionReturn(0); 01151 }
PetscErrorCode RegisterModule | ( | const char * | cat, | |
const char * | cmp, | |||
AnalysisDataType | type, | |||
PetscErrorCode(*)(AnaModNumericalProblem, AnalysisItem *, int *, PetscTruth *) | f | |||
) |
Register a new computational module
This adds a computational routine (the f
argument) into the modules database under the given category (cat
) and module (cmp
) label. If the category does not exist yet, it is created.
The available types are defined in anamodtypes.h
If the routine is NULL, only the category and component are created.
Routine prototype:
See also HasComputeModule(), ComputeQuantity(), DeregisterModules().
Definition at line 410 of file module_functions.c.
References categories, components, hasval, id, ids, INC, maxcategories, maxcomponents, modules, MXC, ncategories, ncomponents, optionfunctions, and types.
Referenced by RegisterICMKModules(), RegisterIprsModules(), RegisterJPLModules(), RegisterLapackModules(), RegisterNormalityModules(), RegisterSimpleModules(), RegisterSpectrumModules(), RegisterStatsModules(), RegisterStructureModules(), and RegisterVarianceModules().
00412 { 00413 PetscTruth flg; int i,icmp,icat,id; PetscErrorCode ierr; 00414 PetscFunctionBegin; 00415 00416 /* 00417 * Check for illegal names 00418 */ 00419 if (strchr(cat,':')) 00420 SETERRQ(1,"Illegal colon in category name"); 00421 if (strchr(cmp,':')) 00422 SETERRQ(1,"Illegal colon in component name"); 00423 00424 /* initial setup */ 00425 if (ncategories==0) { 00426 ierr = PetscMalloc 00427 (maxcategories*sizeof(char*),&categories); CHKERRQ(ierr); 00428 ierr = PetscMalloc 00429 (maxcategories*sizeof(int),&maxcomponents); CHKERRQ(ierr); 00430 ierr = PetscMalloc 00431 (maxcategories*sizeof(int),&ncomponents); CHKERRQ(ierr); 00432 ierr = PetscMalloc 00433 (maxcategories*sizeof(char**),&components); CHKERRQ(ierr); 00434 ierr = PetscMalloc 00435 (maxcategories*sizeof(AnalysisDataType*),&types); CHKERRQ(ierr); 00436 ierr = PetscMalloc 00437 (maxcategories*sizeof(PetscErrorCode(**)(Mat,AnalysisItem*,int*,PetscTruth*)), 00438 &modules); CHKERRQ(ierr); 00439 ierr = PetscMalloc 00440 (maxcategories*sizeof(PetscErrorCode(*)(char*)), 00441 &optionfunctions); CHKERRQ(ierr); 00442 ierr = PetscMalloc 00443 (maxcategories*sizeof(PetscTruth*),&hasval); CHKERRQ(ierr); 00444 ierr = PetscMalloc 00445 (maxcategories*sizeof(int*),&ids); CHKERRQ(ierr); 00446 } 00447 00448 /* match this category, or allocate new */ 00449 flg = PETSC_FALSE; 00450 for (i=0; i<ncategories; i++) { 00451 ierr = PetscStrcmp(cat,categories[i],&flg); CHKERRQ(ierr); 00452 if (flg) { 00453 icat = i; goto old_cat; 00454 } 00455 } 00456 icat=ncategories; 00457 00458 /* 00459 * reallocate categories if the array is overflowing 00460 */ 00461 if (icat>=maxcategories) { 00462 int m = maxcategories; 00463 char **newcategories,***newcomponents; AnalysisDataType **newtypes; 00464 int *newmaxcomponents,*newncomponents; 00465 PetscErrorCode(***newmodules)(AnaModNumericalProblem,AnalysisItem*,int*,PetscTruth*); 00466 PetscErrorCode(**newoptionfunctions)(char*); 00467 PetscTruth **newhasval; int **newids; 00468 maxcategories += INC; 00469 /*printf("increasing categores from %d to %d components\n",m,maxcategories);*/ 00470 00471 ierr = PetscMalloc 00472 (maxcategories*sizeof(char*),&newcategories); CHKERRQ(ierr); 00473 ierr = PetscMalloc 00474 (maxcategories*sizeof(int),&newmaxcomponents); CHKERRQ(ierr); 00475 ierr = PetscMalloc 00476 (maxcategories*sizeof(int),&newncomponents); CHKERRQ(ierr); 00477 ierr = PetscMalloc 00478 (maxcategories*sizeof(char**),&newcomponents); CHKERRQ(ierr); 00479 ierr = PetscMalloc 00480 (maxcategories*sizeof(AnalysisDataType*),&newtypes); CHKERRQ(ierr); 00481 ierr = PetscMalloc 00482 (maxcategories*sizeof(PetscErrorCode(**)(Mat,AnalysisItem*,int*,PetscTruth*)), 00483 &newmodules); CHKERRQ(ierr); 00484 ierr = PetscMalloc 00485 (maxcategories*sizeof(PetscErrorCode(**)(char*)), 00486 &newoptionfunctions); CHKERRQ(ierr); 00487 ierr = PetscMalloc 00488 (maxcategories*sizeof(PetscTruth*),&newhasval); CHKERRQ(ierr); 00489 ierr = PetscMalloc 00490 (maxcategories*sizeof(int*),&newids); CHKERRQ(ierr); 00491 00492 for (i=0; i<m; i++) { 00493 newcategories[i] = categories[i]; 00494 newmaxcomponents[i] = maxcomponents[i]; 00495 newncomponents[i] = ncomponents[i]; 00496 newcomponents[i] = components[i]; 00497 newtypes[i] = types[i]; 00498 newmodules[i] = modules[i]; 00499 newoptionfunctions[i] = optionfunctions[i]; 00500 newhasval[i] = hasval[i]; 00501 newids[i] = ids[i]; 00502 } 00503 00504 ierr = PetscFree(categories); CHKERRQ(ierr); 00505 ierr = PetscFree(maxcomponents); CHKERRQ(ierr); 00506 ierr = PetscFree(ncomponents); CHKERRQ(ierr); 00507 ierr = PetscFree(components); CHKERRQ(ierr); 00508 ierr = PetscFree(types); CHKERRQ(ierr); 00509 ierr = PetscFree(modules); CHKERRQ(ierr); 00510 ierr = PetscFree(optionfunctions); CHKERRQ(ierr); 00511 ierr = PetscFree(hasval); CHKERRQ(ierr); 00512 ierr = PetscFree(ids); CHKERRQ(ierr); 00513 00514 categories = newcategories; 00515 maxcomponents = newmaxcomponents; 00516 ncomponents = newncomponents; 00517 components = newcomponents; 00518 types = newtypes; 00519 modules = newmodules; 00520 optionfunctions = newoptionfunctions; 00521 hasval = newhasval; 00522 ids = newids; 00523 00524 } 00525 00526 /* 00527 * Now that we are sure we have the space, insert this category 00528 */ 00529 ierr = PetscStrallocpy(cat,categories+icat); CHKERRQ(ierr); 00530 maxcomponents[icat] = MXC; ncomponents[icat] = 0; 00531 ierr = PetscMalloc 00532 (maxcomponents[icat]*sizeof(char*),&(components[icat])); CHKERRQ(ierr); 00533 ierr = PetscMalloc 00534 (maxcomponents[icat]*sizeof(AnalysisDataType),&(types[icat])); CHKERRQ(ierr); 00535 ierr = PetscMalloc 00536 (maxcomponents[icat]*sizeof(int(*)(Mat,AnalysisItem*,int*,PetscTruth*)), 00537 &(modules[icat])); CHKERRQ(ierr); 00538 ierr = PetscMalloc 00539 (maxcomponents[icat]*sizeof(PetscTruth),&(hasval[icat])); CHKERRQ(ierr); 00540 ierr = PetscMalloc 00541 (maxcomponents[icat]*sizeof(int),&(ids[icat])); CHKERRQ(ierr); 00542 ncategories++; 00543 00544 /* 00545 * component handling 00546 */ 00547 old_cat: 00548 00549 /* match this component or allocate new */ 00550 flg = PETSC_FALSE; 00551 for (i=0; i<ncomponents[icat]; i++) { 00552 ierr = PetscStrcmp(cmp,components[icat][i],&flg); CHKERRQ(ierr); 00553 if (flg) { 00554 icmp = i; goto old_cmp; 00555 } 00556 } 00557 icmp=ncomponents[icat]; 00558 /*printf("creating category element <%s:%s> @ %d,%d\n",cat,cmp,icat,icmp);*/ 00559 if (icmp>=maxcomponents[icat]) { 00560 int m = maxcomponents[icat]; 00561 char **newcomponents; AnalysisDataType *newtypes; 00562 int(**newmodules)(AnaModNumericalProblem,AnalysisItem*,int*,PetscTruth*); 00563 PetscTruth *newhasval; int *newids; 00564 maxcomponents[icat] += INC; 00565 /*printf("increasing category <%s> from %d to %d components\n", 00566 cat,m,maxcomponents[icat]);*/ 00567 ierr = PetscMalloc 00568 (maxcomponents[icat]*sizeof(char*),&newcomponents); CHKERRQ(ierr); 00569 ierr = PetscMalloc 00570 (maxcomponents[icat]*sizeof(AnalysisDataType),&newtypes); CHKERRQ(ierr); 00571 ierr = PetscMalloc 00572 (maxcomponents[icat]*sizeof(int(*)(Mat,AnalysisItem*,int*,PetscTruth*)),&newmodules); CHKERRQ(ierr); 00573 ierr = PetscMalloc 00574 (maxcomponents[icat]*sizeof(PetscTruth),&newhasval); CHKERRQ(ierr); 00575 ierr = PetscMalloc 00576 (maxcomponents[icat]*sizeof(int),&newids); CHKERRQ(ierr); 00577 00578 for (i=0; i<m; i++) { 00579 newcomponents[i] = components[icat][i]; 00580 newtypes[i] = types[icat][i]; 00581 newmodules[i] = modules[icat][i]; 00582 newhasval[i] = hasval[icat][i]; 00583 newids[i] = ids[icat][i]; 00584 } 00585 ierr = PetscFree(components[icat]); CHKERRQ(ierr); 00586 ierr = PetscFree(types[icat]); CHKERRQ(ierr); 00587 ierr = PetscFree(modules[icat]); CHKERRQ(ierr); 00588 ierr = PetscFree(hasval[icat]); CHKERRQ(ierr); 00589 ierr = PetscFree(ids[icat]); CHKERRQ(ierr); 00590 components[icat] = newcomponents; 00591 types[icat] = newtypes; 00592 modules[icat] = newmodules; 00593 hasval[icat] = newhasval; 00594 ids[icat] = newids; 00595 } 00596 ierr = PetscStrallocpy(cmp,components[icat]+icmp); CHKERRQ(ierr); 00597 types[icat][icmp] = type; 00598 ncomponents[icat]++; 00599 old_cmp: 00600 00601 /* insert this function */ 00602 modules[icat][icmp] = f; 00603 ierr = PetscObjectComposedDataRegister(&id); CHKERRQ(ierr); 00604 ids[icat][icmp] = id; 00605 00606 PetscFunctionReturn(0); 00607 }
PetscErrorCode RetrieveQuantity | ( | AnaModNumericalProblem | prob, | |
char * | cat, | |||
char * | cmp, | |||
AnalysisItem * | res, | |||
PetscTruth * | success | |||
) |
Retrieve an attached quantity. Note that this does not report the length of arrays; you have to know under which name this is stored.
Definition at line 931 of file module_functions.c.
References ANALYSISINTARRAY, AnaModHasTrace(), AnaModTraceArrays(), AnaModTraceMessage(), GetCategoryIndex(), GetModuleIndex(), hasval, QuantityAsString(), RetrieveQuantityByID(), TYPEii, and types.
00933 { 00934 PetscTruth flg,trace; 00935 int icat,icmp; PetscErrorCode ierr; 00936 00937 PetscFunctionBegin; 00938 00939 /* 00940 * Get the location of the module for this quantity 00941 */ 00942 ierr = GetCategoryIndex(cat,&icat,&flg); CHKERRQ(ierr); 00943 if (!flg) 00944 SETERRQ1(1,"Could not find category <%s>",cat); 00945 ierr = GetModuleIndex(icat,cmp,&icmp,&flg); CHKERRQ(ierr); 00946 if (!flg) 00947 SETERRQ2(1,"Could not find module <%s:%s>",cat,cmp); 00948 00949 /* 00950 * Compute 00951 */ 00952 ierr = RetrieveQuantityByID(prob,icat,icmp,res,&flg); CHKERRQ(ierr); 00953 00954 hasval[icat][icmp] = flg; 00955 00956 if (!flg) goto nosuccess; 00957 /* 00958 * Tracing 00959 */ 00960 ierr = AnaModHasTrace(&trace); CHKERRQ(ierr); 00961 if (trace) { 00962 if (flg) { 00963 char *string; PetscTruth trace_arrays; 00964 AnalysisDataType t = TYPEii(icat,icmp); 00965 00966 ierr = AnaModTraceArrays(&trace_arrays); CHKERRQ(ierr); 00967 if (t<ANALYSISINTARRAY || trace_arrays) { 00968 ierr = QuantityAsString 00969 (res,types[icat][icmp],&string); CHKERRQ(ierr); 00970 ierr = AnaModTraceMessage 00971 ("Anamod retrieved <%s:%s> = <%s>\n",cat,cmp,string); CHKERRQ(ierr); 00972 ierr = PetscFree(string); CHKERRQ(ierr); 00973 } 00974 } else { 00975 ierr = AnaModTraceMessage 00976 ("Anamod failed to compute <%s:%s>\n",cat,cmp); CHKERRQ(ierr); 00977 } 00978 } 00979 00980 nosuccess: 00981 if (success) *success = flg; 00982 00983 PetscFunctionReturn(0); 00984 }
PetscErrorCode RetrieveQuantityByID | ( | AnaModNumericalProblem | prob, | |
int | icat, | |||
int | icmp, | |||
AnalysisItem * | result, | |||
PetscTruth * | f | |||
) |
See also HasQuantityByID()
Definition at line 1066 of file module_functions.c.
References ANALYSISDBLARRAY, ANALYSISDOUBLE, ANALYSISINTARRAY, ANALYSISINTEGER, AnalysisItem::i, ids, AnalysisItem::ii, AnalysisItem::r, AnalysisItem::rr, and TYPEii.
Referenced by RetrieveQuantity().
01068 { 01069 Mat A = (Mat)prob; AnalysisDataType type; int id = ids[icat][icmp]; 01070 PetscErrorCode ierr; 01071 PetscFunctionBegin; 01072 01073 type = TYPEii(icat,icmp); 01074 switch (type) { 01075 case ANALYSISINTEGER : 01076 ierr = PetscObjectComposedDataGetInt 01077 ((PetscObject)A,id,result->i,*f); CHKERRQ(ierr); 01078 break; 01079 case ANALYSISDOUBLE : 01080 ierr = PetscObjectComposedDataGetReal 01081 ((PetscObject)A,id,result->r,*f); CHKERRQ(ierr); 01082 break; 01083 case ANALYSISINTARRAY : 01084 ierr = PetscObjectComposedDataGetIntstar 01085 ((PetscObject)A,id,result->ii,*f); CHKERRQ(ierr); 01086 break; 01087 case ANALYSISDBLARRAY : 01088 ierr = PetscObjectComposedDataGetRealstar 01089 ((PetscObject)A,id,result->rr,*f); CHKERRQ(ierr); 01090 break; 01091 default : SETERRQ1(1,"Unknown data type %d",type); 01092 } 01093 PetscFunctionReturn(0); 01094 }
PetscErrorCode StringArrayAdd | ( | StringArray | array, | |
char * | val, | |||
int * | idx | |||
) |
Add a new value and return the index. Right now we do not yet dynamically reallocate the array if there is no more space.
Definition at line 153 of file anamodutils.c.
References StringArray_::alloc, StringArray_::data, StringArray_::fill, and StringArray_::has.
Referenced by AddToFeatureSet().
00154 { 00155 int ins; 00156 PetscFunctionBegin; 00157 if (array->fill>=array->alloc-1) SETERRQ(1,"No more space"); 00158 ins = array->fill++; 00159 array->data[ins] = strdup(val); 00160 array->has[ins] = PETSC_TRUE; 00161 PetscFunctionReturn(0); 00162 }
PetscErrorCode StringArrayGetAt | ( | StringArray | array, | |
int | idx, | |||
char ** | val | |||
) |
As StringArrayTryGetAt(), except that it is an error to ask for an index where no value has been set.
Definition at line 214 of file anamodutils.c.
References StringArray_::alloc, StringArray_::data, and StringArray_::has.
Referenced by InstantiateFeatureSet().
00215 { 00216 PetscFunctionBegin; 00217 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00218 if (!array->has[idx]) SETERRQ1(1,"Asking for non-set element: %d",idx); 00219 *val = array->data[idx]; 00220 PetscFunctionReturn(0); 00221 }
PetscErrorCode StringArrayGetFill | ( | StringArray | , | |
int * | ||||
) |
Definition at line 166 of file anamodutils.c.
References StringArray_::fill.
Referenced by InstantiateFeatureSet().
PetscErrorCode StringArraySetAt | ( | StringArray | array, | |
int | idx, | |||
char * | val | |||
) |
Set a value at a given index. Right now we do not yet dynamically reallocate the array if the index is out of bound.
Definition at line 178 of file anamodutils.c.
References StringArray_::alloc, StringArray_::data, StringArray_::fill, and StringArray_::has.
00179 { 00180 PetscFunctionBegin; 00181 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00182 array->data[idx] = strdup(val); array->has[idx] = PETSC_TRUE; 00183 if (idx>array->fill) array->fill = idx; 00184 PetscFunctionReturn(0); 00185 }
PetscErrorCode StringArrayTryGetAt | ( | StringArray | array, | |
int | idx, | |||
char ** | val, | |||
PetscTruth * | has | |||
) |
Retrieve data from a given index.
Arguments:
array
: the StringArray objectidx
: the index; it is an error to ask out of bounds, but not to ask beyond the highest position filled; in that case failure will be reportedval
(output) : the value retrieved. This argument is allowed to be null.has
(output) : true if a value was stored at this index. This argument is allowed to be null. Definition at line 200 of file anamodutils.c.
References StringArray_::alloc, StringArray_::data, and StringArray_::has.
00201 { 00202 PetscFunctionBegin; 00203 if (idx>=array->alloc) SETERRQ1(1,"Index out of bounds: %d",idx); 00204 if (has) *has = array->has[idx]; 00205 if (array->has[idx] && val) *val = array->data[idx]; 00206 PetscFunctionReturn(0); 00207 }
PetscErrorCode TabReportModules | ( | Mat | , | |
char ** | , | |||
char ** | , | |||
int | ||||
) |