mars.tensor.modf#
- mars.tensor.modf(x, out1=None, out2=None, out=None, where=None, **kwargs)[源代码]#
Return the fractional and integral parts of a tensor, element-wise.
The fractional and integral parts are negative if the given number is negative.
- 参数
x (array_like) – Input tensor.
out (Tensor, None, or tuple of Tensor and None, 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 tensor is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
where (array_like, optional) – Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone.
**kwargs –
- 返回
y1 (Tensor) – Fractional part of x.
y2 (Tensor) – Integral part of x.
提示
For integer input the return values are floats.
参见
divmod
divmod(x, 1)
is equivalent tomodf
with the return values switched, except it always has a positive remainder.
实际案例
>>> import mars.tensor as mt
>>> mt.modf([0, 3.5]).execute() (array([ 0. , 0.5]), array([ 0., 3.])) >>> mt.modf(-0.5).execute() (-0.5, -0)