Skip to content

Commit

Permalink
Recasting ptr_diff types to unsigned int
Browse files Browse the repository at this point in the history
  • Loading branch information
raneamri committed Nov 17, 2024
1 parent b86329f commit de916f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/XAD/Hessian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void computeHessian(const std::vector<AReal<FReal<T>>> &vec,
{
unsigned int domain(static_cast<unsigned int>(vec.size()));

if (std::distance(first, last) != domain ||
std::distance(first->cbegin(), first->cend()) != domain)
if (static_cast<unsigned int>(std::distance(first, last)) != domain ||
static_cast<unsigned int>(std::distance(first->cbegin(), first->cend())) != domain)
throw OutOfRange("Iterator not allocated enough space");
static_assert(detail::has_begin<typename std::iterator_traits<RowIterator>::value_type>::value,
"RowIterator must dereference to a type that implements a begin() method");
Expand Down Expand Up @@ -109,8 +109,8 @@ void computeHessian(const std::vector<FReal<FReal<T>>> &vec,
{
unsigned int domain(static_cast<unsigned int>(vec.size()));

if (std::distance(first, last) != domain ||
std::distance(first->cbegin(), first->cend()) != domain)
if (static_cast<unsigned int>(std::distance(first, last)) != domain ||
static_cast<unsigned int>(std::distance(first->cbegin(), first->cend())) != domain)
throw OutOfRange("Iterator not allocated enough space");
static_assert(detail::has_begin<typename std::iterator_traits<RowIterator>::value_type>::value,
"RowIterator must dereference to a type that implements a begin() method");
Expand Down
6 changes: 3 additions & 3 deletions src/XAD/Jacobian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void computeJacobian(const std::vector<AReal<T>> &vec,
std::function<std::vector<AReal<T>>(std::vector<AReal<T>> &)> foo,
RowIterator first, RowIterator last, Tape<T> *tape = Tape<T>::getActive())
{
if (std::distance(first->cbegin(), first->cend()) != vec.size())
if (static_cast<unsigned int>(std::distance(first->cbegin(), first->cend())) != vec.size())
throw OutOfRange("Iterator not allocated enough space (domain)");
static_assert(detail::has_begin<typename std::iterator_traits<RowIterator>::value_type>::value,
"RowIterator must dereference to a type that implements a begin() method");
Expand All @@ -71,7 +71,7 @@ void computeJacobian(const std::vector<AReal<T>> &vec,
auto y = foo(v);
unsigned int domain = static_cast<unsigned int>(vec.size()),
codomain = static_cast<unsigned int>(y.size());
if (std::distance(first, last) != codomain)
if (static_cast<unsigned int>(std::distance(first, last)) != codomain)
throw OutOfRange("Iterator not allocated enough space (codomain)");
tape->registerOutputs(y);

Expand Down Expand Up @@ -104,7 +104,7 @@ void computeJacobian(const std::vector<FReal<T>> &vec,
std::function<std::vector<FReal<T>>(std::vector<FReal<T>> &)> foo,
RowIterator first, RowIterator last)
{
if (std::distance(first->cbegin(), first->cend()) != vec.size())
if (static_cast<unsigned int>(std::distance(first->cbegin(), first->cend())) != vec.size())
throw OutOfRange("Iterator not allocated enough space (domain)");
static_assert(detail::has_begin<typename std::iterator_traits<RowIterator>::value_type>::value,
"RowIterator must dereference to a type that implements a begin() method");
Expand Down

0 comments on commit de916f9

Please sign in to comment.