GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • 
  • Consortium for Python Data API Standards
  • API specification
  • Element-wise Functions
  • Purpose and scope
  • Terms and Definitions
  • Use cases
  • Assumptions
  • Design topics & constraints
  • Future API standard evolution
  • Array object
  • Broadcasting
  • Constants
  • Creation Functions

This view

  • Original page
  • New address

GeezerVison is showing data-apis.org — copysign — Python array API standard DRAFT documentation

copysign¶

copysign(x1: array | int | float, x2: array | int | float, /) → array¶

Composes a floating-point value with the magnitude of x1_i and the sign of x2_i for each element of the input array x1.

Parameters:
  • x1 (Union[array, int, float]) – input array containing magnitudes. Should have a real-valued floating-point data type.

  • x2 (Union[array, int, float]) – input array whose sign bits are applied to the magnitudes of x1. Must be compatible with x1 (see Broadcasting). Should have a real-valued floating-point data type.

Returns:

out (array) – an array containing the element-wise results. The returned array must have a floating-point data type determined by Type Promotion Rules.

Notes

  • At least one of x1 or x2 must be an array.

Special cases

For real-valued floating-point operands, let |x| be the absolute value, and if x1_i is not NaN,

  • If x2_i is less than 0, the result is -|x1_i|.

  • If x2_i is -0, the result is -|x1_i|.

  • If x2_i is +0, the result is |x1_i|.

  • If x2_i is greater than 0, the result is |x1_i|.

  • If x2_i is NaN and the sign bit of x2_i is 1, the result is -|x1_i|.

  • If x2_i is NaN and the sign bit of x2_i is 0, the result is |x1_i|.

  • If x1_i is NaN and x2_i is less than 0, the result is NaN with a sign bit of 1.

  • If x1_i is NaN and x2_i is -0, the result is NaN with a sign bit of 1.

  • If x1_i is NaN and x2_i is +0, the result is NaN with a sign bit of 0.

  • If x1_i is NaN and x2_i is greater than 0, the result is NaN with a sign bit of 0.

  • If x1_i is NaN and x2_i is NaN and the sign bit of x2_i is 1, the result is NaN with a sign bit of 1.

  • If x1_i is NaN and x2_i is NaN and the sign bit of x2_i is 0, the result is NaN with a sign bit of 0.

New in version 2023.12.

Changed in version 2024.12: Added scalar argument support.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.