Skip to content
Snippets Groups Projects
Commit ab914244 authored by Oliver Sander's avatar Oliver Sander Committed by sander@FU-BERLIN.DE
Browse files

Make the number of digits of the MultiIndex by a dynamic quantity.

This is needed to test quad elements and higher-order gfe.

[[Imported from SVN: r8047]]
parent dbf8c097
No related branches found
No related tags found
No related merge requests found
......@@ -156,7 +156,7 @@ int main(int argc, char** argv)
// Set up elements of SO(3)
std::vector<TargetSpace> corners(domainDim+1);
MultiIndex<domainDim+1> index(nTestPoints);
MultiIndex index(domainDim+1, nTestPoints);
int numIndices = index.cycle();
for (int i=0; i<numIndices; i++, ++index) {
......
......@@ -127,7 +127,7 @@ void testUnitVector3d()
// Set up elements of S^2
std::vector<TargetSpace> coefficients(dim+1);
MultiIndex<dim+1> index(nTestPoints);
MultiIndex index(dim+1, nTestPoints);
int numIndices = index.cycle();
for (int i=0; i<numIndices; i++, ++index) {
......
......@@ -275,7 +275,7 @@ void test()
// Set up elements of the target space
std::vector<TargetSpace> corners(domainDim+1);
MultiIndex<domainDim+1> index(nTestPoints);
MultiIndex index(domainDim+1, nTestPoints);
int numIndices = index.cycle();
for (int i=0; i<numIndices; i++, ++index) {
......
......@@ -116,7 +116,7 @@ void testHessian()
// Set up elements of S^2
std::vector<TargetSpace> coefficients(domainDim+1);
MultiIndex<domainDim+1> index(nTestPoints);
MultiIndex index(domainDim+1, nTestPoints);
int numIndices = index.cycle();
size_t nDofs = domainDim+1;
......
......@@ -34,7 +34,7 @@ void test()
// Set up elements of SO(3)
std::vector<TargetSpace> coefficients(domainDim+1);
MultiIndex<domainDim+1> index(nTestPoints);
MultiIndex index(domainDim+1, nTestPoints);
int numIndices = index.cycle();
PQkLocalFiniteElementCache<double,double,domainDim,1> feCache;
......
#ifndef MULTI_INDEX_HH
#define MULTI_INDEX_HH
#include <dune/common/array.hh>
#include <vector>
/** \brief N-dimensional multi-index
/** \brief A multi-index
*/
template <int N>
class MultiIndex
: public Dune::array<unsigned int,N>
: public std::vector<unsigned int>
{
// The range of each component
unsigned int limit_;
public:
/** \brief Constructor with a given range for each digit */
MultiIndex(unsigned int limit)
: limit_(limit)
/** \brief Constructor with a given range for each digit
* \param n Number of digits
*/
MultiIndex(unsigned int n, unsigned int limit)
: std::vector<unsigned int>(n),
limit_(limit)
{
std::fill(this->begin(), this->end(), 0);
}
......@@ -24,7 +26,7 @@ public:
/** \brief Increment the MultiIndex */
MultiIndex& operator++() {
for (int i=0; i<N; i++) {
for (size_t i=0; i<size(); i++) {
// Augment digit
(*this)[i]++;
......@@ -42,7 +44,7 @@ public:
/** \brief Compute how many times you can call operator++ before getting to (0,...,0) again */
size_t cycle() const {
size_t result = 1;
for (int i=0; i<N; i++)
for (size_t i=0; i<size(); i++)
result *= limit_;
return result;
}
......
......@@ -16,7 +16,7 @@ int main()
int nTestValues = 5;
double maxDiff = 0;
MultiIndex<N*M> index(nTestValues);
MultiIndex index(N*M, nTestValues);
int numIndices = index.cycle();
for (int i=0; i<numIndices; i++, ++index) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment