MOAB: Mesh Oriented datABase  (version 5.4.1)
DGMSolver.hpp
Go to the documentation of this file.
00001 #ifndef DGMSOLVER_HPP
00002 #define DGMSOLVER_HPP
00003 #include <vector>
00004 
00005 namespace moab
00006 {
00007 
00008 class DGMSolver
00009 {
00010     DGMSolver(){};
00011     ~DGMSolver(){};
00012 
00013   public:
00014     //! \brief compute combinational number, n choose k, maximum output is
00015     //! std::numeric_limits<unsigned int>::max();
00016     // If overflows, return 0
00017     static unsigned int nchoosek( unsigned int n, unsigned int k );
00018 
00019     //! \brief compute the number of columns for a multivariate vandermonde matrix, given certen
00020     //! degree
00021     /** If degree = 0, out put is 1;
00022      *If kvars = 1, degree = k, output is k+1;
00023      *If kvars = 2, degree = k, output is (k+2)*(k+1)/2;
00024      */
00025     static unsigned int compute_numcols_vander_multivar( unsigned int kvars, unsigned int degree );
00026 
00027     //! \brief compute the monomial basis of mutiple variables, up to input degree,
00028     //! lexicographically ordered
00029     /** if degree = 0, output basis = {1}
00030      *If kvars = 1, vars = {u}, degree = k, basis = {1,u,...,u^k}
00031      *If kvars = 2, vars = {u,v}, degree = k, basis =
00032      *{1,u,v,u^2,uv,v^2,u^3,u^2*v,uv^2,v^3,...,u^k,u^k-1*v,...,uv^k-1,v^k} If kvars = 3, vars =
00033      *{u,v,w}, degree = k, basis =
00034      *{1,u,v,w,u^2,uv,uw,v^2,v*w,w^2,...,u^k,u^k-1v,u^k-1w,...,v^k,v^k-1w,...,vw^k-1,w^k} \param
00035      *kvars Integer, number of variables \param vars Pointer to array of doubles, size = kvars,
00036      *variable values \param degree Integer, maximum degree \param basis Reference to vector, user
00037      *input container to hold output which is appended to existing data; users don't have to
00038      *preallocate for basis, this function will allocate interally
00039      */
00040     static void gen_multivar_monomial_basis( const int kvars,
00041                                              const double* vars,
00042                                              const int degree,
00043                                              std::vector< double >& basis );
00044 
00045     //! \brief compute multivariate vandermonde matrix, monomial basis ordered in the same way as
00046     //! gen_multivar_monomial_basis
00047     /** if degree = 0, V = {1,...,1}';
00048         *If kvars = 1, us = {u1;u2;..,;um}, degree = k, V = {1 u1 u1^2 ... u1^k;1 u2 u2^2 ...
00049        u2^k;...;1 um um^2 ... um^k}; *If kvars = 2, us = {u1 v1;u2 v2;...;um vm}, degree = k, V = {1
00050        u1 v1 u1^2 u1v1 v1^2;...;1 um vm um^2 umvm vm^2};
00051         * \param mrows Integer, number of points to evaluate Vandermonde matrix
00052         * \param kvars Integer, number of variables
00053         * \param us Pointer to array of doubles, size = mrow*kvars, variable values for all points.
00054        Stored in row-wise, like {u1 v1 u2 v2 ...}
00055         * \param degree Integer, maximum degree
00056         * \param basis Reference to vector, user input container to hold Vandermonde matrix which is
00057        appended to existing data; users don't have to preallocate for basis, this function will
00058        allocate interally; the Vandermonde matrix is stored in an array, columnwise, like {1 ... 1
00059        u1 ...um u1^2 ... um^2 ...}
00060     */
00061     static void gen_vander_multivar( const int mrows,
00062                                      const int kvars,
00063                                      const double* us,
00064                                      const int degree,
00065                                      std::vector< double >& V );
00066 
00067     static void rescale_matrix( int mrows, int ncols, double* V, double* ts );
00068 
00069     static void compute_qtransposeB( int mrows, int ncols, const double* Q, int bncols, double* bs );
00070 
00071     static void qr_polyfit_safeguarded( const int mrows, const int ncols, double* V, double* D, int* rank );
00072 
00073     static void backsolve( int mrows, int ncols, double* R, int bncols, double* bs, double* ws );
00074 
00075     static void backsolve_polyfit_safeguarded( int dim,
00076                                                int degree,
00077                                                const bool interp,
00078                                                int mrows,
00079                                                int ncols,
00080                                                double* R,
00081                                                int bncols,
00082                                                double* bs,
00083                                                const double* ws,
00084                                                int* degree_out );
00085 
00086     static void vec_dotprod( const int len, const double* a, const double* b, double* c );
00087 
00088     static void vec_scalarprod( const int len, const double* a, const double c, double* b );
00089 
00090     static void vec_crossprod( const double a[3], const double b[3], double ( &c )[3] );
00091 
00092     static double vec_innerprod( const int len, const double* a, const double* b );
00093 
00094     static double vec_2norm( const int len, const double* a );
00095 
00096     static double vec_normalize( const int len, const double* a, double* b );
00097 
00098     static double vec_distance( const int len, const double* a, const double* b );
00099 
00100     static void vec_projoff( const int len, const double* a, const double* b, double* c );
00101 
00102     static void vec_linear_operation( const int len,
00103                                       const double mu,
00104                                       const double* a,
00105                                       const double psi,
00106                                       const double* b,
00107                                       double* c );
00108 
00109     static void get_tri_natural_coords( const int dim,
00110                                         const double* cornercoords,
00111                                         const int npts,
00112                                         const double* currcoords,
00113                                         double* naturalcoords );
00114 };
00115 
00116 }  // namespace moab
00117 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines