|
1 | 1 | /* |
2 | | - * Copyright (c) 2004-2015 Tada AB and other contributors, as listed below. |
| 2 | + * Copyright (c) 2004-2021 Tada AB and other contributors, as listed below. |
3 | 3 | * |
4 | 4 | * All rights reserved. This program and the accompanying materials |
5 | 5 | * are made available under the terms of the The BSD 3-Clause License |
@@ -242,6 +242,41 @@ public static boolean componentsEQ(ComplexScalar a, ComplexScalar b) |
242 | 242 | return a.m_x == b.m_x && a.m_y == b.m_y; |
243 | 243 | } |
244 | 244 |
|
| 245 | + /** |
| 246 | + * True if the complex argument is real-valued and equal to the real |
| 247 | + * argument. |
| 248 | + *<p> |
| 249 | + * From one equality method on (complex,double) can be synthesized all four |
| 250 | + * cross-type operators, {@code =} and {@code <>} for that pair of types and |
| 251 | + * their {@code TWIN} commutators. One of the {@code <>} twins does need to |
| 252 | + * specify what its synthetic function should be named. |
| 253 | + */ |
| 254 | + @Operator( |
| 255 | + name = "javatest.=", |
| 256 | + commutator = TWIN, negator = "javatest.<>", |
| 257 | + provides = "complex:double relationals" |
| 258 | + ) |
| 259 | + @Operator( |
| 260 | + name = "javatest.=", |
| 261 | + synthetic = TWIN, negator = "javatest.<>", |
| 262 | + provides = "complex:double relationals" |
| 263 | + ) |
| 264 | + @Operator( |
| 265 | + name = "javatest.<>", synthetic = "javatest.neToReal", |
| 266 | + commutator = TWIN, provides = "complex:double relationals" |
| 267 | + ) |
| 268 | + @Operator( |
| 269 | + name = "javatest.<>", synthetic = TWIN, |
| 270 | + provides = "complex:double relationals" |
| 271 | + ) |
| 272 | + @Function( |
| 273 | + schema = "javatest", effects = IMMUTABLE, onNullInput = RETURNS_NULL |
| 274 | + ) |
| 275 | + public static boolean eqToReal(ComplexScalar a, double b) |
| 276 | + { |
| 277 | + return a.m_x == b && 0. == a.m_y; |
| 278 | + } |
| 279 | + |
245 | 280 | /** |
246 | 281 | * As an ordinary function, returns the lesser in magnitude of two |
247 | 282 | * arguments; as a simple aggregate, returns the least in magnitude over its |
|
0 commit comments