Skip to content

Commit

Permalink
[advalue] Fix a bug in initialization for dim=0
Browse files Browse the repository at this point in the history
  • Loading branch information
cgraeser committed Nov 15, 2024
1 parent 8d912dd commit ffece1a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ADOL-C/include/adolc/advalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ template <class V, std::size_t m, std::size_t dim> class ADValue {
ADValue(const T &value, I k) : jet_() {
partial() = value;
if constexpr (maxOrder >= 1)
partial(k) = 1;
if (dim > 0)
partial(k) = 1;
}

/**
Expand All @@ -368,18 +369,18 @@ template <class V, std::size_t m, std::size_t dim> class ADValue {
ADValue(const T &value, I k, std::size_t d) : jet_(d) {
partial() = value;
if constexpr (maxOrder >= 1)
partial(k) = 1;
if (d > 0)
partial(k) = 1;
}

/**
* \brief Assignment from raw value
*
* This will treat this as a constant afterwards.
*/
// template<class T,
// std::enable_if_t<std::is_convertible_v<T, Value>, int> = 0>
// ADValue& operator=(const T& value)
ADValue &operator=(const Value &value) {
template <class T, std::enable_if_t<std::is_convertible_v<T, Value>, int> = 0>
ADValue &operator=(const T &value) {
// ADValue &operator=(const Value &value) {
forEachDerivativeIndex([&](auto... i) { partial(i...) = 0; });
partial() = value;
return *this;
Expand Down

0 comments on commit ffece1a

Please sign in to comment.