Skip to content

Commit 4f65128

Browse files
committed
Add log10
1 parent ff7b613 commit 4f65128

File tree

6 files changed

+9
-1
lines changed

6 files changed

+9
-1
lines changed

include/pyoptinterface/nlexpr.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ enum class UnaryOperator
5959
Sqrt,
6060
Exp,
6161
Log,
62+
Log10
6263
};
6364

6465
enum class BinaryOperator

lib/cppad_interface.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ CppAD::AD<double> cppad_build_unary_expression(UnaryOperator op, const CppAD::AD
242242
case UnaryOperator::Log: {
243243
return CppAD::log(operand);
244244
}
245+
case UnaryOperator::Log10: {
246+
return CppAD::log10(operand);
247+
}
245248
default: {
246249
throw std::runtime_error("Invalid unary operator");
247250
}

lib/nlexpr_ext.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ NB_MODULE(nlexpr_ext, m)
3939
.value("Abs", UnaryOperator::Abs)
4040
.value("Sqrt", UnaryOperator::Sqrt)
4141
.value("Exp", UnaryOperator::Exp)
42-
.value("Log", UnaryOperator::Log);
42+
.value("Log", UnaryOperator::Log)
43+
.value("Log10", UnaryOperator::Log10);
4344

4445
nb::enum_<BinaryOperator>(m, "BinaryOperator")
4546
.value("Sub", BinaryOperator::Sub)

src/pyoptinterface/_src/function_tracing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def f(expr):
166166
sqrt = unary_mathematical_function(math.sqrt, UnaryOperator.Sqrt)
167167
exp = unary_mathematical_function(math.exp, UnaryOperator.Exp)
168168
log = unary_mathematical_function(math.log, UnaryOperator.Log)
169+
log10 = unary_mathematical_function(math.log10, UnaryOperator.Log10)
169170

170171

171172
# Implement binary mathematical functions

src/pyoptinterface/nlfunc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
sqrt,
1212
exp,
1313
log,
14+
log10,
1415
pow,
1516
ifelse,
1617
)

tests/test_nlp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def con(vars):
4444
nlfunc.cos,
4545
nlfunc.exp,
4646
nlfunc.log,
47+
nlfunc.log10,
4748
nlfunc.pow,
4849
nlfunc.sin,
4950
nlfunc.sqrt,

0 commit comments

Comments
 (0)