This package contains utility functions that are utilized by higher level vector and matrix functions. These functions are usually not useful for an end-user.
Extends from Modelica.Icons.UtilitiesPackage
(Icon for utility packages).
Name | Description |
---|---|
householderReflection | Reflect a vector a on a plane with orthogonal vector u |
householderVector | Calculate a normalized householder vector to reflect vector a onto vector b |
roots | Compute zeros of a polynomial where the highest coefficient is assumed as not to be zero |
Vectors.Utilities.householderVector(a,b);
The function call "householderVector(a, b)
" returns the normalized Householder vector
u for Householder reflection of input vector a onto vector b, i.e., Householder vector u is the normal
vector of the reflection plane. Algebraically, the reflection is performed by transformation matrix Q
i.e., vector a is mapped toQ = I - 2*u*u',
with scalar c, |c| = ||a|| / ||b||. Q*a is the reflection of a about the hyperplane orthogonal to u. Q is an orthogonal matrix, i.e.a -> Q*a=c*b
Q = inv(Q) = Q'
a = {2, -4, -2, -1}; b = {1, 0, 0, 0}; u = householderVector(a,b); // {0.837, -0.478, -0.239, -0.119} // Computation (identity(4) - 2*matrix(u)*transpose(matrix(u)))*a results in // {-5, 0, 0, 0} = -5*b
Extends from Modelica.Icons.Function
(Icon for functions).
Type | Name | Description |
---|---|---|
Real | a[:] | Real vector to be reflected |
Real | b[size(a, 1)] | Real vector b vector a is mapped onto |
Type | Name | Description |
---|---|---|
Real | u[size(a, 1)] | Householder vector to map a onto b |
Vectors.Utilities.householderReflection(a,u);
Function "householderReflection(a, u)
" performs the reflection of vector
a about a plane orthogonal to vector u (Householder vector).
Algebraically the operation is defined by
withb=Q*a
where Q is an orthogonal matrix, i.e.Q = I - 2*u*u',
Q = inv(Q) = Q'
a = {2, -4, -2, -1}; u = {0.837, -0.478, -0.239, -0.119}; householderReflection(a,u); // = {-5.0, -0.001, -0.0005, -0.0044}
Extends from Modelica.Icons.Function
(Icon for functions).
Type | Name | Description |
---|---|---|
Real | a[:] | Real vector a to be reflected |
Real | u[size(a, 1)] | householder vector |
Type | Name | Description |
---|---|---|
Real | ra[size(u, 1)] | reflexion of a |
r = Vectors.Utilities.roots(p);
This function computes the roots of a polynomial P of x
P = p[1]*x^n + p[2]*x^(n-1) + ... + p[n-1]*x + p[n+1];
with the coefficient vector p. It is assumed that the first element of p is not zero, i.e., that the polynomial is of order size(p,1)-1.
To compute the roots, the eigenvalues of the corresponding companion matrix C
|-p[2]/p[1] -p[3]/p[1] ... -p[n-2]/p[1] -p[n-1]/p[1] -p[n]/p[1] | | 1 0 0 0 0 | | 0 1 ... 0 0 0 | C = | . . ... . . . | | . . ... . . . | | 0 0 ... 0 1 0 |
are calculated. These are the roots of the polynomial.
Since the companion matrix has already Hessenberg form, the transformation to Hessenberg form has not to be performed.
Function eigenvaluesHessenberg
provides efficient eigenvalue computation for those matrices.
r = roots({1,2,3}); // r = [-1.0, 1.41421356237309; // -1.0, -1.41421356237309] // which corresponds to the roots: -1.0 +/- j*1.41421356237309
Extends from Modelica.Icons.Function
(Icon for functions).
Type | Name | Description |
---|---|---|
Real | p[:] | Vector with polynomial coefficients p[1]*x^n + p[2]*x^(n-1) + p[n]*x +p[n-1] |
Type | Name | Description |
---|---|---|
Real | roots[max(0, size(p, 1) - 1),2] | roots[:,1] and roots[:,2] are the real and imaginary parts of the roots of polynomial p |
Generated 2018-12-12 12:14:34 EST by MapleSim.