mikera.vectorz
Class Op
- java.lang.Object
-
- mikera.vectorz.Op
-
- All Implemented Interfaces:
- IOperator
- Direct Known Subclasses:
- ABoundedOp, Absolute, AFunctionOp, APolynomialOp, Composed, Division, GaussianNoise, Inverse, Power, Product, ScaledLogistic, Sum
public abstract class Op extends java.lang.Object implements IOperator
Abstract class for representing a unary operation
-
-
Constructor Summary
Constructors Constructor and Description Op()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract doubleapply(double x)Applies this operator to a single value, returning the resultdoubleapplyInverse(double y)Applies the inverse of this Op.voidapplyTo(ADenseArrayVector v)Applies this operator to a dense array vector, mutating the vectorvoidapplyTo(AMatrix m)Applies this operator to every element of a target matrix, mutating the matrixvoidapplyTo(AScalar s)Applies this operator to a scalar, mutating the scalarvoidapplyTo(AVector v)Applies this operator to a mutable vector.voidapplyTo(AVector v, int offset, int length)Applies this operator to the specified range within a mutable vector.voidapplyTo(double[] data)Applies this operator to every element in a double[] array, mutating the array in placevoidapplyTo(double[] data, int offset, int length)Applies this operator to the specified range within a double[] array.voidapplyTo(double[] data, int offset, int stride, int length)Applies this operator to the specified strided range within a double[] array.voidapplyTo(INDArray a)Applies this operator to every element of a target array.doubleaverageValue()Opcompose(Op op)static Opcompose(Op op1, Op op2)voidconstrainValues(double[] src, double[] dest, int offset, int length)Creates a copy of the values of src in dest, constraining them to be within the valid range of output values from this Opdoublederivative(double x)Returns the derivative of this Op for a given input value x i.e.doublederivativeForOutput(double y)Returns the derivative of this Op for a given output value y i.e.Opdivide(Op op)OpgetDerivativeOp()Gets an operator which represents the derivative of this operator.OpgetInverse()Gets the inverse of this operator.ATransformgetTransform(int dims)Converts an operator into a corresponding transform that applies the operator to all elements of its inputbooleanhasDerivative()Returns true if this operator supports computing the derivative for a given inputbooleanhasDerivativeForOutput()Returns true if this operator supports computing the derivative for a given outputbooleanhasInverse()Returns true if this operator supports computing the inverse for a given outputbooleanisBounded()Returns true if this operator has a known finite upper or lower boundbooleanisDomainBounded()booleanisStochastic()Returns true if the operator is stochastic, i.e returns random values for at least some inputsdoublemaxDomain()doublemaxValue()doubleminDomain()doubleminValue()Opproduct(Op op)Opsum(Op op)java.lang.StringtoString()booleanvalidateOutput(double[] output)Validates whether all values in a double[] are within the possible output range for this Op
-
-
-
Method Detail
-
apply
public abstract double apply(double x)
Description copied from interface:IOperatorApplies this operator to a single value, returning the result
-
applyInverse
public double applyInverse(double y)
Applies the inverse of this Op. Throws an error if the inverse function does not exist. Returns Double.NaN if no inverse exists for the specific value of y.- Parameters:
y-- Returns:
-
applyTo
public void applyTo(AVector v)
Description copied from interface:IOperatorApplies this operator to a mutable vector.
-
applyTo
public void applyTo(AMatrix m)
Applies this operator to every element of a target matrix, mutating the matrix
-
applyTo
public void applyTo(AVector v, int offset, int length)
Description copied from interface:IOperatorApplies this operator to the specified range within a mutable vector.
-
applyTo
public void applyTo(AScalar s)
Applies this operator to a scalar, mutating the scalar- Parameters:
s-
-
applyTo
public void applyTo(ADenseArrayVector v)
Applies this operator to a dense array vector, mutating the vector- Parameters:
s-
-
applyTo
public void applyTo(INDArray a)
Applies this operator to every element of a target array. Mutates the array in place.- Parameters:
a-
-
applyTo
public void applyTo(double[] data, int offset, int length)Description copied from interface:IOperatorApplies this operator to the specified range within a double[] array.
-
applyTo
public void applyTo(double[] data, int offset, int stride, int length)Description copied from interface:IOperatorApplies this operator to the specified strided range within a double[] array.
-
applyTo
public void applyTo(double[] data)
Applies this operator to every element in a double[] array, mutating the array in place- Parameters:
data-
-
getTransform
public ATransform getTransform(int dims)
Description copied from interface:IOperatorConverts an operator into a corresponding transform that applies the operator to all elements of its input- Specified by:
getTransformin interfaceIOperator- Returns:
-
getInverse
public Op getInverse()
Description copied from interface:IOperatorGets the inverse of this operator. Returns null if no inverse exists.- Specified by:
getInversein interfaceIOperator- Returns:
-
hasDerivative
public boolean hasDerivative()
Returns true if this operator supports computing the derivative for a given input- Returns:
-
hasDerivativeForOutput
public boolean hasDerivativeForOutput()
Returns true if this operator supports computing the derivative for a given output- Returns:
-
hasInverse
public boolean hasInverse()
Returns true if this operator supports computing the inverse for a given output- Returns:
-
derivativeForOutput
public double derivativeForOutput(double y)
Returns the derivative of this Op for a given output value y i.e. f'(g(y)) where f is the operator, g is the inverse of f- Parameters:
y-- Returns:
-
derivative
public double derivative(double x)
Returns the derivative of this Op for a given input value x i.e. f'(x) where f is the operator- Parameters:
y-- Returns:
-
isStochastic
public boolean isStochastic()
Returns true if the operator is stochastic, i.e returns random values for at least some inputs- Returns:
-
averageValue
public double averageValue()
-
minValue
public double minValue()
-
maxValue
public double maxValue()
-
minDomain
public double minDomain()
-
maxDomain
public double maxDomain()
-
isDomainBounded
public boolean isDomainBounded()
-
validateOutput
public boolean validateOutput(double[] output)
Validates whether all values in a double[] are within the possible output range for this Op- Parameters:
output-- Returns:
-
constrainValues
public void constrainValues(double[] src, double[] dest, int offset, int length)Creates a copy of the values of src in dest, constraining them to be within the valid range of output values from this Op- Parameters:
src-dest-offset-length-
-
isBounded
public boolean isBounded()
Returns true if this operator has a known finite upper or lower bound- Returns:
-
getDerivativeOp
public Op getDerivativeOp()
Gets an operator which represents the derivative of this operator. Returns nil if this cannot be computed or does not exist.- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG