GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmNewtonCotesIntegrationTables.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
25#ifndef _GEMA_NEWTON_INT_TABLES_H_
26#define _GEMA_NEWTON_INT_TABLES_H_
27
28#include "gmCoreConfig.h"
29#include "gmVector.h"
30
31#include <QVector>
32
37{
38public:
39
44 static const QVector<QPair<double, double>>* lineRuleTable(int rule, bool closed)
45 {
46 return select(rule, closed, _closedLineTable, _openLineTable);
47 }
48
54 static int lineRuleDegree(int rule) { return rule%2 ? rule : rule-1; }
55
60 static const QVector<QPair<GmVector, double>>* triRuleTable(int rule, bool closed)
61 {
62 return select(rule, closed, _closedTriTable, _openTriTable);
63 }
64
69 static int triRuleDegree(int rule) { return rule; }
70
75 static const QVector<QPair<GmVector, double>>* tetRuleTable(int rule, bool closed)
76 {
77 return select(rule, closed, _closedTetTable, _openTetTable);
78 }
79
84 static int tetRuleDegree(int rule) { return rule; }
85
86 static bool initTables();
87
88private:
89
91 template <class T> static const T* select(int rule, bool closed, const T ct[], const T ot[])
92 {
93
94 if(rule < 1 || rule > 5)
95 return NULL;
96 if(closed)
97 {
98 assert(!ct[rule-1].isEmpty());
99 return &ct[rule-1];
100 }
101 else
102 {
103 assert(!ot[rule-1].isEmpty());
104 return &ot[rule-1];
105 }
106 }
107
108 static void initLineTables();
109 static void initTriTables();
110 static void initTetTables();
111
112 static void simplexRulesPermutations(const char* s, QStringList& permutations);
113 static double simplexRulesPointAndWeight(int degree, const char* index, int u, int num, int den, QVector<GmVector>& posList);
114
115
117 static QVector<QPair<double, double>> _closedLineTable[5];
118
120 static QVector<QPair<double, double>> _openLineTable[5];
121
125 static QVector<QPair<GmVector, double>> _closedTriTable[5];
126
130 static QVector<QPair<GmVector, double>> _openTriTable[5];
131
135 static QVector<QPair<GmVector, double>> _closedTetTable[5];
136
140 static QVector<QPair<GmVector, double>> _openTetTable[5];
141};
142
143#endif
A class storing tables with (position, weight) pairs for line, triangle and tetrahedron Open & closed...
Definition gmNewtonCotesIntegrationTables.h:37
static const QVector< QPair< GmVector, double > > * tetRuleTable(int rule, bool closed)
Returns the table storing (position, weight) pairs for the given open or closed tetrahedron Newton Co...
Definition gmNewtonCotesIntegrationTables.h:75
static int tetRuleDegree(int rule)
Returns the integration degree for the given tetrahedron Newton rule (The polynomial degree for which...
Definition gmNewtonCotesIntegrationTables.h:84
static const QVector< QPair< double, double > > * lineRuleTable(int rule, bool closed)
Returns the table storing (position, weight) pairs for the given open or closed line Newton Cotes rul...
Definition gmNewtonCotesIntegrationTables.h:44
static int triRuleDegree(int rule)
Returns the integration degree for the given triangle Newton rule (The polynomial degree for which th...
Definition gmNewtonCotesIntegrationTables.h:69
static const QVector< QPair< GmVector, double > > * triRuleTable(int rule, bool closed)
Returns the table storing (position, weight) pairs for the given open or closed triangle Newton Cotes...
Definition gmNewtonCotesIntegrationTables.h:60
static const T * select(int rule, bool closed, const T ct[], const T ot[])
Helper function retuning the rule table selecting from the open or closed version.
Definition gmNewtonCotesIntegrationTables.h:91
static int lineRuleDegree(int rule)
Returns the integration degree for the given line Newton Cotes rule (The polynomial degree for which ...
Definition gmNewtonCotesIntegrationTables.h:54
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Declaration of the GmVector class.