dense AD: fix a few stupid bugs
e.g., looping over the wrong range or an infinite loop. also, the dense-AD unit test is shortend to test one specialization and the unspecialized class.
This commit is contained in:
parent
bf771b09b4
commit
2f44918a2b
@ -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) %}
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user