| 1 | /*************************************************************************** |
| 2 | |
| 3 | TITLE: ls_matrix.h |
| 4 | |
| 5 | ---------------------------------------------------------------------------- |
| 6 | |
| 7 | FUNCTION: Header file for general real matrix routines. |
| 8 | |
| 9 | The routines in this module have come more or less from ref [1]. |
| 10 | Note that, probably due to the heritage of ref [1] (which has a |
| 11 | FORTRAN version that was probably written first), the use of 1 as |
| 12 | the first element of an array (or vector) is used. This is accomplished |
| 13 | in memory by allocating, but not using, the 0 elements in each dimension. |
| 14 | While this wastes some memory, it allows the routines to be ported more |
| 15 | easily from FORTRAN (I suspect) as well as adhering to conventional |
| 16 | matrix notation. As a result, however, traditional ANSI C convention |
| 17 | (0-base indexing) is not followed; as the authors of ref [1] point out, |
| 18 | there is some question of the portability of the resulting routines |
| 19 | which sometimes access negative indexes. See ref [1] for more details. |
| 20 | |
| 21 | ---------------------------------------------------------------------------- |
| 22 | |
| 23 | MODULE STATUS: developmental |
| 24 | |
| 25 | ---------------------------------------------------------------------------- |
| 26 | |
| 27 | GENEALOGY: Created 950222 E. B. Jackson |
| 28 | |
| 29 | ---------------------------------------------------------------------------- |
| 30 | |
| 31 | DESIGNED BY: from Numerical Recipes in C, by Press, et. al. |
| 32 | |
| 33 | CODED BY: Bruce Jackson |
| 34 | |
| 35 | MAINTAINED BY: |
| 36 | |
| 37 | ---------------------------------------------------------------------------- |
| 38 | |
| 39 | MODIFICATION HISTORY: |
| 40 | |
| 41 | DATE PURPOSE BY |
| 42 | |
| 43 | CURRENT RCS HEADER: |
| 44 | |
| 45 | $Header$ |
| 46 | $Log$ |
| 47 | Revision 1.1 2002/09/10 01:14:02 curt |
| 48 | Initial revision |
| 49 | |
| 50 | Revision 1.1.1.1 1999/06/17 18:07:34 curt |
| 51 | Start of 0.7.x branch |
| 52 | |
| 53 | Revision 1.1.1.1 1999/04/05 21:32:45 curt |
| 54 | Start of 0.6.x branch. |
| 55 | |
| 56 | Revision 1.1 1998/06/27 22:34:58 curt |
| 57 | Initial revision. |
| 58 | |
| 59 | * Revision 1.1 1995/02/27 20:02:18 bjax |
| 60 | * Initial revision |
| 61 | * |
| 62 | |
| 63 | ---------------------------------------------------------------------------- |
| 64 | |
| 65 | REFERENCES: [1] Press, William H., et. al, Numerical Recipes in |
| 66 | C, 2nd edition, Cambridge University Press, 1992 |
| 67 | |
| 68 | ---------------------------------------------------------------------------- |
| 69 | |
| 70 | CALLED BY: |
| 71 | |
| 72 | ---------------------------------------------------------------------------- |
| 73 | |
| 74 | CALLS TO: |
| 75 | |
| 76 | ---------------------------------------------------------------------------- |
| 77 | |
| 78 | INPUTS: |
| 79 | |
| 80 | ---------------------------------------------------------------------------- |
| 81 | |
| 82 | OUTPUTS: |
| 83 | |
| 84 | --------------------------------------------------------------------------*/ |
| 85 | #include <stdlib.h> |
| 86 | #include <stdio.h> |
| 87 | #include <math.h> |
| 88 | |
| 89 | #define NR_END 1 |
| 90 | |
| 91 | /* matrix creation & destruction routines */ |
| 92 | |
| 93 | int *nr_ivector(long nl, long nh); |
| 94 | double **nr_matrix(long nrl, long nrh, long ncl, long nch); |
| 95 | |
| 96 | void nr_free_ivector(int *v, long nl /* , long nh */); |
| 97 | void nr_free_matrix(double **m, long nrl, long nrh, long ncl, long nch); |
| 98 | |
| 99 | |
| 100 | /* Gauss-Jordan inversion routine */ |
| 101 | |
| 102 | int nr_gaussj(double **a, int n, double **b, int m); |
| 103 | |
| 104 | /* Linear equation solution by Gauss-Jordan elimination. a[1..n][1..n] is */ |
| 105 | /* the input matrix. b[1..n][1..m] is input containing the m right-hand */ |
| 106 | /* side vectors. On output, a is replaced by its matrix invers, and b is */ |
| 107 | /* replaced by the corresponding set of solution vectors. */ |
| 108 | |
| 109 | /* Note: this routine modified by EBJ to make b optional, if m == 0 */ |
| 110 | |
| 111 | /* Matrix copy, multiply, and printout routines (by EBJ) */ |
| 112 | |
| 113 | void nr_copymat(double **orig, int n, double **copy); |
| 114 | void nr_multmat(double **m1, int n, double **m2, double **prod); |
| 115 | void nr_printmat(double **a, int n); |
| 116 | |
| 117 |