Skip to content

Commit 0ffa3c9

Browse files
committed
different fix for #1164
1 parent 7d827e2 commit 0ffa3c9

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Common/include/linear_algebra/vector_expressions.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,16 @@ FORCEINLINE auto FUN(decay_t<S> u, const CVecExpr<V,S>& v) \
157157
RETURNS( EXPR<Bcast<S>,V,S>(Bcast<S>(u), v.derived()) \
158158
) \
159159

160-
/*--- std::max/min have issues (maybe because they return by reference). ---*/
160+
/*--- std::max/min have issues (maybe because they return by reference).
161+
* For AD codi::max/min need to be used to avoid issues in debug builds. ---*/
161162

163+
#if defined(CODI_REVERSE_TYPE) || defined(CODI_FORWARD_TYPE)
164+
#define max_impl math::max
165+
#define min_impl math::min
166+
#else
162167
#define max_impl(a,b) a<b? Scalar(b) : Scalar(a)
163168
#define min_impl(a,b) b<a? Scalar(b) : Scalar(a)
169+
#endif
164170
MAKE_BINARY_FUN(max, max_, max_impl)
165171
MAKE_BINARY_FUN(min, min_, min_impl)
166172
MAKE_BINARY_FUN(pow, pow_, math::pow)

Common/include/parallelization/vectorization.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Array : public CVecExpr<Array<Scalar_t,N>, Scalar_t> {
7575
using Scalar = Scalar_t;
7676
enum : size_t {Size = N};
7777
enum : size_t {Align = Size*sizeof(Scalar)};
78-
static constexpr bool StoreAsRef = false;
78+
static constexpr bool StoreAsRef = true;
7979

8080
private:
8181
alignas(Size*sizeof(Scalar)) Scalar x_[N];

0 commit comments

Comments
 (0)