scuq.cucomponents¶
- scuq.cucomponents.complex_to_matrix(value)[source]¶
This function transforms a complex value into a 2x2 NumPy array.
- Parameters:
value – The complex value.
- Returns:
A 2x2
numpy.ndarraycontaining the value.
- class scuq.cucomponents.CUncertainComponent[source]¶
Bases:
objectThis is the abstract super class of all complex valued uncertain components. Despite defining the interface for complex valued uncertain components, it also provides a set of factory methods that act as an interface for
numpy.- depends_on()[source]¶
This abstact method should return the set of CUncertainInput instances, on which this instance depends on.
- Returns:
A list of CUncertainInputs this instance depends on.
- get_value()[source]¶
This abstract method should return the complex value of this component.
- Returns:
The value of this component.
- get_uncertainty(x)[source]¶
This abstact method should return the partial derivate of this component with respect to the input
x.- Parameters:
x – An uncertain input.
- Returns:
The uncertainty of this component with respect to the input.
- get_a_value()[source]¶
This method returns the value of this component as a 2x2 array.
- Returns:
The complex value of this component as a
numpy.ndarray.
- exp()[source]¶
Get the exponential of this instance. Let this instance be x then this method returns e^x.
- Returns:
The exponential value of this instance.
- log()[source]¶
Get the natural logarithm of this instance. Let this instance be x then this method returns ln(x).
- Returns:
The natural logarithm of this instance.
- log10()[source]¶
Get the decadic logarithm of this instance. Let this instance be x then this method returns log_{10}(x).
- Returns:
The decadic logarithm of this instance.
- log2()[source]¶
Get the binary logarithm of this instance. Let this instance be x then this method returns log_{2}(x).
- Returns:
The binary logarithm of this instance.
- sqrt()[source]¶
Get the square-root of this instance. Let this instance be x then this method returns sqrt{x}.
- Returns:
The square-root of this instance.
- square()[source]¶
Get the square of this instance. Let this instance be x then this method returns x cdot x.
- Returns:
The square of this instance.
- sin()[source]¶
Get the sine of this instance. Let this instance be x then this method returns sin(x).
- Returns:
The sine of this instance.
- cos()[source]¶
Get the cosine of this instance. Let this instance be x then this method returns cos(x).
- Returns:
The cosine of this instance.
- tan()[source]¶
Get the tangent of this instance. Let this instance be x then this method returns tan(x).
- Returns:
The tangent of this instance.
- arcsin()[source]¶
Get the inverse sine of this instance. Let this instance be x then this method returns sin^{-1}(x).
- Returns:
The inverse sine of this instance.
- arccos()[source]¶
Get the inverse cosine of this instance. Let this instance be x then this method returns cos^{-1}(x).
- Returns:
The inverse cosine of this instance.
- arctan()[source]¶
Get the inverse tangent of this instance. Let this instance be x then this method returns tan^{-1}(x).
- Returns:
The inverse tangent of this instance.
- arctan2(y)[source]¶
Get the two-argument inverse tangent of this instance. Let this instance be x then this method returns tan^{-1}(x).
- Parameters:
y – Another component of uncertainty.
- Returns:
The two-argument inverse tangent of this instance.
- sinh()[source]¶
Get the hyperbolic sine of this instance. Let this instance be x then this method returns sinh(x).
- Returns:
The hyperbolic sine of this instance.
- cosh()[source]¶
Get the hyperbolic cosine of this instance. Let this instance be x then this method returns cosh(x).
- Returns:
The hyperbolic cosine of this instance.
- tanh()[source]¶
Get the hyperbolic tangent of this instance. Let this instance be x then this method returns tanh(x).
- Returns:
The hyperbolic cosine of this instance.
- arcsinh()[source]¶
Get the inverse hyperbolic sine of this instance. Let this instance be x then this method returns sinh^{-1}(x).
- Returns:
The inverse hyperbolic sine of this instance.
- arccosh()[source]¶
Get the inverse hyperbolic cosine of this instance. Let this instance be x then this method returns cosh^{-1}(x).
- Returns:
The inverse hyperbolic cosine of this instance.
- arctanh()[source]¶
Get the inverse hyperbolic tangent of this instance. Let this instance be x then this method returns tanh^{-1}(x).
- Returns:
The inverse hyperbolic tangent of this instance.
- hypot(y)[source]¶
Calculate the hypothenusis of this and another complex-valued argument.
- Parameters:
y – another component of uncertainty.
- Returns:
sqrt{x^2 + y^2}
- __abs__()[source]¶
Return the absolute value of this instance. Let this instance be mathbf{z} = x + j y then this method returns
- Returns:
The absolute value of this instance.
- fabs()[source]¶
Return the absolute value of this instance. Let this instance be mathbf{z} = x + j y then this method returns
- Returns:
The absolute value of this instance.
- __invert__()[source]¶
Get the inverse of this instance. Let this instance be x then this method returns x^{-1}.
- Returns:
The inverse of this instance.
- conjugate()[source]¶
Get the conjuagte complex value of this instance.
- Returns:
the conjuagte complex value of this instance.
- __add__(y)[source]¶
Add another instance to this instance.
- Parameters:
y – Another uncertain value.
- Returns:
The sum of this instance and the other instance.
- __sub__(y)[source]¶
Subtract another instance from this instance.
- Parameters:
y – Another uncertain value.
- Returns:
The difference of this instance and the other instance.
- __mul__(y)[source]¶
Multiply another instance with this instance.
- Parameters:
y – Another uncertain value.
- Returns:
The product of this instance and the other instance.
- __truediv__(y)[source]¶
Divide this instance by another instance.
- Parameters:
y – Another uncertain value.
- Returns:
The result of the respective operation.
- __pow__(y)[source]¶
Raise this instance to the power of the argument.
- Parameters:
y – Another uncertain value.
- Returns:
The result of the respective operation.
- __radd__(y)[source]¶
Add another instance to this instance.
- Parameters:
y – Another uncertain value.
- Returns:
The sum of this instance and the other instance.
- __rsub__(y)[source]¶
Subtract another instance from this instance.
- Parameters:
y – Another uncertain value.
- Returns:
The difference of this instance and the other instance.
- __rmul__(y)[source]¶
Multiply another instance with this instance.
- Parameters:
y – Another uncertain value.
- Returns:
The product of this instance and the other instance.
- __rtruediv__(y)[source]¶
Divide this instance by another instance.
- Parameters:
y – Another uncertain value.
- Returns:
The result of the respective operation.
- __rpow__(y)[source]¶
Raise this instance to the power of the argument.
- Parameters:
y – Another uncertain value.
- Returns:
The result of the respective operation.
- static value_of(value)[source]¶
This factory method converts the argument to a complex uncertain value.
- Parameters:
value – A numeric value.
- Returns:
An instance of CUncertainComponent.
- set_context(c)[source]¶
This assigns a context to the component. This context is only needed for evaluating __str__
- Parameters:
c – An instance of Context
- get_context()[source]¶
This returns the assigned context of the component. This context is only needed for evaluating __str__
- Returns:
c The Context of the component or
None.
- class scuq.cucomponents.CUncertainInput(value, u_real, u_imag, dof='inf')[source]¶
Bases:
CUncertainComponentThis class models a complex-valued input of a function.
- __init__(value, u_real, u_imag, dof='inf')[source]¶
The default constructor.
- Parameters:
value – The value of this instance.
u_real – The uncertainty of the real part.
u_imag – The uncertainty of the imaginary part.
dof – The degrees of freedom of the input.
uncertain. Instead encapsulate an uncertain value inside a quantity.
- get_uncertainty(x)[source]¶
If
x == selfget the uncertainty of the current node, otherwise return a 2x2 array of zeros.- Parameters:
x – Another instance of CUncertainInput
- Returns:
The uncertainty of this instance with respect to the argument.
- get_dof()[source]¶
Get the degrees of freedom assigned to this input.
- Returns:
The degrees of freedom assigned to this input.
- class scuq.cucomponents.CUnaryOperation(sibling)[source]¶
Bases:
CUncertainComponentThis abstract class models an unary operation.
- class scuq.cucomponents.CBinaryOperation(left, right)[source]¶
Bases:
CUncertainComponentThis abstract class models a binary operation.
- class scuq.cucomponents.Exp(sibling)[source]¶
Bases:
CUnaryOperationThis class models the exponential function e^x. x denotes the sibling of this instance.
- class scuq.cucomponents.Log(sibling, base=2.718281828459045)[source]¶
Bases:
CUnaryOperationThis class models logarithms having a real base. However, the base cannot be uncertain.
- class scuq.cucomponents.Sqrt(sibling)[source]¶
Bases:
CUnaryOperationThis class models taking the square root of an uncertain component.
- class scuq.cucomponents.Sin(sibling)[source]¶
Bases:
CUnaryOperationThis class models the sine function.
- class scuq.cucomponents.Cos(sibling)[source]¶
Bases:
CUnaryOperationThis class models the cosine function.
- class scuq.cucomponents.Tan(sibling)[source]¶
Bases:
CUnaryOperationThis class models the tangent function.
- class scuq.cucomponents.ArcSin(sibling)[source]¶
Bases:
CUnaryOperationThis class models the inverse sine function.
- class scuq.cucomponents.ArcCos(sibling)[source]¶
Bases:
CUnaryOperationThis class models the inverse cosine function.
- class scuq.cucomponents.ArcTan(sibling)[source]¶
Bases:
CUnaryOperationThis class models the inverse tangent function.
- class scuq.cucomponents.Sinh(sibling)[source]¶
Bases:
CUnaryOperationThis class models the hyperbolic sine function.
- class scuq.cucomponents.Cosh(sibling)[source]¶
Bases:
CUnaryOperationThis class models the hyperbolic cosine function.
- class scuq.cucomponents.Tanh(sibling)[source]¶
Bases:
CUnaryOperationThis class models the hyperbolic tangent function.
- class scuq.cucomponents.ArcSinh(sibling)[source]¶
Bases:
CUnaryOperationThis class models the inverse hyperbolic sine function.
- class scuq.cucomponents.ArcCosh(sibling)[source]¶
Bases:
CUnaryOperationThis class models the inverse hyperbolic cosine function.
- class scuq.cucomponents.ArcTanh(sibling)[source]¶
Bases:
CUnaryOperationThis class models the inverse hyperbolic tangent function.
- class scuq.cucomponents.Abs(sibling)[source]¶
Bases:
CUnaryOperationThis class models taking the absolute value of a complex function.
- class scuq.cucomponents.Conjugate(sibling)[source]¶
Bases:
CUnaryOperationThis class models taking the negative of a complex value.
- class scuq.cucomponents.Neg(sibling)[source]¶
Bases:
CUnaryOperationThis class models taking the negative of a complex value.
- class scuq.cucomponents.Inv(sibling)[source]¶
Bases:
CUnaryOperationThis class models inverting complex values. Let an instance of this class model the complex value x then this class models frac{1}{x}.
- class scuq.cucomponents.Add(left, right)[source]¶
Bases:
CBinaryOperationThis class models adding two complex values.
- class scuq.cucomponents.Sub(left, right)[source]¶
Bases:
CBinaryOperationThis class models taking the difference of two complex values.
- class scuq.cucomponents.Mul(left, right)[source]¶
Bases:
CBinaryOperationThis class models multiplying two complex values.
- class scuq.cucomponents.Div(left, right)[source]¶
Bases:
CBinaryOperationThis class models dividing two complex values.
- class scuq.cucomponents.Pow(left, right)[source]¶
Bases:
CBinaryOperationThis class models complex powers.
- class scuq.cucomponents.ArcTan2(left, right)[source]¶
Bases:
CBinaryOperationThis class models two-argument inverse tangent.
- class scuq.cucomponents.Context[source]¶
Bases:
objectThis class provides a context for complex-valued uncertainty evaluations. It manages the correlation coefficients and is able to evaluate the effective degrees of freedom.
- gaussian(val, u_r, u_i, dof='inf', matrix=None)[source]¶
This is a factory method for generating uncertain inputs that have a Gaussian distribution (i.e. bivariate Normal Distribution).
- Parameters:
val – The complex value of the input.
u_r – The uncertainty of the real part.
u_i – The uncertainty of the imaginary part.
dof – The degrees of freedom of the variable.
matrix – Optional 2x2 array-like correlation coefficients.
- constant(val)[source]¶
This is a factory method for generating constans for uncertainty evaluations.
- set_correlation(c1, c2, matrix)[source]¶
This method sets the correlation coefficients of two input arguments.
- Parameters:
c1 – The first CUncertainInput
c2 – The second CUncertainInput
matrix – 2x2 array-like correlation coefficients.
- get_correlation(c1, c2)[source]¶
Get the correlation of two input arguments.
- Parameters:
c1 – The first CUncertainInput
c2 – The second CUncertainInput
- Returns:
The correlation coefficients as a 2x2
numpy.ndarray.