From 5c0c54dce9ff84b2ffab803eee1aa68c4bf80784 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen <pauli.t.virtanen@jyu.fi> Date: Tue, 23 Apr 2024 13:50:18 +0300 Subject: [PATCH] src: CppAD 2024 wants ordered complex numbers Fix compilation error. Define lexical order for complex numbers. --- src/common.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common.hpp b/src/common.hpp index 4c73306..fd5d680 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -63,6 +63,10 @@ namespace CppAD { COMMON_HPP_DECLARE_BINOP(*); COMMON_HPP_DECLARE_BINOP(/); #undef COMMON_HPP_DECLARE_BINOP + + /* CppAD needs comparisons; use lexical order for complex */ + bool operator <=(const Complex& a, const Complex& b) { return a.real() == b.real() ? (a.imag() <= b.imag()) : (a.real() <= b.real()); } + bool operator <(const Complex& a, const Complex& b) { return a.real() == b.real() ? (a.imag() < b.imag()) : (a.real() < b.real()); } } #endif -- GitLab