Merge pull request #4 from andlaus/generated_eval_specializations_v3

dense AD: fix a few stupid bugs due to code generation
This commit is contained in:
dr-robertk 2017-03-20 10:23:07 +01:00 committed by GitHub
commit d6bb4353c2
15 changed files with 131 additions and 50 deletions

View File

@ -205,8 +205,13 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
{% if numDerivs < 0 %}
for (int i = dstart_; i < dend_; ++i)
data_[i] = other.data_[i];
{% else %}
{% for i in range(1, numDerivs+1) %}
data_[{{i}}] = other.data_[{{i}}];{% endfor %}
{% endif %}
}
@ -269,7 +274,7 @@ public:
// derivatives
{% if numDerivs < 0 %}
for (int i = 0; i < length_; ++i)
for (int i = dstart_; i < dend_; ++i)
this->data_[i] = this->data_[i]*v + other.data_[i] * u;
{% else %}
{% for i in range(1, numDerivs+1) %}
@ -306,7 +311,7 @@ public:
// derivatives
{% if numDerivs < 0 %}
for (int i = 0; i < length_; ++i)
for (int i = dstart_; i < dend_; ++i)
data_[i] = data_[i]*v_vv - other.data_[i]*u_vv;
{% else %}
{% for i in range(1, numDerivs+1) %}

View File

@ -161,8 +161,10 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
for (int i = dstart_; i < dend_; ++i)
data_[i] = other.data_[i];
}
@ -219,7 +221,7 @@ public:
// derivatives
for (int i = 0; i < length_; ++i)
for (int i = dstart_; i < dend_; ++i)
this->data_[i] = this->data_[i]*v + other.data_[i] * u;
@ -250,7 +252,7 @@ public:
// derivatives
for (int i = 0; i < length_; ++i)
for (int i = dstart_; i < dend_; ++i)
data_[i] = data_[i]*v_vv - other.data_[i]*u_vv;

View File

@ -159,8 +159,10 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
}

View File

@ -177,8 +177,19 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
data_[4] = other.data_[4];
data_[5] = other.data_[5];
data_[6] = other.data_[6];
data_[7] = other.data_[7];
data_[8] = other.data_[8];
data_[9] = other.data_[9];
data_[10] = other.data_[10];
}

View File

@ -179,8 +179,20 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
data_[4] = other.data_[4];
data_[5] = other.data_[5];
data_[6] = other.data_[6];
data_[7] = other.data_[7];
data_[8] = other.data_[8];
data_[9] = other.data_[9];
data_[10] = other.data_[10];
data_[11] = other.data_[11];
}

View File

@ -181,8 +181,21 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
data_[4] = other.data_[4];
data_[5] = other.data_[5];
data_[6] = other.data_[6];
data_[7] = other.data_[7];
data_[8] = other.data_[8];
data_[9] = other.data_[9];
data_[10] = other.data_[10];
data_[11] = other.data_[11];
data_[12] = other.data_[12];
}

View File

@ -161,8 +161,11 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
}

View File

@ -163,8 +163,12 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
}

View File

@ -165,8 +165,13 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
data_[4] = other.data_[4];
}

View File

@ -167,8 +167,14 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
data_[4] = other.data_[4];
data_[5] = other.data_[5];
}

View File

@ -169,8 +169,15 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
data_[4] = other.data_[4];
data_[5] = other.data_[5];
data_[6] = other.data_[6];
}

View File

@ -171,8 +171,16 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
data_[4] = other.data_[4];
data_[5] = other.data_[5];
data_[6] = other.data_[6];
data_[7] = other.data_[7];
}

View File

@ -173,8 +173,17 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
data_[4] = other.data_[4];
data_[5] = other.data_[5];
data_[6] = other.data_[6];
data_[7] = other.data_[7];
data_[8] = other.data_[8];
}

View File

@ -175,8 +175,18 @@ public:
// copy all derivatives from other
void copyDerivatives(const Evaluation& other)
{
for (int i = dstart_; 0 < dend_; ++i)
data_[i] = other.data_[i];
data_[1] = other.data_[1];
data_[2] = other.data_[2];
data_[3] = other.data_[3];
data_[4] = other.data_[4];
data_[5] = other.data_[5];
data_[6] = other.data_[6];
data_[7] = other.data_[7];
data_[8] = other.data_[8];
data_[9] = other.data_[9];
}

View File

@ -647,31 +647,15 @@ inline void testAll()
};//TestEnv
template <class Scalar, int numVars>
struct TestAll
{
static void test()
{
TestEnv< Scalar, numVars >().testAll();
TestAll< Scalar, numVars-1>::test();
}
};
template <class Scalar>
struct TestAll<Scalar, 2>
{
static void test()
{
TestEnv< Scalar, 2 >().testAll();
}
};
int main(int argc, char **argv)
{
Dune::MPIHelper::instance(argc, argv);
TestAll<double, 15>::test();
TestAll<float, 15>::test();
TestEnv<double, 15>().testAll();
TestEnv<double, 2>().testAll();
TestEnv<float, 15>().testAll();
TestEnv<float, 2>().testAll();
return 0;
}