| 1 | //
|
|---|
| 2 | // cg.h
|
|---|
| 3 | // cg
|
|---|
| 4 | //
|
|---|
| 5 | // Created by Sri Hari Krishna Narayanan on 5/21/15.
|
|---|
| 6 | //
|
|---|
| 7 | //
|
|---|
| 8 |
|
|---|
| 9 | #ifndef __cg__cg__
|
|---|
| 10 | #define __cg__cg__
|
|---|
| 11 |
|
|---|
| 12 | /** @brief Fully intrusive version of CG algorithm. Solves Ax=b for an ensemble of A and a single b and returns x for each ensemble member and the iteration at which convergence is reached.
|
|---|
| 13 | * @param A ensemble of A matrices.
|
|---|
| 14 | * @param b RHS vector.
|
|---|
| 15 | * @param n dimensions of A (same as m).
|
|---|
| 16 | * @param m dimensions of A (same as n).
|
|---|
| 17 | * @param tolerance value to which norm is tested.
|
|---|
| 18 | * @param ensemblecount number of ensembles, .
|
|---|
| 19 | * @param ensemblepolicy (allconverge=0, anyconverge=1, halfconverge=2).
|
|---|
| 20 | * @param x ensemble of output solutions.
|
|---|
| 21 | * @param converged output to report iterations at which CG converges.
|
|---|
| 22 | * @return Void.
|
|---|
| 23 | */
|
|---|
| 24 | void conjugateGradientEnsembleA( double ***A, double *b, int n, int m, double tolerance, int ensemblecount, int ensemblepolicy, double **x, int *converged);
|
|---|
| 25 |
|
|---|
| 26 | /** @brief Fully intrusive version of CG algorithm. Solves Ax=b for a single A and an ensemble of b and returns x for each ensemeble member and the iteration at which convergence is reached.
|
|---|
| 27 | * @param A A matrix.
|
|---|
| 28 | * @param b ensemble of RHS vectors.
|
|---|
| 29 | * @param n dimensions of A (same as m).
|
|---|
| 30 | * @param m dimensions of A (same as n).
|
|---|
| 31 | * @param tolerance value to which norm is tested.
|
|---|
| 32 | * @param ensemblecount number of ensembles, .
|
|---|
| 33 | * @param ensemblepolicy (allconverge=0, anyconverge=1, halfconverge=2).
|
|---|
| 34 | * @param x ensemble of output solutions.
|
|---|
| 35 | * @param converged output to report iterations at which CG converges.
|
|---|
| 36 | * @return Void.
|
|---|
| 37 | */
|
|---|
| 38 | void conjugateGradientEnsembleB( double **A, double **b, int n, int m, double tolerance, int ensemblecount, int ensemblepolicy, double **x, int *converged);
|
|---|
| 39 |
|
|---|
| 40 | /** @brief Generates an ensemble of A matrices and solves CG fully intrusively.
|
|---|
| 41 | * @param filename file containing an input A matrix (can be NULL).
|
|---|
| 42 | * @param rhsfilename file containing an input RHS (can be NULL).
|
|---|
| 43 | * @param directionfilename file containing an input direction vector (can be NULL).
|
|---|
| 44 | * @param scalingfactor value used to scale diagonal entries of A matrices of ensemble.
|
|---|
| 45 | * @param tolerance value to which norm is tested.
|
|---|
| 46 | * @param ensemblecount total number of ensembles.
|
|---|
| 47 | * @param ensemblepolicy (allconverge=0, anyconverge=1, halfconverge=2).
|
|---|
| 48 | * @param wantindependentensemble boolean to test if ensembles should be independent from each other.
|
|---|
| 49 | * @return Void.
|
|---|
| 50 | */
|
|---|
| 51 | void solveEnsembleA(const char * filename, const char * rhsfilename, const char * directionfilename, double scalingfactor, double tolerance, int ensemblecount, int ensemblepolicy, int wantindependentensemble);
|
|---|
| 52 |
|
|---|
| 53 | /** @brief Generates an ensemble of RHS vectors and solves CG fully instrusively.
|
|---|
| 54 | * @param filename file containing an input A matrix (can be NULL).
|
|---|
| 55 | * @param rhsfilename file containing an input RHS (can be NULL).
|
|---|
| 56 | * @param directionfilename file containing an input direction vector (can be NULL).
|
|---|
| 57 | * @param scalingfactor value used to scale RHS vectors of ensemble.
|
|---|
| 58 | * @param tolerance value to which norm is tested.
|
|---|
| 59 | * @param ensemblecount total number of ensembles.
|
|---|
| 60 | * @param ensemblepolicy (allconverge=0, anyconverge=1, halfconverge=2).
|
|---|
| 61 | * @param wantindependentensemble boolean to test if ensembles should be independent from each other.
|
|---|
| 62 | * @return Void.
|
|---|
| 63 | */
|
|---|
| 64 | void solveEnsembleB(const char * filename, const char * rhsfilename, const char * directionfilename, double scalingfactor, double tolerance, int ensemblecount, int ensemblepolicy, int wantindependentensemble);
|
|---|
| 65 |
|
|---|
| 66 | void usage();
|
|---|
| 67 |
|
|---|
| 68 | #endif /* defined(__cg__cg__) */
|
|---|