MOAB: Mesh Oriented datABase  (version 5.2.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, const double* vars, const int degree,
00041                                              std::vector< double >& basis );
00042 
00043     //! \brief compute multivariate vandermonde matrix, monomial basis ordered in the same way as
00044     //! gen_multivar_monomial_basis
00045     /** if degree = 0, V = {1,...,1}';
00046         *If kvars = 1, us = {u1;u2;..,;um}, degree = k, V = {1 u1 u1^2 ... u1^k;1 u2 u2^2 ...
00047        u2^k;...;1 um um^2 ... um^k}; *If kvars = 2, us = {u1 v1;u2 v2;...;um vm}, degree = k, V = {1
00048        u1 v1 u1^2 u1v1 v1^2;...;1 um vm um^2 umvm vm^2};
00049         * \param mrows Integer, number of points to evaluate Vandermonde matrix
00050         * \param kvars Integer, number of variables
00051         * \param us Pointer to array of doubles, size = mrow*kvars, variable values for all points.
00052        Stored in row-wise, like {u1 v1 u2 v2 ...}
00053         * \param degree Integer, maximum degree
00054         * \param basis Reference to vector, user input container to hold Vandermonde matrix which is
00055        appended to existing data; users don't have to preallocate for basis, this function will
00056        allocate interally; the Vandermonde matrix is stored in an array, columnwise, like {1 ... 1
00057        u1 ...um u1^2 ... um^2 ...}
00058     */
00059     static void gen_vander_multivar( const int mrows, const int kvars, const double* us, const int degree,
00060                                      std::vector< double >& V );
00061 
00062     static void rescale_matrix( int mrows, int ncols, double* V, double* ts );
00063 
00064     static void compute_qtransposeB( int mrows, int ncols, const double* Q, int bncols, double* bs );
00065 
00066     static void qr_polyfit_safeguarded( const int mrows, const int ncols, double* V, double* D, int* rank );
00067 
00068     static void backsolve( int mrows, int ncols, double* R, int bncols, double* bs, double* ws );
00069 
00070     static void backsolve_polyfit_safeguarded( int dim, int degree, const bool interp, int mrows, int ncols, double* R,
00071                                                int bncols, double* bs, const double* ws, int* degree_out );
00072 
00073     static void vec_dotprod( const int len, const double* a, const double* b, double* c );
00074 
00075     static void vec_scalarprod( const int len, const double* a, const double c, double* b );
00076 
00077     static void vec_crossprod( const double a[3], const double b[3], double ( &c )[3] );
00078 
00079     static double vec_innerprod( const int len, const double* a, const double* b );
00080 
00081     static double vec_2norm( const int len, const double* a );
00082 
00083     static double vec_normalize( const int len, const double* a, double* b );
00084 
00085     static double vec_distance( const int len, const double* a, const double* b );
00086 
00087     static void vec_projoff( const int len, const double* a, const double* b, double* c );
00088 
00089     static void vec_linear_operation( const int len, const double mu, const double* a, const double psi,
00090                                       const double* b, double* c );
00091 
00092     static void get_tri_natural_coords( const int dim, const double* cornercoords, const int npts,
00093                                         const double* currcoords, double* naturalcoords );
00094 };
00095 
00096 }  // namespace moab
00097 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines