Skip to content

Commit

Permalink
add doc and clean cmake file
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSiebert1 committed Oct 14, 2024
1 parent 7a8beb3 commit d2e86b7
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 113 deletions.
54 changes: 26 additions & 28 deletions ADOL-C/c_interface/ADOLC_TB_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Constructor & Destructor for class tape-based adouble
*/
extern "C"
{
// Constructor
TBAdoubleHandle create_tb_adouble(double x)
TBAdoubleHandle create_tb_adouble(const double x)
{
return new adouble(x);
}
Expand All @@ -16,7 +15,6 @@ extern "C"
return new adouble();
}

// Destructor
void free_tb_adouble(TBAdoubleHandle a)
{
return delete static_cast<adouble *>(a);
Expand All @@ -43,139 +41,139 @@ extern "C"
{
return new adouble(*static_cast<adouble *>(a) + *static_cast<adouble *>(b));
}
TBAdoubleHandle add_double_tb_adouble(double x, TBAdoubleHandle b)
TBAdoubleHandle add_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return new adouble(x + *static_cast<adouble *>(b));
}
TBAdoubleHandle add_tb_adouble_double(TBAdoubleHandle a, double x)
TBAdoubleHandle add_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return new adouble(*static_cast<adouble *>(a) + x);
}
TBAdoubleHandle mult_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return new adouble(*static_cast<adouble *>(a) * *static_cast<adouble *>(b));
}
TBAdoubleHandle mult_double_tb_adouble(double x, TBAdoubleHandle b)
TBAdoubleHandle mult_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return new adouble(x * *static_cast<adouble *>(b));
}
TBAdoubleHandle mult_tb_adouble_double(TBAdoubleHandle a, double x)
TBAdoubleHandle mult_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return new adouble(*static_cast<adouble *>(a) * x);
}
TBAdoubleHandle subtr_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return new adouble(*static_cast<adouble *>(a) - *static_cast<adouble *>(b));
}
TBAdoubleHandle subtr_double_tb_adouble(double x, TBAdoubleHandle b)
TBAdoubleHandle subtr_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return new adouble(x - *static_cast<adouble *>(b));
}
TBAdoubleHandle subtr_tb_adouble_double(TBAdoubleHandle a, double x)
TBAdoubleHandle subtr_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return new adouble(*static_cast<adouble *>(a) - x);
}
TBAdoubleHandle div_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return new adouble(*static_cast<adouble *>(a) / *static_cast<adouble *>(b));
}
TBAdoubleHandle div_double_tb_adouble(double x, TBAdoubleHandle b)
TBAdoubleHandle div_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return new adouble(x / *static_cast<adouble *>(b));
}
TBAdoubleHandle div_tb_adouble_double(TBAdoubleHandle a, double x)
TBAdoubleHandle div_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return new adouble(*static_cast<adouble *>(a) / x);
}
TBAdoubleHandle max_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return new adouble(fmax(*static_cast<adouble *>(a), *static_cast<adouble *>(b)));
}
TBAdoubleHandle max_double_tb_adouble(double x, TBAdoubleHandle b)
TBAdoubleHandle max_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return new adouble(fmax(x, *static_cast<adouble *>(b)));
}
TBAdoubleHandle max_tb_adouble_double(TBAdoubleHandle a, double x)
TBAdoubleHandle max_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return new adouble(fmax(*static_cast<adouble *>(a), x));
}
TBAdoubleHandle min_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return new adouble(fmin(*static_cast<adouble *>(a), *static_cast<adouble *>(b)));
}
TBAdoubleHandle min_double_tb_adouble(double x, TBAdoubleHandle b)
TBAdoubleHandle min_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return new adouble(fmin(x, *static_cast<adouble *>(b)));
}
TBAdoubleHandle min_tb_adouble_double(TBAdoubleHandle a, double x)
TBAdoubleHandle min_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return new adouble(fmin(*static_cast<adouble *>(a), x));
}
TBAdoubleHandle pow_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return new adouble(pow(*static_cast<adouble *>(a), *static_cast<adouble *>(b)));
}
TBAdoubleHandle pow_tb_adouble_double(TBAdoubleHandle a, double x)
TBAdoubleHandle pow_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return new adouble(pow(*static_cast<adouble *>(a), x));
}
bool ge_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return *static_cast<adouble *>(a) >= *static_cast<adouble *>(b);
}
bool ge_double_tb_adouble(double x, TBAdoubleHandle b)
bool ge_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return x >= *static_cast<adouble *>(b);
}
bool ge_tb_adouble_double(TBAdoubleHandle a, double x)
bool ge_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return *static_cast<adouble *>(a) >= x;
}
bool g_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return *static_cast<adouble *>(a) > *static_cast<adouble *>(b);
}
bool g_double_tb_adouble(double x, TBAdoubleHandle b)
bool g_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return x > *static_cast<adouble *>(b);
}
bool g_tb_adouble_double(TBAdoubleHandle a, double x)
bool g_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return *static_cast<adouble *>(a) > x;
}
bool le_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return *static_cast<adouble *>(a) <= *static_cast<adouble *>(b);
}
bool le_double_tb_adouble(double x, TBAdoubleHandle b)
bool le_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return x <= *static_cast<adouble *>(b);
}
bool le_tb_adouble_double(TBAdoubleHandle a, double x)
bool le_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return *static_cast<adouble *>(a) <= x;
}
bool l_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return *static_cast<adouble *>(a) < *static_cast<adouble *>(b);
}
bool l_double_tb_adouble(double x, TBAdoubleHandle b)
bool l_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return x < *static_cast<adouble *>(b);
}
bool l_tb_adouble_double(TBAdoubleHandle a, double x)
bool l_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return *static_cast<adouble *>(a) < x;
}
bool eq_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b)
{
return *static_cast<adouble *>(a) == *static_cast<adouble *>(b);
}
bool eq_double_tb_adouble(double x, TBAdoubleHandle b)
bool eq_double_tb_adouble(const double x, TBAdoubleHandle b)
{
return x == *static_cast<adouble *>(b);
}
bool eq_tb_adouble_double(TBAdoubleHandle a, double x)
bool eq_tb_adouble_double(TBAdoubleHandle a, const double x)
{
return *static_cast<adouble *>(a) == x;
}
Expand Down Expand Up @@ -255,7 +253,7 @@ extern "C"
{
return new adouble(floor(*static_cast<adouble *>(a)));
}
TBAdoubleHandle tb_ldexp(TBAdoubleHandle a, int n)
TBAdoubleHandle tb_ldexp(TBAdoubleHandle a, const int n)
{
return new adouble(ldexp(*static_cast<adouble *>(a), n));
}
Expand All @@ -278,7 +276,7 @@ extern "C"
{
return trace_off(flag);
}
void create_independent(TBAdoubleHandle a, double x)
void create_independent(TBAdoubleHandle a, const double x)
{
*static_cast<adouble *>(a) <<= x;
}
Expand Down
50 changes: 25 additions & 25 deletions ADOL-C/c_interface/ADOLC_TB_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern "C"
{
#endif
// Constructor
TBAdoubleHandle create_tb_adouble(double x);
TBAdoubleHandle create_tb_adouble(const double x);
TBAdoubleHandle create_tb_adouble_empty();

// Destructor
Expand Down Expand Up @@ -48,51 +48,51 @@ extern "C"
{
#endif
TBAdoubleHandle add_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
TBAdoubleHandle add_double_tb_adouble(double x, TBAdoubleHandle b);
TBAdoubleHandle add_tb_adouble_double(TBAdoubleHandle a, double x);
TBAdoubleHandle add_double_tb_adouble(const double x, TBAdoubleHandle b);
TBAdoubleHandle add_tb_adouble_double(TBAdoubleHandle a, const double x);

TBAdoubleHandle mult_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
TBAdoubleHandle mult_double_tb_adouble(double x, TBAdoubleHandle b);
TBAdoubleHandle mult_tb_adouble_double(TBAdoubleHandle a, double x);
TBAdoubleHandle mult_double_tb_adouble(const double x, TBAdoubleHandle b);
TBAdoubleHandle mult_tb_adouble_double(TBAdoubleHandle a, const double x);

TBAdoubleHandle subtr_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
TBAdoubleHandle subtr_double_tb_adouble(double x, TBAdoubleHandle b);
TBAdoubleHandle subtr_tb_adouble_double(TBAdoubleHandle a, double x);
TBAdoubleHandle subtr_double_tb_adouble(const double x, TBAdoubleHandle b);
TBAdoubleHandle subtr_tb_adouble_double(TBAdoubleHandle a, const double x);

TBAdoubleHandle div_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
TBAdoubleHandle div_double_tb_adouble(double x, TBAdoubleHandle b);
TBAdoubleHandle div_tb_adouble_double(TBAdoubleHandle a, double x);
TBAdoubleHandle div_double_tb_adouble(const double x, TBAdoubleHandle b);
TBAdoubleHandle div_tb_adouble_double(TBAdoubleHandle a, const double x);

TBAdoubleHandle max_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
TBAdoubleHandle max_double_tb_adouble(double x, TBAdoubleHandle b);
TBAdoubleHandle max_tb_adouble_double(TBAdoubleHandle a, double x);
TBAdoubleHandle max_double_tb_adouble(const double x, TBAdoubleHandle b);
TBAdoubleHandle max_tb_adouble_double(TBAdoubleHandle a, const double x);

TBAdoubleHandle min_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
TBAdoubleHandle min_double_tb_adouble(double x, TBAdoubleHandle b);
TBAdoubleHandle min_tb_adouble_double(TBAdoubleHandle a, double x);
TBAdoubleHandle min_double_tb_adouble(const double x, TBAdoubleHandle b);
TBAdoubleHandle min_tb_adouble_double(TBAdoubleHandle a, const double x);

TBAdoubleHandle pow_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
TBAdoubleHandle pow_tb_adouble_double(TBAdoubleHandle a, double x);
TBAdoubleHandle pow_tb_adouble_double(TBAdoubleHandle a, const double x);

bool ge_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
bool ge_double_tb_adouble(double x, TBAdoubleHandle b);
bool ge_tb_adouble_double(TBAdoubleHandle a, double x);
bool ge_double_tb_adouble(const double x, TBAdoubleHandle b);
bool ge_tb_adouble_double(TBAdoubleHandle a, const double x);

bool g_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
bool g_double_tb_adouble(double x, TBAdoubleHandle b);
bool g_tb_adouble_double(TBAdoubleHandle a, double x);
bool g_double_tb_adouble(const double x, TBAdoubleHandle b);
bool g_tb_adouble_double(TBAdoubleHandle a, const double x);

bool le_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
bool le_double_tb_adouble(double x, TBAdoubleHandle b);
bool le_tb_adouble_double(TBAdoubleHandle a, double x);
bool le_double_tb_adouble(const double x, TBAdoubleHandle b);
bool le_tb_adouble_double(TBAdoubleHandle a, const double x);

bool l_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
bool l_double_tb_adouble(double x, TBAdoubleHandle b);
bool l_tb_adouble_double(TBAdoubleHandle a, double x);
bool l_double_tb_adouble(const double x, TBAdoubleHandle b);
bool l_tb_adouble_double(TBAdoubleHandle a, const double x);

bool eq_tb_adouble(TBAdoubleHandle a, TBAdoubleHandle b);
bool eq_double_tb_adouble(double x, TBAdoubleHandle b);
bool eq_tb_adouble_double(TBAdoubleHandle a, double x);
bool eq_double_tb_adouble(const double x, TBAdoubleHandle b);
bool eq_tb_adouble_double(TBAdoubleHandle a, const double x);

TBAdoubleHandle tb_abs(TBAdoubleHandle a);
TBAdoubleHandle tb_sqrt(TBAdoubleHandle a);
Expand Down Expand Up @@ -128,7 +128,7 @@ extern "C"
#endif
int c_trace_on(short int tag, int keep = 0);
void c_trace_off(int flag = 0);
void create_independent(TBAdoubleHandle a, double x);
void create_independent(TBAdoubleHandle a, const double x);
void create_dependent(TBAdoubleHandle a, double *y);
size_t num_independent(short tape_id);
size_t num_dependent(short tape_id);
Expand Down
Loading

0 comments on commit d2e86b7

Please sign in to comment.