Top Description Fields Constructors Methods
org.apache.commons.math3.analysis.differentiation

public Class SparseGradient

extends Object
implements RealFieldElement<SparseGradient>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.RealFieldElement, org.apache.commons.math3.FieldElement
Imports
java.io.Serializable, java.util.Collections, .HashMap, .Map, org.apache.commons.math3.Field, .FieldElement, .RealFieldElement, org.apache.commons.math3.exception.DimensionMismatchException, org.apache.commons.math3.util.FastMath, .MathArrays, .MathUtils, .Precision

First derivative computation with large number of variables.

This class plays a similar role to DerivativeStructure, with a focus on efficiency when dealing with large number of independent variables and most computation depend only on a few of them, and when only first derivative is desired. When these conditions are met, this class should be much faster than DerivativeStructure and use less memory.

Since
3.3

Field Summary

Modifier and TypeField and Description
private final Map<Integer, Double>
derivatives

Stored derivative, each key representing a different independent variable.

private static final long
serialVersionUID

Serializable UID.

private double
value

Value of the calculation.

Constructor Summary

AccessConstructor and Description
private
SparseGradient(final double
value of the function
value
,
final Map<Integer, Double>
derivatives map, a deep copy will be performed, so the map given here will remain safe from changes in the new instance, may be null to create an empty derivatives map, i.e. a constant value
derivatives
)

Internal constructor.

private
SparseGradient(final double
value of the function
value
,
final double
scaling factor to apply to all derivatives
scale
,
final Map<Integer, Double>
derivatives map, a deep copy will be performed, so the map given here will remain safe from changes in the new instance, may be null to create an empty derivatives map, i.e. a constant value
derivatives
)

Internal constructor.

Method Summary

Modifier and TypeMethod and Description
public SparseGradient
public SparseGradient
acos()

Implements org.apache.commons.math3.RealFieldElement.acos.

Arc cosine operation.

public SparseGradient
acosh()

Implements org.apache.commons.math3.RealFieldElement.acosh.

Inverse hyperbolic cosine operation.

public SparseGradient
add(final SparseGradient
element to add
a
)

Implements org.apache.commons.math3.FieldElement.add.

Compute this + a.

public SparseGradient
add(final double
right hand side parameter of the operator
c
)

Implements org.apache.commons.math3.RealFieldElement.add.

'+' operator.

public void
addInPlace(final SparseGradient
instance to add
a
)

Add in place.

public SparseGradient
asin()

Implements org.apache.commons.math3.RealFieldElement.asin.

Arc sine operation.

public SparseGradient
asinh()

Implements org.apache.commons.math3.RealFieldElement.asinh.

Inverse hyperbolic sine operation.

public SparseGradient
atan()

Implements org.apache.commons.math3.RealFieldElement.atan.

Arc tangent operation.

public SparseGradient
atan2(final SparseGradient
second argument of the arc tangent
x
)

Implements org.apache.commons.math3.RealFieldElement.atan2.

Two arguments arc tangent operation.

public static SparseGradient

Returns:

atan2(y, x)
atan2
(final SparseGradient
first argument of the arc tangent
y
,
final SparseGradient
second argument of the arc tangent
x
)

Two arguments arc tangent operation.

public SparseGradient
atanh()

Implements org.apache.commons.math3.RealFieldElement.atanh.

Inverse hyperbolic tangent operation.

public SparseGradient
public SparseGradient
ceil()

Implements org.apache.commons.math3.RealFieldElement.ceil.

Get the smallest whole number larger than instance.

public SparseGradient

Returns:

f(this)
compose
(final double
value of the function at (i.e. f(getValue()))
f0
,
final double
first derivative of the function at the current point (i.e. f'(getValue()))
f1
)

Compute composition of the instance by a univariate function.

public SparseGradient
copySign(final SparseGradient
the sign for the returned value
sign
)

Implements org.apache.commons.math3.RealFieldElement.copySign.

Returns the instance with the sign of the argument.

public SparseGradient
copySign(final double
the sign for the returned value
sign
)

Implements org.apache.commons.math3.RealFieldElement.copySign, org.apache.commons.math3.RealFieldElement.copySign.

Returns the instance with the sign of the argument.

public SparseGradient
cos()

Implements org.apache.commons.math3.RealFieldElement.cos.

Cosine operation.

public SparseGradient
cosh()

Implements org.apache.commons.math3.RealFieldElement.cosh.

Hyperbolic cosine operation.

public static SparseGradient

Returns:

a new instance
createConstant
(final double
value of the constant
value
)

Factory method creating a constant.

public static SparseGradient

Returns:

a new instance
createVariable
(final int
index of the variable
idx
,
final double
value of the variable
value
)

Factory method creating an independent variable.

public SparseGradient
divide(final SparseGradient
element to divide by
a
)

Implements org.apache.commons.math3.FieldElement.divide.

Compute this ÷ a.

public SparseGradient
divide(final double
right hand side parameter of the operator
c
)

Implements org.apache.commons.math3.RealFieldElement.divide.

'÷' operator.

public boolean

Returns:

true if two sparse gradients are equal
equals
(Object
Object to test for equality to this
other
)

Overrides java.lang.Object.equals.

Test for the equality of two sparse gradients.

public SparseGradient
public SparseGradient
expm1()

Implements org.apache.commons.math3.RealFieldElement.expm1.

Exponential minus 1.

public SparseGradient
floor()

Implements org.apache.commons.math3.RealFieldElement.floor.

Get the largest whole number smaller than instance.

public double

Returns:

derivative with respect to a particular index variable
getDerivative
(final int
index to differentiate with.
index
)

Get the derivative with respect to a particular index variable.

public Field<SparseGradient>
getField()

Implements org.apache.commons.math3.FieldElement.getField.

Get the Field to which the instance belongs.

public double
getReal()

Implements org.apache.commons.math3.RealFieldElement.getReal.

Get the real value of the number.

public double

Returns:

value of the function.
getValue
()

Get the value of the function.

public int

Returns:

a hash code value for this object
hashCode
()

Overrides java.lang.Object.hashCode.

Get a hashCode for the derivative structure.

public SparseGradient
hypot(final SparseGradient
a value
y
)

Implements org.apache.commons.math3.RealFieldElement.hypot.

Returns the hypotenuse of a triangle with sides this and y - sqrt(this2 +y2) avoiding intermediate overflow or underflow.

public static SparseGradient

Returns:

sqrt(x2 +y2)
hypot
(final SparseGradient
a value
x
,
final SparseGradient
a value
y
)

Returns the hypotenuse of a triangle with sides x and y - sqrt(x2 +y2) avoiding intermediate overflow or underflow.

public SparseGradient
linearCombination(final SparseGradient[]
Factors.
a
,
final SparseGradient[]
Factors.
b
)

Implements org.apache.commons.math3.RealFieldElement.linearCombination.

Compute a linear combination.

public SparseGradient
public SparseGradient
linearCombination(final SparseGradient
first factor of the first term
a1
,
final SparseGradient
second factor of the first term
b1
,
final SparseGradient
first factor of the second term
a2
,
final SparseGradient
second factor of the second term
b2
)

Implements org.apache.commons.math3.RealFieldElement.linearCombination.

Compute a linear combination.

public SparseGradient
linearCombination(final double
first factor of the first term
a1
,
final SparseGradient
second factor of the first term
b1
,
final double
first factor of the second term
a2
,
final SparseGradient
second factor of the second term
b2
)

Implements org.apache.commons.math3.RealFieldElement.linearCombination, org.apache.commons.math3.RealFieldElement.linearCombination.

Compute a linear combination.

public SparseGradient
linearCombination(final SparseGradient
first factor of the first term
a1
,
final SparseGradient
second factor of the first term
b1
,
final SparseGradient
first factor of the second term
a2
,
final SparseGradient
second factor of the second term
b2
,
final SparseGradient
first factor of the third term
a3
,
final SparseGradient
second factor of the third term
b3
)

Implements org.apache.commons.math3.RealFieldElement.linearCombination.

Compute a linear combination.

public SparseGradient
linearCombination(final double
first factor of the first term
a1
,
final SparseGradient
second factor of the first term
b1
,
final double
first factor of the second term
a2
,
final SparseGradient
second factor of the second term
b2
,
final double
first factor of the third term
a3
,
final SparseGradient
second factor of the third term
b3
)

Implements org.apache.commons.math3.RealFieldElement.linearCombination, org.apache.commons.math3.RealFieldElement.linearCombination.

Compute a linear combination.

public SparseGradient
linearCombination(final SparseGradient
first factor of the first term
a1
,
final SparseGradient
second factor of the first term
b1
,
final SparseGradient
first factor of the second term
a2
,
final SparseGradient
second factor of the second term
b2
,
final SparseGradient
first factor of the third term
a3
,
final SparseGradient
second factor of the third term
b3
,
final SparseGradient
first factor of the third term
a4
,
final SparseGradient
second factor of the third term
b4
)

Implements org.apache.commons.math3.RealFieldElement.linearCombination.

Compute a linear combination.

public SparseGradient
linearCombination(final double
first factor of the first term
a1
,
final SparseGradient
second factor of the first term
b1
,
final double
first factor of the second term
a2
,
final SparseGradient
second factor of the second term
b2
,
final double
first factor of the third term
a3
,
final SparseGradient
second factor of the third term
b3
,
final double
first factor of the third term
a4
,
final SparseGradient
second factor of the third term
b4
)

Implements org.apache.commons.math3.RealFieldElement.linearCombination, org.apache.commons.math3.RealFieldElement.linearCombination.

Compute a linear combination.

public SparseGradient
log()

Implements org.apache.commons.math3.RealFieldElement.log.

Natural logarithm.

public SparseGradient

Returns:

base 10 logarithm of the instance
log10
()

Base 10 logarithm.

public SparseGradient
log1p()

Implements org.apache.commons.math3.RealFieldElement.log1p.

Shifted natural logarithm.

public SparseGradient
multiply(final SparseGradient
element to multiply
a
)

Implements org.apache.commons.math3.FieldElement.multiply.

Compute this × a.

public SparseGradient
multiply(final double
right hand side parameter of the operator
c
)

Implements org.apache.commons.math3.RealFieldElement.multiply.

'×' operator.

public SparseGradient
multiply(final int
Number of times this must be added to itself.
n
)

Implements org.apache.commons.math3.FieldElement.multiply, org.apache.commons.math3.FieldElement.multiply.

Compute n × this.</center>

public void
multiplyInPlace(final SparseGradient
instance to multiply
a
)

Multiply in place.

public SparseGradient
negate()

Implements org.apache.commons.math3.FieldElement.negate.

Returns the additive inverse of this element.

public int

Returns:

number of variables
numVars
()

Find the number of variables.

public SparseGradient
pow(final double
power to apply
p
)

Implements org.apache.commons.math3.RealFieldElement.pow, org.apache.commons.math3.RealFieldElement.pow.

Power operation.

public SparseGradient
pow(final int
power to apply
n
)

Implements org.apache.commons.math3.RealFieldElement.pow, org.apache.commons.math3.RealFieldElement.pow.

Integer power operation.

public SparseGradient
pow(final SparseGradient
exponent
e
)

Implements org.apache.commons.math3.RealFieldElement.pow.

Power operation.

public static SparseGradient

Returns:

ax
pow
(final double
number to exponentiate
a
,
final SparseGradient
power to apply
x
)

Compute ax where a is a double and x a SparseGradient

public SparseGradient
reciprocal()

Implements org.apache.commons.math3.RealFieldElement.reciprocal.

Returns the multiplicative inverse of this element.

public SparseGradient
remainder(final double
right hand side parameter of the operator
a
)

Implements org.apache.commons.math3.RealFieldElement.remainder, org.apache.commons.math3.RealFieldElement.remainder.

IEEE remainder operator.

public SparseGradient
remainder(final SparseGradient
right hand side parameter of the operator
a
)

Implements org.apache.commons.math3.RealFieldElement.remainder.

IEEE remainder operator.

public SparseGradient
rint()

Implements org.apache.commons.math3.RealFieldElement.rint.

Get the whole number that is the nearest to the instance, or the even one if x is exactly half way between two integers.

public SparseGradient
rootN(final int
order of the root
n
)

Implements org.apache.commons.math3.RealFieldElement.rootN.

Nth root.

public long
round()

Implements org.apache.commons.math3.RealFieldElement.round.

Get the closest long to instance value.

public SparseGradient
scalb(final int
power of 2
n
)

Implements org.apache.commons.math3.RealFieldElement.scalb.

Multiply the instance by a power of 2.

public SparseGradient
signum()

Implements org.apache.commons.math3.RealFieldElement.signum.

Compute the signum of the instance.

public SparseGradient
public SparseGradient
sinh()

Implements org.apache.commons.math3.RealFieldElement.sinh.

Hyperbolic sine operation.

public SparseGradient
public SparseGradient
subtract(final SparseGradient
element to subtract
a
)

Implements org.apache.commons.math3.FieldElement.subtract.

Compute this - a.

public SparseGradient
subtract(double
right hand side parameter of the operator
c
)

Implements org.apache.commons.math3.RealFieldElement.subtract.

'-' operator.

public SparseGradient
tan()

Implements org.apache.commons.math3.RealFieldElement.tan.

Tangent operation.

public SparseGradient
tanh()

Implements org.apache.commons.math3.RealFieldElement.tanh.

Hyperbolic tangent operation.

public double

Returns:

value of the Taylor expansion at x + Δx, y + Δy, ...
taylor
(final double...
parameters offsets (Δx, Δy, ...)
delta
)

Evaluate Taylor expansion of a sparse gradient.

public SparseGradient

Returns:

instance converted into degrees
toDegrees
()

Convert radians to degrees, with error of less than 0.5 ULP

public SparseGradient

Returns:

instance converted into radians
toRadians
()

Convert degrees to radians, with error of less than 0.5 ULP

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait