Package org.apache.sysds.runtime.matrix.operators

## Class BinaryOperator

- java.lang.Object
- - org.apache.sysds.runtime.matrix.operators.Operator
  - - org.apache.sysds.runtime.matrix.operators.MultiThreadedOperator
    - - org.apache.sysds.runtime.matrix.operators.BinaryOperator

All Implemented Interfaces:
  `Serializable`

    public class BinaryOperator
    extends MultiThreadedOperator

BinaryOperator class for operations that have two inputs. For instance

    BinaryOperator op = new BinaryOperator(Plus.getPlusFnObject());
    double r = op.execute(5.0, 8.2)

See Also:
  Serialized Form

### Field Summary

Fields
`boolean` `commutative`
`ValueFunction` `fn`

### Fields inherited from class org.apache.sysds.runtime.matrix.operators.Operator

`sparseSafe`

### Constructor Summary

Constructors
`BinaryOperator​(ValueFunction p)`
`BinaryOperator​(ValueFunction p, int k)`

### Method Summary

All Methods Instance Methods Concrete Methods
`Types.OpOp2` `getBinaryOperatorOpOp2()` Method for getting the hop binary operator type for a given function object.
`boolean` `isCommutative()`
`boolean` `isIntroducingZerosLeft​(double[] row)` Check if the operation returns zeros if the input is contained in row.
`boolean` `isIntroducingZerosLeft​(MatrixBlock row)` Check if the operation returns zeros if the input is contained in row.
`boolean` `isIntroducingZerosRight​(double[] row)` Check if the operation returns zeros if the input is contained in row.
`boolean` `isIntroducingZerosRight​(MatrixBlock row)` Check if the operation returns zeros if the input is contained in row.
`boolean` `isRowSafeLeft​(double[] row)` Check if the operation returns zeros if the input zero.
`boolean` `isRowSafeLeft​(MatrixBlock row)` Check if the operation returns zeros if the input zero.
`boolean` `isRowSafeRight​(double[] row)` Check if the operation returns zeros if the input zero.
`boolean` `isRowSafeRight​(MatrixBlock row)` Check if the operation returns zeros if the input zero.
`String` `toString()`

### Methods inherited from class org.apache.sysds.runtime.matrix.operators.MultiThreadedOperator

`getNumThreads, setNumThreads`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### fn

    public final ValueFunction fn

#### commutative

    public final boolean commutative

### Constructor Detail

#### BinaryOperator

    public BinaryOperator​(ValueFunction p)

#### BinaryOperator

    public BinaryOperator​(ValueFunction p,
                          int k)

### Method Detail

#### getBinaryOperatorOpOp2

    public Types.OpOp2 getBinaryOperatorOpOp2()

Method for getting the hop binary operator type for a given function object. This is used in order to use a common code path for consistency between compiler and runtime.

Returns:
  binary operator type for a function object

#### isCommutative

    public boolean isCommutative()

#### isRowSafeLeft

    public boolean isRowSafeLeft​(double[] row)

Check if the operation returns zeros if the input zero.

Parameters:
  `row` - The values to check
Returns:
  If the output is always zero if other value is zero

#### isRowSafeLeft

    public boolean isRowSafeLeft​(MatrixBlock row)

Check if the operation returns zeros if the input zero.

Parameters:
  `row` - The values to check
Returns:
  If the output is always zero if other value is zero

#### isIntroducingZerosLeft

    public boolean isIntroducingZerosLeft​(MatrixBlock row)

Check if the operation returns zeros if the input is contained in row.

Parameters:
  `row` - The values to check
Returns:
  If the output contains zeros

#### isIntroducingZerosLeft

    public boolean isIntroducingZerosLeft​(double[] row)

Check if the operation returns zeros if the input is contained in row.

Parameters:
  `row` - The values to check
Returns:
  If the output contains zeros

#### isRowSafeRight

    public boolean isRowSafeRight​(double[] row)

Check if the operation returns zeros if the input zero.

Parameters:
  `row` - The values to check
Returns:
  If the output is always zero if other value is zero

#### isRowSafeRight

    public boolean isRowSafeRight​(MatrixBlock row)

Check if the operation returns zeros if the input zero.

Parameters:
  `row` - The values to check
Returns:
  If the output is always zero if other value is zero

#### isIntroducingZerosRight

    public boolean isIntroducingZerosRight​(MatrixBlock row)

Check if the operation returns zeros if the input is contained in row.

Parameters:
  `row` - The values to check
Returns:
  If the output contains zeros

#### isIntroducingZerosRight

    public boolean isIntroducingZerosRight​(double[] row)

Check if the operation returns zeros if the input is contained in row.

Parameters:
  `row` - The values to check
Returns:
  If the output contains zeros

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`