[Dune] What is the convention for specialized class functions in Dune
Aleksejs Fomins
aleksejs.fomins at lspr.ch
Mon Aug 4 15:19:19 CEST 2014
Dear Dune,
I would like to implement the elementInterpolator class, which uses
lagrange polynomials to interpolate over the element of a given type,
given interpolation order.
So far I have implemented classes triangleInterpolator and
tetrahedronInterpolator, but I thought it would be much more scalable to
generalize all of them to one class such that other element type
functionality could be easily added
So the question:
I would like to have one class with general interpolation functionality,
and a sub-function interpolate which would depend on the particular
element chosen.
Would you suggest doing it using templates or using overloading?
I have tried to do it using templates, writing a little test program
below, but it has an error and I don't seem to be able to find online
what is wrong with it.
Thank you,
Aleksejs
--------------------------------------------------------------------------
#include <iostream>
using namespace std;
template <int cl, int dim>
class impl_prototype {
public:
impl_prototype() {}
int f(int x) { return cl + 2 * g(x); }
int g(int x) { return cl + 1 * x;}
};
template <int cl>
int impl_prototype<cl, 1>::g(int x) { return cl + 3 * x; }
int main ()
{
impl_prototype<0, 0> test_0;
impl_prototype<0, 1> test_1;
cout << test_0.f(5) << " " << test_0.g(5) << std::endl;
cout << test_1.f(5) << " " << test_1.g(5) << std::endl;
return 0;
}
------------------------------------------------------------------------------
template_test.cpp:15:35: error: invalid use of incomplete type ‘class
impl_prototype<cl, 1>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20140804/df90074a/attachment.sig>
More information about the Dune
mailing list