Skip to content

Commit

Permalink
master: fix isnan ambibuity on Visual C++ 2022.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradbell committed Sep 9, 2024
1 parent cc3fc3a commit ff01a85
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 52 deletions.
5 changes: 4 additions & 1 deletion appendix/whats_new/2024.xrst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
dll
env
iostream
isnan
nul
nx
omhelp
Expand All @@ -32,7 +33,9 @@ mm-dd

09-09
=====
The :ref:`cmake@CMake Command@Visual Studio` instructions were improved.
#. The :ref:`cmake@CMake Command@Visual Studio` instructions were improved.
#. ``CppAD`` was added before ``isnan`` , see the discussion of
:ref:`nan@std::isnan` .

08-10
=====
Expand Down
64 changes: 32 additions & 32 deletions include/cppad/core/graph/from_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# define CPPAD_CORE_GRAPH_FROM_GRAPH_HPP
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2003-23 Bradley M. Bell
// SPDX-FileContributor: 2003-24 Bradley M. Bell
// ----------------------------------------------------------------------------

# include <cppad/core/ad_fun.hpp>
Expand Down Expand Up @@ -268,7 +268,7 @@ void CppAD::ADFun<Base,RecBase>::from_graph(
CPPAD_ASSERT_UNKNOWN( parameter.size() == 0 );
addr_t i_par = rec.put_con_par(nan);
CPPAD_ASSERT_UNKNOWN( i_par == 0 );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_par] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_par] ) );
//
// Place the variable with index 0 in the tape
CPPAD_ASSERT_NARG_NRES(local::BeginOp, 1, 1);
Expand All @@ -286,7 +286,7 @@ void CppAD::ADFun<Base,RecBase>::from_graph(
}
else
{ i_par = rec.put_dyn_par(nan, local::ind_dyn );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_par] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_par] ) );
node_type.push_back(dynamic_enum);
node2fun.push_back(i_par);
}
Expand All @@ -297,7 +297,7 @@ void CppAD::ADFun<Base,RecBase>::from_graph(
for(size_t i = 0; i < n_variable_ind; ++i)
{ if( var2dyn[i] )
{ i_par = rec.put_dyn_par(nan, local::ind_dyn );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_par] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_par] ) );
node_type.push_back(dynamic_enum);
node2fun.push_back(i_par);
}
Expand Down Expand Up @@ -530,7 +530,7 @@ void CppAD::ADFun<Base,RecBase>::from_graph(
{ i_result = rec.put_dyn_par(
nan, local::add_dyn, i_result, temporary[j]
);
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
}
}
else
Expand Down Expand Up @@ -975,112 +975,112 @@ void CppAD::ADFun<Base,RecBase>::from_graph(
{
case abs_graph_op:
i_result = rec.put_dyn_par(nan, local::abs_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case acosh_graph_op:
i_result = rec.put_dyn_par(nan, local::acosh_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case asinh_graph_op:
i_result = rec.put_dyn_par(nan, local::asinh_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case atanh_graph_op:
i_result = rec.put_dyn_par(nan, local::atanh_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case erf_graph_op:
i_result = rec.put_dyn_par(nan, local::erf_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case erfc_graph_op:
i_result = rec.put_dyn_par(nan, local::erfc_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case expm1_graph_op:
i_result = rec.put_dyn_par(nan, local::expm1_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case log1p_graph_op:
i_result = rec.put_dyn_par(nan, local::log1p_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case acos_graph_op:
i_result = rec.put_dyn_par(nan, local::acos_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case asin_graph_op:
i_result = rec.put_dyn_par(nan, local::asin_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case atan_graph_op:
i_result = rec.put_dyn_par(nan, local::atan_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case cosh_graph_op:
i_result = rec.put_dyn_par(nan, local::cosh_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case cos_graph_op:
i_result = rec.put_dyn_par(nan, local::cos_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case exp_graph_op:
i_result = rec.put_dyn_par(nan, local::exp_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case log_graph_op:
i_result = rec.put_dyn_par(nan, local::log_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case neg_graph_op:
i_result = rec.put_dyn_par(nan, local::neg_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case sign_graph_op:
i_result = rec.put_dyn_par(nan, local::sign_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case sinh_graph_op:
i_result = rec.put_dyn_par(nan, local::sinh_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case sin_graph_op:
i_result = rec.put_dyn_par(nan, local::sin_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case sqrt_graph_op:
i_result = rec.put_dyn_par(nan, local::sqrt_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case tanh_graph_op:
i_result = rec.put_dyn_par(nan, local::tanh_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case tan_graph_op:
i_result = rec.put_dyn_par(nan, local::tan_dyn, arg[0] );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

default:
Expand Down Expand Up @@ -1367,19 +1367,19 @@ void CppAD::ADFun<Base,RecBase>::from_graph(
case add_graph_op:
i_result =
rec.put_dyn_par(nan, local::add_dyn, arg[0], arg[1]);
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case azmul_graph_op:
i_result =
rec.put_dyn_par(nan, local::zmul_dyn, arg[0], arg[1]);
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case div_graph_op:
i_result =
rec.put_dyn_par(nan, local::div_dyn, arg[0], arg[1]);
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case mul_graph_op:
Expand All @@ -1390,13 +1390,13 @@ void CppAD::ADFun<Base,RecBase>::from_graph(
case pow_graph_op:
i_result =
rec.put_dyn_par(nan, local::pow_dyn, arg[0], arg[1]);
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

case sub_graph_op:
i_result =
rec.put_dyn_par(nan, local::sub_dyn, arg[0], arg[1]);
CPPAD_ASSERT_UNKNOWN( isnan( parameter[i_result] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[i_result] ) );
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions include/cppad/core/graph/to_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2003-23 Bradley M. Bell
// SPDX-FileContributor: 2003-24 Bradley M. Bell
// ----------------------------------------------------------------------------

# include <cppad/core/ad_fun.hpp>
Expand Down Expand Up @@ -113,7 +113,7 @@ void CppAD::ADFun<Base,RecBase>::to_graph(
CPPAD_ASSERT_UNKNOWN( n_dynamic_ind <= n_dynamic );
CPPAD_ASSERT_UNKNOWN( dyn_par_is.size() == n_parameter );
CPPAD_ASSERT_UNKNOWN( n_parameter > 0 );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[0] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[0] ) );
CPPAD_ASSERT_UNKNOWN( ! dyn_par_is[0] );
// --------------------------------------------------------------------
// par2node
Expand Down
4 changes: 2 additions & 2 deletions include/cppad/example/cppad_eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# define CPPAD_EXAMPLE_CPPAD_EIGEN_HPP
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2003-23 Bradley M. Bell
// SPDX-FileContributor: 2003-24 Bradley M. Bell
// ----------------------------------------------------------------------------

/*
Expand Down Expand Up @@ -244,7 +244,7 @@ namespace std {
{ return isfinite(CppAD::Value( CppAD::Var2Par(x) ) ); }

template <class Base> bool isnan(const CppAD::AD<Base> &x)
{ return isnan(CppAD::Value( CppAD::Var2Par(x) ) ); }
{ return CppAD::isnan(CppAD::Value( CppAD::Var2Par(x) ) ); }
}
/* {xrst_code}
{xrst_spell_on}
Expand Down
4 changes: 2 additions & 2 deletions include/cppad/local/optimize/get_par_usage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# define CPPAD_LOCAL_OPTIMIZE_GET_PAR_USAGE_HPP
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2003-23 Bradley M. Bell
// SPDX-FileContributor: 2003-24 Bradley M. Bell
// ----------------------------------------------------------------------------
/*!
\file get_cexp_info.hpp
Expand Down Expand Up @@ -438,7 +438,7 @@ void get_par_usage(
type_x.resize(n);
for(size_t j = 0; j < n; ++j)
{ // parameter index zero is used for variable
CPPAD_ASSERT_UNKNOWN( isnan( all_par_vec[0] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( all_par_vec[0] ) );
addr_t arg_j = dyn_par_arg[i_arg + 5 + j];
parameter_x[j] = all_par_vec[arg_j];
if( arg_j == 0 )
Expand Down
4 changes: 2 additions & 2 deletions include/cppad/local/optimize/optimize_run.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# define CPPAD_LOCAL_OPTIMIZE_OPTIMIZE_RUN_HPP
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2003-23 Bradley M. Bell
// SPDX-FileContributor: 2003-24 Bradley M. Bell
// ----------------------------------------------------------------------------

# include <stack>
Expand Down Expand Up @@ -329,7 +329,7 @@ bool optimize_run(
rec->set_record_compare( compare_op );

// copy parameters with index 0
CPPAD_ASSERT_UNKNOWN( ! dyn_par_is[0] && isnan( play->GetPar(0) ) );
CPPAD_ASSERT_UNKNOWN( ! dyn_par_is[0] && CppAD::isnan( play->GetPar(0) ) );
rec->put_con_par( play->GetPar(0) );
new_par[0] = 0;

Expand Down
4 changes: 2 additions & 2 deletions include/cppad/local/record/put_dyn_atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# define CPPAD_LOCAL_RECORD_PUT_DYN_ATOMIC_HPP
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2003-23 Bradley M. Bell
// SPDX-FileContributor: 2003-24 Bradley M. Bell
// ----------------------------------------------------------------------------
# include <cppad/local/record/recorder.hpp>

Expand Down Expand Up @@ -133,7 +133,7 @@ void recorder<Base>::put_dyn_atomic(

case variable_enum:
arg = 0; // phantom parameter index
CPPAD_ASSERT_UNKNOWN( isnan( all_par_vec_[arg] ) )
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( all_par_vec_[arg] ) )
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions include/cppad/local/record/recorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# define CPPAD_LOCAL_RECORD_RECORDER_HPP
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2003-22 Bradley M. Bell
// SPDX-FileContributor: 2003-24 Bradley M. Bell
// ----------------------------------------------------------------------------
# include <cppad/core/hash_code.hpp>
# include <cppad/local/pod_vector.hpp>
Expand Down Expand Up @@ -541,7 +541,7 @@ addr_t recorder<Base>::put_con_par(const Base &par)
// index zero is used to signify that a value is not a parameter;
// i.e., it is a variable.
if( all_par_vec_.size() == 0 )
CPPAD_ASSERT_UNKNOWN( isnan(par) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan(par) );
# endif
// ---------------------------------------------------------------------
// check for a match with a previous parameter
Expand Down
8 changes: 4 additions & 4 deletions include/cppad/local/val_graph/val2fun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# define CPPAD_LOCAL_VAL_GRAPH_VAL2FUN_HPP
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2003-23 Bradley M. Bell
// SPDX-FileContributor: 2003-24 Bradley M. Bell
// --------------------------------------------------------------------------
/*
{xrst_begin val2fun_graph dev}
Expand Down Expand Up @@ -228,7 +228,7 @@ void ADFun<Base, RecBase>::val2fun(
// initialize with the value nan at index nan
par_addr = rec.put_con_par(nan);
CPPAD_ASSERT_UNKNOWN( par_addr == 0 );
CPPAD_ASSERT_UNKNOWN( isnan( parameter[par_addr] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[par_addr] ) );
//
// rec
// Place the variable with index 0 in the tape
Expand Down Expand Up @@ -270,7 +270,7 @@ void ADFun<Base, RecBase>::val2fun(
fun_ad_type[ dyn_ind[i] ] = dynamic_enum;
par_addr = rec.put_dyn_par(nan, local::ind_dyn);
val2fun_index[ dyn_ind[i] ] = par_addr;
CPPAD_ASSERT_UNKNOWN( isnan( parameter[par_addr] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[par_addr] ) );
}
// put the independent variables in the function recording
for(size_t i = 0; i < var_n_ind; ++i)
Expand Down Expand Up @@ -484,7 +484,7 @@ void ADFun<Base, RecBase>::val2fun(
CPPAD_VAL2FUN_DYN_BINARY(div);
CPPAD_VAL2FUN_DYN_BINARY(pow);
}
CPPAD_ASSERT_UNKNOWN( isnan( parameter[tmp_addr] ) );
CPPAD_ASSERT_UNKNOWN( CppAD::isnan( parameter[tmp_addr] ) );
}
else if(
ad_type_x[0] == variable_enum &&
Expand Down
Loading

0 comments on commit ff01a85

Please sign in to comment.