NumPhp::copysign

Change the sign of m-element to that of n-element, element-wise.

Description

SciPhp\NdArray NumPhp::copysign( array|NdArray $m , array|NdArray $n )

Parameters

$m
An array [1, 2, 3] or a NdArray.
$n
An array [1, 2, 3] or a NdArray.

Return Values

A SciPhp\NdArray

Examples

Example #1: Construct a copysign array

use SciPhp\NumPhp as np;

$m np::ar([-555]);
$n np::ar([10, -1]);

$r np::copysign($m$n);

echo 
"m\n$m""n\n$n""r\n$r";

The above example will output:

m
[-5  5   5 ]
n
[1   0   -1]
r
[5   5   -5]

See Also

  • NumPhp::signbit() - Returns element-wise true where signbit is set (less than zero).