matrix.h

Go to the documentation of this file.
00001 /* -----------------------------------------------------------------------------------------
00002   $Id: matrix.h 486 2006-07-07 21:07:52Z svacek $
00003   $Author: svacek $
00004    ----------------------------------------------------------------------------------------- */
00005 #include <malloc.h>
00006 #include <stdlib.h>
00007 #include <stdio.h>
00008 #include <math.h>
00009 #include "wlog.h"
00010 #include "vector.h"
00011 #include "constants.h"
00012 #ifndef __MAT_SVH
00013 #define __MAT_SVH
00014 /* ------------------------------------------------------------------------------- */
00015 /*@{*/
00016 /** \defgroup MATRIX_OPS Matrix Operations */
00017 /** \ingroup LINEAR_ALGEBRA */
00018 /** Structure matrix : definition of full matrix 
00019      @todo Should be replaced with BLAS/CGNS tools 
00020 */
00021 /* -------------------------------------------------------------------------- */
00022 typedef struct 
00023 {
00024   double **a;
00025   long n,m;
00026 } matrix;
00027 /* ------------------------------------------------------------------------------- */
00028 
00029 /*
00030   function construct()
00031   function construct_transpose()
00032   function construct_multiply()
00033   function destruct()
00034   - provede alokaci/dealokaci matice A dle rozmeru nebo okopirovanim 
00035     jine matice(pripadne transponovanim resp. nasobenim)
00036   function construct_mtransf()
00037   function construct_mtransfinv()
00038   
00039    out - je matice transformace referencniho trojuhelniku na troj. ABC (ia,ib,ic - indexy vrcholu)
00040     (L1,L2,L3)=MTransf*(1,x,y)   
00041     MTransfInv*(L1,L2,L3)=(1,x,y)
00042     kde L1,L2,L3 jsou barycentricke souradnice, x,y jsou souradnice bodu v trojuhelniku ABC.
00043  */
00044 void construct_mat(matrix *A,long n,long m);                                     /**< Construct matrix A of order n X m */
00045 void construct_mat_copy(matrix *A,const matrix B);                               /**< Construct copy of matrix B and puts it into B */
00046 void construct_mat_transpose(matrix *out,const matrix in);                       /**< Makes transport of in and puts it into out  */
00047 void construct_mat_multiply(matrix *out,const matrix A,const matrix B);          /**< Construct Matrix Multiplication out:=A*B */
00048 void mat_transf(matrix out,long ia,long ib,long ic,double *_x,double *_y);       
00049 /**< Creates the transformation matrix from the element ABC onto the reference triangle. 
00050  *
00051  *  Let \f$ A =(x_{i_a},y_{i_a}), B =(x_{i_b},y_{i_b}), C =(x_{i_c},y_{i_c}), \f$.
00052  *
00053  *  Let us denote it \f$\bf M\f$ the matrix of linear transformation
00054  *
00055  *  from the reference triangle \f$ \hat{T}\f$ onto triangle \f$ T=\triangle ABC\f$.
00056  *
00057  *  we can write it in the baricentric coordinates as 
00058  *
00059  * \f$ F_{T}(\lambda_1,\lambda_2,\lambda_3) = 
00060  *     \bf b + \bf M \cdot (\lambda_1,\lambda_2,\lambda_3)^T
00061  *  \f$
00062  *
00063  *  The computed matrix out is then \f$ \bf M^{-1} \f$.
00064  */
00065 void mat_transfinv(matrix out,long ia,long ib,long ic,double *_x,double *_y);
00066 /**< Creates the transformation matrix from  the reference triangle onto the element ABC. 
00067  *
00068  * Let \f$ A =(x_{i_a},y_{i_a}), B =(x_{i_b},y_{i_b}), C =(x_{i_c},y_{i_c}), \f$, then 
00069  *  the matrix out (let us denote it \f$\bf M\f$ the matrix of linear transformation
00070  *  from the reference triangle \f$ \hat{T}\f$ onto triangle \f$ T=\triangle ABC\f$, i.e.
00071  *  we can write it in the baricentric coordinates as 
00072  *
00073  * \f$ F_{T}(\lambda_1,\lambda_2,\lambda_3) = 
00074  *     \bf b + \bf M \cdot (\lambda_1,\lambda_2,\lambda_3)^T
00075  *  \f$
00076  *
00077  *  The computed matrix is then \f$ \bf M \f$, i.e.
00078  *  \f$ M= \left( \begin{array}{rrr} 1 1 1 \\ x_{i_a} x_{i_b} x_{i_c} \\ y_{i_a} y_{i_b} y_{i_c} \end{array} \right)\f$
00079  */
00080 
00081 void destruct_mat(matrix *A);
00082 /* 
00083    function vypis() - vypis fmatrix do souboru
00084  */
00085 void save_mat(const matrix which,char *filename);
00086 /*
00087   function transpose()
00088   provede transponovani matice do jiz alokovane matice odpovidajicich rozmeru
00089  */
00090 void transpose_mat(matrix *out,const matrix in);
00091 /*
00092   function multiply()
00093   maticove nasobeni resp. nasobeni skalarem
00094  */
00095 void matrix_multiply_mat(matrix *out,const matrix A,const matrix B);
00096 void multiply_mat(matrix M,const double beta);
00097 /* 
00098    function add/subtract()
00099    A:= A+B/A-B 
00100    function multiply_rows()
00101    A[i]:=A[i]*v[i] nasobeni radku matice 
00102  */
00103 void zeroize_mat(matrix A);
00104 void add_mat(matrix A,const matrix B);
00105 void subtract_mat(matrix A,const matrix B);
00106 void multiply_mat_rows(matrix A,const vector v);
00107 /*
00108   function multiply()
00109   out:=A*v (out jiz ma byt alokovano na odpovidajici velikost!)
00110   resp. out:=v*A
00111  */
00112 void matrix_reziduum(vector out,const matrix A,const vector v);
00113 void matrix_multiply_right(vector out,const matrix A,const vector v);
00114 void matrix_multiply_left(vector out,const vector v,const matrix A);
00115 /*
00116   function solve()
00117 
00118   GJ eliminacni algoritmus pro reseni soustavy linarnich rovnic
00119   sol:=A\b (sol jiz alokovano!)
00120 
00121   function Rsolve()
00122   
00123   out:=R\b, pouze prvnich k-radek je brano v uvahu, R - horni trojuhelnikova matice(predpoklad)
00124  */
00125 void solve_mat(vector sol,const matrix A,const vector b);
00126 void upper_solve_mat(vector out,const matrix R,const vector b,long k);
00127 void ludcmp(matrix out);
00128 void lusolve(vector sol,const matrix out,const vector rhs);
00129 /*@}*/
00130 /* -------------------------------------------------------------------------- */
00131 #endif
00132 
00133 

Generated on Sun May 27 11:59:43 2007 for FEMFLUID by  doxygen 1.4.6