w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

matrix.h (1594B)


      1 /* $Id$ */
      2 /* 
      3  * matrix.h, matrix.c: Liner equation solver using LU decomposition.
      4  * 
      5  * by K.Okabe  Aug. 1999
      6  * 
      7  * You can use,copy,modify and distribute this program without any permission.
      8  */
      9 
     10 #ifndef _MATRIX_H
     11 #include <math.h>
     12 #include <string.h>
     13 
     14 /* 
     15  * Types.
     16  */
     17 
     18 struct matrix {
     19     double *me;
     20     int dim;
     21 };
     22 
     23 struct vector {
     24     double *ve;
     25     int dim;
     26 };
     27 
     28 typedef struct matrix *Matrix;
     29 typedef struct vector *Vector;
     30 
     31 /* 
     32  * Macros.
     33  */
     34 
     35 #define M_VAL(m,i,j) ((m)->me[(i)*(m)->dim +(j)])
     36 #define V_VAL(v,i) ((v)->ve[i])
     37 
     38 /* 
     39  * Compatible macros with those in Meschach Library.
     40  */
     41 
     42 #define m_entry(m,i,j) (M_VAL(m,i,j))
     43 #define v_entry(v,i) (V_VAL(v,i))
     44 #define m_copy(m1,m2) (bcopy((m1)->me,(m2)->me,(m1)->dim*(m1)->dim*sizeof(double)))
     45 #define v_free(v) ((v)=NULL)
     46 #define m_free(m) ((m)=NULL)
     47 #define px_free(px) ((px)=NULL)
     48 #define m_set_val(m,i,j,x) (M_VAL(m,i,j) = (x))
     49 #define m_add_val(m,i,j,x) (M_VAL(m,i,j) += (x))
     50 #define v_set_val(v,i,x) (V_VAL(v,i) = (x))
     51 #define v_add_val(v,i,x) (V_VAL(v,i) += (x))
     52 #define m_get(r,c) (new_matrix(r))
     53 #define v_get(n) (new_vector(n))
     54 #define px_get(n) (New_N(int,n))
     55 typedef struct matrix MAT;
     56 typedef struct vector VEC;
     57 typedef int PERM;
     58 
     59 extern int LUfactor(Matrix, int *);
     60 extern Matrix m_inverse(Matrix, Matrix);
     61 extern Matrix LUinverse(Matrix, int *, Matrix);
     62 extern int LUsolve(Matrix, int *, Vector, Vector);
     63 extern int Lsolve(Matrix, Vector, Vector, double);
     64 extern int Usolve(Matrix, Vector, Vector, double);
     65 extern Matrix new_matrix(int);
     66 extern Vector new_vector(int);
     67 
     68 #define _MATRIX_H
     69 #endif				/* _MATRIX_H */