Package xal.tools.math
Class DifferentialVariable
java.lang.Object
xal.tools.math.DifferentialVariable
Represents an immutable value and its differentials relative to independent
variables and performs math operations on them in support of error
propagation.
- Author:
- t6p
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DifferentialVariable
representation of the constant onestatic final DifferentialVariable
representation of the constant zero -
Constructor Summary
ConstructorsConstructorDescriptionDifferentialVariable
(double value, int offset, double... derivatives) Primary Constructor -
Method Summary
Modifier and TypeMethodDescriptionfinal DifferentialVariable
abs()
get the absolute value of this variablefinal DifferentialVariable
acos()
get the arc cosine of this variablestatic DifferentialVariable
add
(double value, DifferentialVariable variable) perform the addition operation between a variable and a scalar valuestatic DifferentialVariable
add
(DifferentialVariable... addends) perform the addition operation between two variablesstatic DifferentialVariable
add
(DifferentialVariable variable, double value) perform the addition operation between a variable and a scalar valuefinal DifferentialVariable
asin()
get the arc sine of this variablefinal DifferentialVariable
atan()
get the arc tangent of this variablefinal DifferentialVariable
cos()
get the cosine of this variablefinal DifferentialVariable
cosh()
get the hyperbolic cosine of this variablestatic DifferentialVariable
divide
(double value, DifferentialVariable variable) divide the scalar value by the variablestatic DifferentialVariable
divide
(DifferentialVariable variable, double value) divide the variable by the scalar valuestatic DifferentialVariable
divide
(DifferentialVariable dividend, DifferentialVariable divisor) divide the dividend by the divisorfinal DifferentialVariable
exp()
get the exponential (base e) of this variabledouble
getDerivative
(int index) get the derivative for the independent variable at the specified indexstatic DifferentialVariable
getInstance
(double value, double... derivatives) Constructor with zero offsetdouble
getValue()
get the valuefinal DifferentialVariable
log()
get the natural logarithm (base e) of this variableminus
(double subtrahend) subtract the specified subtrahend from this variableminus
(DifferentialVariable subtrahend) subtract the specified subtrahend from this variablestatic DifferentialVariable
multiply
(double value, DifferentialVariable variable) perform the multiplication operation between a variable and a scalar valuestatic DifferentialVariable
multiply
(DifferentialVariable... multiplicands) multiply the variablesstatic DifferentialVariable
multiply
(DifferentialVariable variable, double value) perform the multiplication operation between a variable and a scalar valuenegate()
negate the variablestatic DifferentialVariable
newConstant
(double value) get a constant valueover
(double divisor) divide this variable by the specified divisorover
(DifferentialVariable divisor) divide this variable by the specified divisorplus
(double addend) add this variable to the specified addendplus
(DifferentialVariable addend) add this variable to the specified addendfinal DifferentialVariable
pow
(double power) raise this variable to the specified powercalculate and return the reciprocal of this variablefinal DifferentialVariable
sin()
get the sine of this variablefinal DifferentialVariable
sinh()
get the hyperbolic sine of this variablefinal DifferentialVariable
sqrt()
get the square root of this variablestatic DifferentialVariable
subtract
(double value, DifferentialVariable variable) subtract the variable from the scalar valuestatic DifferentialVariable
subtract
(DifferentialVariable variable, double subtrahend) subtract the scalar value from the variablestatic DifferentialVariable
subtract
(DifferentialVariable minuend, DifferentialVariable subtrahend) subtract the subtrahend variable from the minuend variablefinal DifferentialVariable
tan()
get the tangent of this variablefinal DifferentialVariable
tanh()
get the hyperbolic tangent of this variabletimes
(double multiplicand) multiply this variable by the specified multiplicandtimes
(DifferentialVariable multiplicand) multiply this variable by the specified multiplicanddouble
varianceWithSignalVariance
(double commonVariance) calculate the variance for this variable given a common variance for each independent variabledouble
varianceWithSignalVariances
(double... variances) calculate the variance for this variable given variances for all independent variablesdouble
varianceWithSignalVariances
(int offset, double... variances) calculate the variance for this variable given the independent variables starting at the specified offset among all independent variables
-
Field Details
-
ZERO
representation of the constant zero -
ONE
representation of the constant one
-
-
Constructor Details
-
DifferentialVariable
public DifferentialVariable(double value, int offset, double... derivatives) Primary Constructor- Parameters:
value
- the value of the variableoffset
- offset of this differential's first independent variable relative to all independent variablesderivatives
- array of derivatives beginning with this differential's first independent variable
-
-
Method Details
-
getInstance
Constructor with zero offset- Parameters:
value
- the value of the variablederivatives
- array of derivatives beginning with the first independent variable
-
newConstant
get a constant value -
getValue
public double getValue()get the value -
getDerivative
public double getDerivative(int index) get the derivative for the independent variable at the specified index -
varianceWithSignalVariance
public double varianceWithSignalVariance(double commonVariance) calculate the variance for this variable given a common variance for each independent variable -
varianceWithSignalVariances
public double varianceWithSignalVariances(double... variances) calculate the variance for this variable given variances for all independent variables -
varianceWithSignalVariances
public double varianceWithSignalVariances(int offset, double... variances) calculate the variance for this variable given the independent variables starting at the specified offset among all independent variables -
add
perform the addition operation between a variable and a scalar value -
add
perform the addition operation between a variable and a scalar value -
add
perform the addition operation between two variables -
subtract
subtract the scalar value from the variable -
subtract
subtract the variable from the scalar value -
subtract
public static DifferentialVariable subtract(DifferentialVariable minuend, DifferentialVariable subtrahend) subtract the subtrahend variable from the minuend variable -
multiply
perform the multiplication operation between a variable and a scalar value -
multiply
perform the multiplication operation between a variable and a scalar value -
multiply
multiply the variables -
divide
divide the variable by the scalar value -
divide
divide the scalar value by the variable -
divide
public static DifferentialVariable divide(DifferentialVariable dividend, DifferentialVariable divisor) divide the dividend by the divisor -
negate
negate the variable -
reciprocal
calculate and return the reciprocal of this variable -
plus
add this variable to the specified addend -
plus
add this variable to the specified addend -
minus
subtract the specified subtrahend from this variable -
minus
subtract the specified subtrahend from this variable -
times
multiply this variable by the specified multiplicand -
times
multiply this variable by the specified multiplicand -
over
divide this variable by the specified divisor -
over
divide this variable by the specified divisor -
pow
raise this variable to the specified power -
sqrt
get the square root of this variable -
abs
get the absolute value of this variable -
log
get the natural logarithm (base e) of this variable -
exp
get the exponential (base e) of this variable -
sin
get the sine of this variable -
cos
get the cosine of this variable -
tan
get the tangent of this variable -
asin
get the arc sine of this variable -
acos
get the arc cosine of this variable -
atan
get the arc tangent of this variable -
sinh
get the hyperbolic sine of this variable -
cosh
get the hyperbolic cosine of this variable -
tanh
get the hyperbolic tangent of this variable
-