From 156b06c69d15eaa5fc21efcd8c06ff358a5be925 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 30 May 2022 03:04:44 -0700 Subject: [PATCH] Add complex number support to `negative` --- spec/API_specification/array_api/array_object.py | 5 ++++- spec/API_specification/array_api/elementwise_functions.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/array_api/array_object.py b/spec/API_specification/array_api/array_object.py index a8f00bfda..34cd3cc7a 100644 --- a/spec/API_specification/array_api/array_object.py +++ b/spec/API_specification/array_api/array_object.py @@ -746,10 +746,13 @@ def __neg__(self: array, /) -> array: .. note:: For signed integer data types, the numerical negative of the minimum representable integer is implementation-dependent. + .. note:: + If ``self`` has a complex floating-point data type, both the real and imaginary components for each ``self_i`` must be negated (a result which follows from the rules of complex number multiplication). + Parameters ---------- self: array - array instance. Should have a real-valued data type. + array instance. Should have a numeric data type. Returns ------- diff --git a/spec/API_specification/array_api/elementwise_functions.py b/spec/API_specification/array_api/elementwise_functions.py index f72af2089..9a6034846 100644 --- a/spec/API_specification/array_api/elementwise_functions.py +++ b/spec/API_specification/array_api/elementwise_functions.py @@ -1014,10 +1014,13 @@ def negative(x: array, /) -> array: .. note:: For signed integer data types, the numerical negative of the minimum representable integer is implementation-dependent. + .. note:: + If ``x`` has a complex floating-point data type, both the real and imaginary components for each ``x_i`` must be negated (a result which follows from the rules of complex number multiplication). + Parameters ---------- x: array - input array. Should have a real-valued data type. + input array. Should have a numeric data type. Returns -------