cs_safe.py

collection of complex-step safe functions to replace standard numpy operations.

openmdao.utils.cs_safe.abs(x)[source]

complex-step safe version of numpy.abs function.

Parameters
xndarray

array value to be computed on

Returns
ndarray
openmdao.utils.cs_safe.arctan2(y, x)[source]

Numpy-compatible, complex-compatible arctan2 function for use with complex-step.

Parameters
yfloat or complex

The length of the side opposite the angle being determined.

xfloat or complex

The length of the side adjacent to the angle being determined.

Returns
ndarray

The angle whose opposite side has length y and whose adjacent side has length x.

openmdao.utils.cs_safe.norm(x, axis=None)[source]

complex-step safe version of numpy.linalg.norm function.

Parameters
xndarray

array value to be computed on

axisNone or int

axis to perform the norm up to

Returns
ndarray