/**
- * A collection of types used within the context of auto-differentiable
- * numbers.
+ * A struct defining a collection of types used within the context of
+ * auto-differentiable numbers.
*/
- namespace types
+ template <typename ADNumberType, typename T = void>
+ struct Types
{
/**
- * Typedef for tape indices. ADOL-C uses short integers, so
- * we restrict ourselves to similar types.
+ * Typedef for tape indices.
*/
- using tape_index = unsigned short;
+ using tape_index = unsigned int;
/**
* Typedef for tape buffer sizes.
*/
using tape_buffer_sizes = unsigned int;
- } // namespace types
+ }; // struct Types
/**
- * A collection of special numbers used within the context of
- * auto-differentiable numbers.
+ * A struct defining a collection of special numbers used within the
+ * context of auto-differentiable numbers.
*/
- namespace numbers
+ template <typename ADNumberType, typename T = void>
+ struct Numbers
{
/**
* A tape index that is unusable and can be used to invalidate recording
* operations.
- *
- * @note ADOL-C doesn't allow us to record to this reserved tape (i.e. can't
- * write it to file), so we can safely use it as an invalidation case. In
- * general, we want the user to be able to record to a tape if they'd
- * like.
*/
- static const types::tape_index invalid_tape_index = 0;
+ // Note: We stipulate in the documentation for the helper classes that the
+ // valid tape index range is (invalid_tape_index,max_tape_index).
+ static const typename Types<ADNumberType>::tape_index invalid_tape_index =
+ 0u;
/**
* The maximum number of tapes that can be written on one process.
*/
-#ifdef DEAL_II_WITH_ADOLC
- // Note: This value is a limitation of ADOL-C, and not something that we
- // have control over. See test adolc/helper_tape_index_01.cc for
- // verification that we cannot use or exceed this value. This value is
- // defined as TBUFNUM; see
- // https://gitlab.com/adol-c/adol-c/blob/master/ADOL-C/include/adolc/internal/usrparms.h#L34
- static const types::tape_index max_tape_index = TBUFNUM;
-#else
- static const types::tape_index max_tape_index =
- std::numeric_limits<types::tape_index>::max();
-#endif // DEAL_II_WITH_ADOLC
- } // namespace numbers
+ static const typename Types<ADNumberType>::tape_index max_tape_index =
+ std::numeric_limits<typename Types<ADNumberType>::tape_index>::max();
+ }; // struct Numbers
/**
* Returns the tape number which is currently activated for recording or
* reading.
*/
- types::tape_index
+ typename Types<ADNumberType>::tape_index
active_tape_index() const;
/**
* or registered.
*/
bool
- is_registered_tape(const types::tape_index tape_index) const;
+ is_registered_tape(
+ const typename Types<ADNumberType>::tape_index tape_index) const;
/**
* Returns whether or not the numerical values of all independent
* @param[in] tbufsize ADOL-C Taylor buffer size
*/
void
- set_tape_buffer_sizes(const types::tape_buffer_sizes obufsize = 67108864,
- const types::tape_buffer_sizes lbufsize = 67108864,
- const types::tape_buffer_sizes vbufsize = 67108864,
- const types::tape_buffer_sizes tbufsize = 67108864);
+ set_tape_buffer_sizes(
+ const typename Types<ADNumberType>::tape_buffer_sizes obufsize = 64 *
+ 1024 *
+ 1024,
+ const typename Types<ADNumberType>::tape_buffer_sizes lbufsize = 64 *
+ 1024 *
+ 1024,
+ const typename Types<ADNumberType>::tape_buffer_sizes vbufsize = 64 *
+ 1024 *
+ 1024,
+ const typename Types<ADNumberType>::tape_buffer_sizes tbufsize = 64 *
+ 1024 *
+ 1024);
/**
* Enable the recording mode for a given tape.
* tape buffer.
*/
void
- start_taping(const types::tape_index tape_index,
- const bool keep_independent_values);
+ start_taping(const typename Types<ADNumberType>::tape_index tape_index,
+ const bool keep_independent_values);
/**
* Disable the recording mode for a given tape.
* should be written to file or kept in memory.
*/
void
- stop_taping(const types::tape_index active_tape_index,
- const bool write_tapes_to_file);
+ stop_taping(
+ const typename Types<ADNumberType>::tape_index active_tape_index,
+ const bool write_tapes_to_file);
/**
* Select a tape to record to or read from.
* from.
*
* @note The chosen tape index must be greater than
- * numbers::invalid_tape_index and less than numbers::max_tape_index.
+ * Numbers<ADNumberType>::invalid_tape_index and less than
+ * Numbers<ADNumberType>::max_tape_index.
*/
void
- activate_tape(const types::tape_index tape_index);
+ activate_tape(const typename Types<ADNumberType>::tape_index tape_index);
/**
* Reset the state of the class.
* written.
*/
static void
- print_tape_stats(const types::tape_index tape_index,
- std::ostream & stream);
+ print_tape_stats(
+ const typename Types<ADNumberType>::tape_index tape_index,
+ std::ostream & stream);
//@}
* @return The scalar value of the function.
*/
static ScalarType
- value(const types::tape_index active_tape_index,
+ value(const typename Types<ADNumberType>::tape_index active_tape_index,
const std::vector<ScalarType> &independent_variables);
/**
* <code>n_independent_variables</code>).
*/
static void
- gradient(const types::tape_index active_tape_index,
+ gradient(const typename Types<ADNumberType>::tape_index active_tape_index,
const std::vector<ScalarType> &independent_variables,
Vector<ScalarType> & gradient);
* <code>n_independent_variables</code>$\times$<code>n_independent_variables</code>).
*/
static void
- hessian(const types::tape_index active_tape_index,
+ hessian(const typename Types<ADNumberType>::tape_index active_tape_index,
const std::vector<ScalarType> &independent_variables,
FullMatrix<ScalarType> & hessian);
* (with length <code>n_dependent_variables</code>).
*/
static void
- values(const types::tape_index active_tape_index,
+ values(const typename Types<ADNumberType>::tape_index active_tape_index,
const unsigned int n_dependent_variables,
const std::vector<ScalarType> &independent_variables,
Vector<ScalarType> & values);
* <code>n_dependent_variables</code>$\times$<code>n_independent_variables</code>).
*/
static void
- jacobian(const types::tape_index active_tape_index,
+ jacobian(const typename Types<ADNumberType>::tape_index active_tape_index,
const unsigned int n_dependent_variables,
const std::vector<ScalarType> &independent_variables,
FullMatrix<ScalarType> & jacobian);
template <typename ADNumberType, typename ScalarType, typename T>
- types::tape_index
+ typename Types<ADNumberType>::tape_index
TapedDrivers<ADNumberType, ScalarType, T>::active_tape_index() const
{
AssertThrow(false, ExcRequiresADNumberSpecialization());
- return numbers::invalid_tape_index;
+ return Numbers<ADNumberType>::invalid_tape_index;
}
template <typename ADNumberType, typename ScalarType, typename T>
bool
TapedDrivers<ADNumberType, ScalarType, T>::is_registered_tape(
- const types::tape_index) const
+ const typename Types<ADNumberType>::tape_index) const
{
AssertThrow(false, ExcRequiresADNumberSpecialization());
return false;
template <typename ADNumberType, typename ScalarType, typename T>
void
TapedDrivers<ADNumberType, ScalarType, T>::set_tape_buffer_sizes(
- const types::tape_buffer_sizes,
- const types::tape_buffer_sizes,
- const types::tape_buffer_sizes,
- const types::tape_buffer_sizes)
+ const typename Types<ADNumberType>::tape_buffer_sizes,
+ const typename Types<ADNumberType>::tape_buffer_sizes,
+ const typename Types<ADNumberType>::tape_buffer_sizes,
+ const typename Types<ADNumberType>::tape_buffer_sizes)
{
AssertThrow(false, ExcRequiresADNumberSpecialization());
}
template <typename ADNumberType, typename ScalarType, typename T>
void
TapedDrivers<ADNumberType, ScalarType, T>::start_taping(
- const types::tape_index,
+ const typename Types<ADNumberType>::tape_index,
const bool)
{
AssertThrow(false, ExcRequiresADNumberSpecialization());
template <typename ADNumberType, typename ScalarType, typename T>
void
TapedDrivers<ADNumberType, ScalarType, T>::stop_taping(
- const types::tape_index,
+ const typename Types<ADNumberType>::tape_index,
const bool)
{
AssertThrow(false, ExcRequiresADNumberSpecialization());
template <typename ADNumberType, typename ScalarType, typename T>
void
TapedDrivers<ADNumberType, ScalarType, T>::activate_tape(
- const types::tape_index)
+ const typename Types<ADNumberType>::tape_index)
{
AssertThrow(false, ExcRequiresADNumberSpecialization());
}
template <typename ADNumberType, typename ScalarType, typename T>
void
TapedDrivers<ADNumberType, ScalarType, T>::print_tape_stats(
- const types::tape_index,
+ const typename Types<ADNumberType>::tape_index,
std::ostream &)
{
AssertThrow(false, ExcRequiresADNumberSpecialization());
template <typename ADNumberType, typename ScalarType, typename T>
ScalarType
TapedDrivers<ADNumberType, ScalarType, T>::value(
- const types::tape_index,
+ const typename Types<ADNumberType>::tape_index,
const std::vector<ScalarType> &)
{
AssertThrow(false, ExcRequiresADNumberSpecialization());
template <typename ADNumberType, typename ScalarType, typename T>
void
TapedDrivers<ADNumberType, ScalarType, T>::gradient(
- const types::tape_index,
+ const typename Types<ADNumberType>::tape_index,
const std::vector<ScalarType> &,
Vector<ScalarType> &)
{
template <typename ADNumberType, typename ScalarType, typename T>
void
TapedDrivers<ADNumberType, ScalarType, T>::hessian(
- const types::tape_index,
+ const typename Types<ADNumberType>::tape_index,
const std::vector<ScalarType> &,
FullMatrix<ScalarType> &)
{
template <typename ADNumberType, typename ScalarType, typename T>
void
TapedDrivers<ADNumberType, ScalarType, T>::values(
- const types::tape_index,
+ const typename Types<ADNumberType>::tape_index,
const unsigned int,
const std::vector<ScalarType> &,
Vector<ScalarType> &)
template <typename ADNumberType, typename ScalarType, typename T>
void
TapedDrivers<ADNumberType, ScalarType, T>::jacobian(
- const types::tape_index,
+ const typename Types<ADNumberType>::tape_index,
const unsigned int,
const std::vector<ScalarType> &,
FullMatrix<ScalarType> &)
# ifdef DEAL_II_WITH_ADOLC
+ /**
+ * Specialization for taped ADOL-C auto-differentiable numbers.
+ */
+ template <typename ADNumberType>
+ struct Types<
+ ADNumberType,
+ typename std::enable_if<ADNumberTraits<ADNumberType>::type_code ==
+ NumberTypes::adolc_taped>::type>
+ {
+ /**
+ * Typedef for tape indices. ADOL-C uses short integers, so
+ * we restrict ourselves to similar types.
+ */
+ using tape_index = unsigned short;
+
+ /**
+ * Typedef for tape buffer sizes.
+ */
+ using tape_buffer_sizes = unsigned int;
+ }; // struct Types
+
+
+ /**
+ * Specialization for taped ADOL-C auto-differentiable numbers.
+ */
+ template <typename ADNumberType>
+ struct Numbers<
+ ADNumberType,
+ typename std::enable_if<ADNumberTraits<ADNumberType>::type_code ==
+ NumberTypes::adolc_taped>::type>
+ {
+ /**
+ * A tape index that is unusable and can be used to invalidate recording
+ * operations.
+ *
+ * @note ADOL-C doesn't allow us to record to this reserved tape (i.e. can't
+ * write it to file), so we can safely use it as an invalidation case. In
+ * general, we want the user to be able to record to a tape if they'd
+ * like.
+ */
+ static const typename Types<ADNumberType>::tape_index invalid_tape_index =
+ 0;
+
+ /**
+ * The maximum number of tapes that can be written on one process.
+ */
+ // Note: This value is a limitation of ADOL-C, and not something that we
+ // have control over. See test adolc/helper_tape_index_01.cc for
+ // verification that we cannot use or exceed this value. This value is
+ // defined as TBUFNUM; see
+ // https://gitlab.com/adol-c/adol-c/blob/master/ADOL-C/include/adolc/internal/usrparms.h#L34
+ static const typename Types<ADNumberType>::tape_index max_tape_index =
+ TBUFNUM;
+ }; // struct Numbers
+
+
/**
* Specialization for taped ADOL-C auto-differentiable numbers.
*
using scalar_type = double;
TapedDrivers()
- : active_tape(numbers::invalid_tape_index)
+ : active_tape(Numbers<ADNumberType>::invalid_tape_index)
, keep_values(true)
, is_recording_flag(false)
, use_stored_taped_buffer_sizes(false)
return is_recording_flag;
}
- types::tape_index
+ typename Types<ADNumberType>::tape_index
active_tape_index() const
{
return active_tape;
}
bool
- is_registered_tape(const types::tape_index tape_index) const
+ is_registered_tape(
+ const typename Types<ADNumberType>::tape_index tape_index) const
{
// Sigh... This is a mess :-/
// The most succinct way to get this piece of information, would be to
// see if the tape REALLY exists (i.e. has been touched, even if nothing
// has been written to it) before trying to access it. It'll only take
// an O(n) search, but at this point who really cares about efficiency?
- const std::vector<types::tape_index> registered_tape_indices =
- get_registered_tape_indices();
+ const std::vector<typename Types<ADNumberType>::tape_index>
+ registered_tape_indices = get_registered_tape_indices();
const auto it = std::find(registered_tape_indices.begin(),
registered_tape_indices.end(),
tape_index);
}
void
- set_tape_buffer_sizes(const types::tape_buffer_sizes in_obufsize,
- const types::tape_buffer_sizes in_lbufsize,
- const types::tape_buffer_sizes in_vbufsize,
- const types::tape_buffer_sizes in_tbufsize)
+ set_tape_buffer_sizes(
+ const typename Types<ADNumberType>::tape_buffer_sizes in_obufsize,
+ const typename Types<ADNumberType>::tape_buffer_sizes in_lbufsize,
+ const typename Types<ADNumberType>::tape_buffer_sizes in_vbufsize,
+ const typename Types<ADNumberType>::tape_buffer_sizes in_tbufsize)
{
// When valid for the chosen AD number type, these values will be used
// the next time start_recording_operations() is called.
}
void
- start_taping(const types::tape_index tape_index,
- const bool keep_independent_values)
+ start_taping(const typename Types<ADNumberType>::tape_index tape_index,
+ const bool keep_independent_values)
{
if (use_stored_taped_buffer_sizes)
trace_on(tape_index,
}
void
- stop_taping(const types::tape_index active_tape_index,
- const bool write_tapes_to_file)
+ stop_taping(
+ const typename Types<ADNumberType>::tape_index active_tape_index,
+ const bool write_tapes_to_file)
{
if (write_tapes_to_file)
trace_off(active_tape_index); // Slow
// invalidate it. However, there is now also no way to double-check
// that the newly recorded tape is indeed the active tape.
if (keep_independent_values() == false)
- active_tape = numbers::invalid_tape_index;
+ active_tape = Numbers<ADNumberType>::invalid_tape_index;
}
void
- activate_tape(const types::tape_index tape_index)
+ activate_tape(const typename Types<ADNumberType>::tape_index tape_index)
{
active_tape = tape_index;
}
void
reset(const bool clear_registered_tapes)
{
- active_tape = numbers::invalid_tape_index;
+ active_tape = Numbers<ADNumberType>::invalid_tape_index;
is_recording_flag = false;
if (clear_registered_tapes)
{
- const std::vector<types::tape_index> registered_tape_indices =
- get_registered_tape_indices();
+ const std::vector<typename Types<ADNumberType>::tape_index>
+ registered_tape_indices = get_registered_tape_indices();
for (const auto &tape_index : registered_tape_indices)
removeTape(tape_index, TapeRemovalType::ADOLC_REMOVE_COMPLETELY);
}
void
print(std::ostream &stream) const
{
- const std::vector<types::tape_index> registered_tape_indices =
- get_registered_tape_indices();
+ const std::vector<typename Types<ADNumberType>::tape_index>
+ registered_tape_indices = get_registered_tape_indices();
stream << "Registered tapes: ";
auto it_registered_tape = registered_tape_indices.begin();
for (unsigned int i = 0; i < registered_tape_indices.size();
}
static void
- print_tape_stats(const types::tape_index tape_index, std::ostream &stream)
+ print_tape_stats(
+ const typename Types<ADNumberType>::tape_index tape_index,
+ std::ostream & stream)
{
// See ADOL-C manual section 2.1
// and adolc/taping.h
// === Scalar drivers ===
static scalar_type
- value(const types::tape_index active_tape_index,
+ value(const typename Types<ADNumberType>::tape_index active_tape_index,
const std::vector<scalar_type> &independent_variables)
{
scalar_type value = 0.0;
}
static void
- gradient(const types::tape_index active_tape_index,
+ gradient(const typename Types<ADNumberType>::tape_index active_tape_index,
const std::vector<scalar_type> &independent_variables,
Vector<scalar_type> & gradient)
{
}
static void
- hessian(const types::tape_index active_tape_index,
+ hessian(const typename Types<ADNumberType>::tape_index active_tape_index,
const std::vector<scalar_type> &independent_variables,
FullMatrix<scalar_type> & hessian)
{
// === Vector drivers ===
static void
- values(const types::tape_index active_tape_index,
+ values(const typename Types<ADNumberType>::tape_index active_tape_index,
const unsigned int n_dependent_variables,
const std::vector<scalar_type> &independent_variables,
Vector<scalar_type> & values)
}
static void
- jacobian(const types::tape_index active_tape_index,
+ jacobian(const typename Types<ADNumberType>::tape_index active_tape_index,
const unsigned int n_dependent_variables,
const std::vector<scalar_type> &independent_variables,
FullMatrix<scalar_type> & jacobian)
* be recorded to or read from when performing computations using "taped"
* auto-differentiable numbers.
*/
- types::tape_index active_tape;
+ typename Types<ADNumberType>::tape_index active_tape;
/**
* Mark whether we're going to inform taped data structures to retain
/**
* ADOL-C operations buffer size.
*/
- types::tape_buffer_sizes obufsize;
+ typename Types<ADNumberType>::tape_buffer_sizes obufsize;
/**
* ADOL-C locations buffer size.
*/
- types::tape_buffer_sizes lbufsize;
+ typename Types<ADNumberType>::tape_buffer_sizes lbufsize;
/**
* ADOL-C value buffer size.
*/
- types::tape_buffer_sizes vbufsize;
+ typename Types<ADNumberType>::tape_buffer_sizes vbufsize;
/**
* ADOL-C Taylor buffer size.
*/
- types::tape_buffer_sizes tbufsize;
+ typename Types<ADNumberType>::tape_buffer_sizes tbufsize;
/**
* Return a list of registered tape indices
*/
- std::vector<types::tape_index>
+ std::vector<typename Types<ADNumberType>::tape_index>
get_registered_tape_indices() const
{
// We've chosen to use unsigned shorts for the tape
std::vector<short> registered_tape_indices_s;
cachedTraceTags(registered_tape_indices_s);
- std::vector<types::tape_index> registered_tape_indices(
- registered_tape_indices_s.size());
+ std::vector<typename Types<ADNumberType>::tape_index>
+ registered_tape_indices(registered_tape_indices_s.size());
std::copy(registered_tape_indices_s.begin(),
registered_tape_indices_s.end(),
registered_tape_indices.begin());
return false;
}
- types::tape_index
+ typename Types<ADNumberType>::tape_index
active_tape_index() const
{
AssertThrow(false, ExcRequiresADOLC());
- return numbers::invalid_tape_index;
+ return Numbers<ADNumberType>::invalid_tape_index;
}
bool
}
bool
- is_registered_tape(const types::tape_index tape_index) const
+ is_registered_tape(
+ const typename Types<ADNumberType>::tape_index tape_index) const
{
AssertThrow(false, ExcRequiresADOLC());
return false;
}
void
- set_tape_buffer_sizes(const types::tape_buffer_sizes,
- const types::tape_buffer_sizes,
- const types::tape_buffer_sizes,
- const types::tape_buffer_sizes)
+ set_tape_buffer_sizes(
+ const typename Types<ADNumberType>::tape_buffer_sizes,
+ const typename Types<ADNumberType>::tape_buffer_sizes,
+ const typename Types<ADNumberType>::tape_buffer_sizes,
+ const typename Types<ADNumberType>::tape_buffer_sizes)
{
AssertThrow(false, ExcRequiresADOLC());
}
void
- start_taping(const types::tape_index, const bool)
+ start_taping(const typename Types<ADNumberType>::tape_index, const bool)
{
AssertThrow(false, ExcRequiresADOLC());
}
void
- stop_taping(const types::tape_index, const bool)
+ stop_taping(const typename Types<ADNumberType>::tape_index, const bool)
{
AssertThrow(false, ExcRequiresADOLC());
}
void
- activate_tape(const types::tape_index)
+ activate_tape(const typename Types<ADNumberType>::tape_index)
{
AssertThrow(false, ExcRequiresADOLC());
}
}
static void
- print_tape_stats(const types::tape_index, std::ostream &)
+ print_tape_stats(const typename Types<ADNumberType>::tape_index,
+ std::ostream &)
{
AssertThrow(false, ExcRequiresADOLC());
}
// === Scalar drivers ===
static scalar_type
- value(const types::tape_index, const std::vector<scalar_type> &)
+ value(const typename Types<ADNumberType>::tape_index,
+ const std::vector<scalar_type> &)
{
AssertThrow(false, ExcRequiresADOLC());
return 0.0;
}
static void
- gradient(const types::tape_index,
+ gradient(const typename Types<ADNumberType>::tape_index,
const std::vector<scalar_type> &,
Vector<scalar_type> &)
{
}
static void
- hessian(const types::tape_index,
+ hessian(const typename Types<ADNumberType>::tape_index,
const std::vector<scalar_type> &,
FullMatrix<scalar_type> &)
{
// === Vector drivers ===
static void
- values(const types::tape_index,
+ values(const typename Types<ADNumberType>::tape_index,
const unsigned int,
const std::vector<scalar_type> &,
Vector<scalar_type> &)
}
static void
- jacobian(const types::tape_index,
+ jacobian(const typename Types<ADNumberType>::tape_index,
const unsigned int,
const std::vector<scalar_type> &,
FullMatrix<scalar_type> &)
return taped_driver.is_recording();
}
- types::tape_index
+ typename Types<ADNumberType>::tape_index
active_tape_index() const
{
// ADOL-C only supports 'double', not 'float', so we can forward to
}
bool
- is_registered_tape(const types::tape_index tape_index) const
+ is_registered_tape(
+ const typename Types<ADNumberType>::tape_index tape_index) const
{
// ADOL-C only supports 'double', not 'float', so we can forward to
// the 'double' implementation of this function
}
void
- set_tape_buffer_sizes(const types::tape_buffer_sizes obufsize,
- const types::tape_buffer_sizes lbufsize,
- const types::tape_buffer_sizes vbufsize,
- const types::tape_buffer_sizes tbufsize)
+ set_tape_buffer_sizes(
+ const typename Types<ADNumberType>::tape_buffer_sizes obufsize,
+ const typename Types<ADNumberType>::tape_buffer_sizes lbufsize,
+ const typename Types<ADNumberType>::tape_buffer_sizes vbufsize,
+ const typename Types<ADNumberType>::tape_buffer_sizes tbufsize)
{
// ADOL-C only supports 'double', not 'float', so we can forward to
// the 'double' implementation of this function
}
void
- start_taping(const types::tape_index tape_index,
- const bool keep_independent_values)
+ start_taping(const typename Types<ADNumberType>::tape_index tape_index,
+ const bool keep_independent_values)
{
// ADOL-C only supports 'double', not 'float', so we can forward to
// the 'double' implementation of this function
}
void
- stop_taping(const types::tape_index active_tape_index,
- const bool write_tapes_to_file)
+ stop_taping(
+ const typename Types<ADNumberType>::tape_index active_tape_index,
+ const bool write_tapes_to_file)
{
// ADOL-C only supports 'double', not 'float', so we can forward to
// the 'double' implementation of this function
}
void
- activate_tape(const types::tape_index tape_index)
+ activate_tape(const typename Types<ADNumberType>::tape_index tape_index)
{
taped_driver.activate_tape(tape_index);
}
}
static void
- print_tape_stats(const types::tape_index tape_index, std::ostream &stream)
+ print_tape_stats(
+ const typename Types<ADNumberType>::tape_index tape_index,
+ std::ostream & stream)
{
// ADOL-C only supports 'double', not 'float', so we can forward to
// the 'double' implementation of this function
// === Scalar drivers ===
static scalar_type
- value(const types::tape_index active_tape_index,
+ value(const typename Types<ADNumberType>::tape_index active_tape_index,
const std::vector<scalar_type> &independent_variables)
{
// ADOL-C only supports 'double', not 'float', so we can forward to
}
static void
- gradient(const types::tape_index active_tape_index,
+ gradient(const typename Types<ADNumberType>::tape_index active_tape_index,
const std::vector<scalar_type> &independent_variables,
Vector<scalar_type> & gradient)
{
}
static void
- hessian(const types::tape_index active_tape_index,
+ hessian(const typename Types<ADNumberType>::tape_index active_tape_index,
const std::vector<scalar_type> &independent_variables,
FullMatrix<scalar_type> & hessian)
{
// === Vector drivers ===
static void
- values(const types::tape_index active_tape_index,
+ values(const typename Types<ADNumberType>::tape_index active_tape_index,
const unsigned int n_dependent_variables,
const std::vector<scalar_type> &independent_variables,
Vector<scalar_type> & values)
}
static void
- jacobian(const types::tape_index active_tape_index,
+ jacobian(const typename Types<ADNumberType>::tape_index active_tape_index,
const unsigned int n_dependent_variables,
const std::vector<scalar_type> &independent_variables,
FullMatrix<scalar_type> & jacobian)
}
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(this->active_tape_index() != numbers::invalid_tape_index,
+ Assert(this->active_tape_index() !=
+ Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
}
Assert(
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(active_tape_index() != numbers::invalid_tape_index,
+ Assert(active_tape_index() != Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
Assert(is_recording() == true,
ExcMessage(
{
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(active_tape_index() != numbers::invalid_tape_index,
+ Assert(active_tape_index() != Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
}
Assert(is_recording() == false,
template <enum AD::NumberTypes ADNumberTypeCode, typename ScalarType>
- types::tape_index
+ typename Types<
+ typename ADHelperBase<ADNumberTypeCode, ScalarType>::ad_type>::tape_index
ADHelperBase<ADNumberTypeCode, ScalarType>::active_tape_index() const
{
if (AD::is_taped_ad_number<ad_type>::value)
template <enum AD::NumberTypes ADNumberTypeCode, typename ScalarType>
bool
ADHelperBase<ADNumberTypeCode, ScalarType>::is_registered_tape(
- const types::tape_index tape_index) const
+ const typename Types<ad_type>::tape_index tape_index) const
{
if (AD::is_taped_ad_number<ad_type>::value)
return taped_driver.is_registered_tape(tape_index);
template <enum AD::NumberTypes ADNumberTypeCode, typename ScalarType>
void
ADHelperBase<ADNumberTypeCode, ScalarType>::print_tape_stats(
- const types::tape_index tape_index,
- std::ostream & stream) const
+ const typename Types<ad_type>::tape_index tape_index,
+ std::ostream & stream) const
{
if (ADNumberTraits<ad_type>::is_tapeless == true)
return;
template <enum AD::NumberTypes ADNumberTypeCode, typename ScalarType>
void
ADHelperBase<ADNumberTypeCode, ScalarType>::activate_recorded_tape(
- const types::tape_index tape_index)
+ const typename Types<ad_type>::tape_index tape_index)
{
activate_tape(tape_index, true /*read_mode*/);
}
template <enum AD::NumberTypes ADNumberTypeCode, typename ScalarType>
void
ADHelperBase<ADNumberTypeCode, ScalarType>::activate_tape(
- const types::tape_index tape_index,
- const bool read_mode)
+ const typename Types<ad_type>::tape_index tape_index,
+ const bool read_mode)
{
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(tape_index != numbers::invalid_tape_index,
+ Assert(tape_index != Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
- Assert(tape_index < numbers::max_tape_index,
+ Assert(tape_index < Numbers<ad_type>::max_tape_index,
ExcMessage("Tape index exceeds maximum allowable value"));
taped_driver.activate_tape(tape_index);
reset_registered_independent_variables();
template <enum AD::NumberTypes ADNumberTypeCode, typename ScalarType>
void
ADHelperBase<ADNumberTypeCode, ScalarType>::set_tape_buffer_sizes(
- const types::tape_buffer_sizes obufsize,
- const types::tape_buffer_sizes lbufsize,
- const types::tape_buffer_sizes vbufsize,
- const types::tape_buffer_sizes tbufsize)
+ const typename Types<ad_type>::tape_buffer_sizes obufsize,
+ const typename Types<ad_type>::tape_buffer_sizes lbufsize,
+ const typename Types<ad_type>::tape_buffer_sizes vbufsize,
+ const typename Types<ad_type>::tape_buffer_sizes tbufsize)
{
// When valid for the chosen AD number type, these values will be used the
// next time start_recording_operations() is called.
template <enum AD::NumberTypes ADNumberTypeCode, typename ScalarType>
bool
ADHelperBase<ADNumberTypeCode, ScalarType>::start_recording_operations(
- const types::tape_index tape_index,
- const bool overwrite_tape,
- const bool keep_independent_values)
+ const typename Types<ad_type>::tape_index tape_index,
+ const bool overwrite_tape,
+ const bool keep_independent_values)
{
// Define this here for clarity when this flag is used later.
const bool read_mode = false;
else
{
Assert(is_recording() == false,
- ExcMessage("Tape recording is unexpectedly still enabled."));
+ ExcMessage(
+ "Tape recording is unexpectedly still enabled."));
// Now we activate the pre-recorded tape so that its immediately
// available for use
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(active_tape_index() != numbers::invalid_tape_index,
+ Assert(active_tape_index() != Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
Assert(is_recording() == true,
ExcMessage(
{
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(this->active_tape_index() != numbers::invalid_tape_index,
+ Assert(this->active_tape_index() !=
+ Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
}
{
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(this->active_tape_index() != numbers::invalid_tape_index,
+ Assert(this->active_tape_index() !=
+ Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
}
{
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(this->active_tape_index() != numbers::invalid_tape_index,
+ Assert(this->active_tape_index() !=
+ Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
}
Assert(values.size() == this->n_independent_variables(),
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(this->active_tape_index() != numbers::invalid_tape_index,
+ Assert(this->active_tape_index() !=
+ Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
Assert(this->is_recording() == false,
ExcMessage(
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(this->active_tape_index() != numbers::invalid_tape_index,
+ Assert(this->active_tape_index() !=
+ Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
Assert(this->is_recording() == false,
ExcMessage(
if (ADNumberTraits<ad_type>::is_taped == true)
{
- Assert(this->active_tape_index() != numbers::invalid_tape_index,
+ Assert(this->active_tape_index() !=
+ Numbers<ad_type>::invalid_tape_index,
ExcMessage("Invalid tape index"));
Assert(this->is_recording() == false,
ExcMessage(