Flow123d  jenkins-Flow123d-linux-release-multijob-282
math_fce.h
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2007 Technical University of Liberec. All rights reserved.
4  *
5  * Please make a following refer to Flow123d on your project site if you use the program for any purpose,
6  * especially for academic research:
7  * Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic
8  *
9  * This program is free software; you can redistribute it and/or modify it under the terms
10  * of the GNU General Public License version 3 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with this program; if not,
17  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
18  *
19  *
20  * $Id$
21  * $Revision$
22  * $LastChangedBy$
23  * $LastChangedDate$
24  *
25  * @file
26  * @brief ???
27  *
28  */
29 
30 #ifndef MATH_H
31 #define MATH_H
32 
33 // TODO: Only mh_fe_values depends on this file. This file can be removed.
34 
35 //! small matrix types
36 typedef double SmallVec1_t[1];
37 typedef double SmallVec2_t[2];
38 typedef double SmallVec3_t[3];
39 typedef double SmallVec4_t[4];
40 
45 
46 
47 //! Numerical helpers
48 #include <float.h>
49 // DBL_MIN approx.= 2.22507e-308, least nonzero double
50 
51 // this should be used when we want to keep first digit nonzero
52 // such number have full double precision, smaller numbers loose precision
53 #define NUM_ZERO DBL_MIN/DBL_EPSILON
54 
55 // each use of ESP(value) indicate that we use some small value
56 // this small value should be relative to the number we want to compare
57 #define EPS(value) (value)
58 
59 // OBSOLETE
60 #define ZERO EPS(1e-12)
61 
62 #define DBL_EQ(i,j) (fabs((i)-(j))<NUM_ZERO)
63 #define DBL_GE(i,j) ((i)>(j)-NUM_ZERO)
64 #define DBL_LE(i,j) ((i)<(j)+NUM_ZERO)
65 #define DBL_GT(i,j) ((i)>(j)+NUM_ZERO)
66 #define DBL_LT(i,j) ((i)<(j)-NUM_ZERO)
67 
68 //! Usefull math macros
69 #define SQUARE(x) ((x) * (x))
70 #define SGN(x) ( ((x)>ZERO)? (1) : ( ((x)<(-ZERO))? (-1) : (0) ) )
71 #define SUBDET2(i,j,k,l) (a[(i)][(k)]*a[(j)][(l)]-a[(i)][(l)]*a[(j)][(k)])
72 #ifndef M_PI
73  #define M_PI 3.14159265358979323846264338327950288f
74 #endif
75 
76 // vector functions
77 double vector_length(double[]);
78 double scalar_product(double[],double[]);
79 void normalize_vector(double[]);
80 void scale_vector(double[],double);
81 
82 void vector_product(double[],double[],double[]);
83 void vector_difference(double[],double[],double[]);
84 // small matrix operations
85 double Det3( SmallMtx3 a);
86 double MatrixInverse(double *a,double *b,int size);
87 void PrintSmallMatrix(double *mtx, int size );
88 #endif
89 //-----------------------------------------------------------------------------
90 // vim: set cindent:
double SmallVec4_t[4]
Definition: math_fce.h:39
void vector_product(double u[], double v[], double x[])
Definition: math_fce.cc:80
SmallVec3_t * SmallMtx3
Definition: math_fce.h:43
double SmallVec1_t[1]
small matrix types
Definition: math_fce.h:36
SmallVec4_t * SmallMtx4
Definition: math_fce.h:44
void normalize_vector(double u[])
Definition: math_fce.cc:60
double vector_length(double v[])
Definition: math_fce.cc:46
void scale_vector(double u[], double k)
Definition: math_fce.cc:72
double scalar_product(double u[], double v[])
Definition: math_fce.cc:53
SmallVec1_t * SmallMtx1
Definition: math_fce.h:41
void PrintSmallMatrix(double *mtx, int size)
Definition: math_fce.cc:226
double Det3(SmallMtx3 a)
Definition: math_fce.cc:106
double MatrixInverse(double *a, double *b, int size)
Definition: math_fce.cc:116
void vector_difference(double u[], double v[], double x[])
Definition: math_fce.cc:92
double SmallVec2_t[2]
Definition: mh_fe_values.hh:21
double SmallVec3_t[3]
Definition: math_fce.h:38
SmallVec2_t * SmallMtx2
Definition: mh_fe_values.hh:22