nums.numpy.cos

nums.numpy.cos(x, out=None, where=True, **kwargs)[source]

Cosine element-wise.

This docstring was copied from numpy.cos.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array in radians.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The corresponding cosine values.

Return type

BlockArray

Notes

If out is provided, the function writes the result into it, and returns a reference to out. (See Examples)

References

M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. New York, NY: Dover, 1972.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.cos(nps.array([0, nps.pi/2, nps.pi])).get()  
array([  1.00000000e+00,   6.12303177e-17,  -1.00000000e+00])