# Element-wise Operations¶

COO arrays support a variety of element-wise operations. However, as with operators, operations that map zero to a nonzero value are not supported.

To illustrate, the following are all possible, and will produce another COO array:

x.abs()
np.sin(x)
np.sqrt(x)
x.conj()
x.expm1()
np.log1p(x)


However, the following are all unsupported and will raise a ValueError:

x.exp()
np.cos(x)
np.log(x)


Notice that you can apply any unary or binary numpy.ufunc to COO arrays, scipy.sparse.spmatrix objects and scalars and it will work so long as the result is not dense.

## COO.elemwise¶

This function allows you to apply any arbitrary unary or binary function where the first object is COO, and the second is a scalar, COO, or a scipy.sparse.spmatrix. For example, the following will add two COO objects:

x.elemwise(np.add, y)


## Partial List of Supported numpy.ufunc s¶

Although any unary or binary numpy.ufunc should work if the result is not dense, when calling in the form x.func(), the following operations are supported: