## Modelica_LinearSystems2.Math.Vectors

Functions operating on vectors

### Information

#### Library content

This library provides functions operating on vectors:

Function | Description
--- | ---
isEqual(v1, v2) | Determines whether two vectors have the same size and elements
norm(v,p) | p-norm of vector v
length(v) | Length of vector v (= norm(v,2), but inlined and therefore usable in symbolic manipulations)
normalize(v) | Return normalized vector such that length = 1 and prevent zero-division for zero vector
reverse(v) | Reverse vector elements
sort(v) | Sort elements of vector in ascending or descending order

#### See also

Matrices

Extends from Modelica.Icons.Package (Icon for standard packages).

### Package Content

Name | Description
--- | ---
find | find element in vector
householderReflexion | reflect vector a on a plane with orthogonal vector u
householderReflexion_e1 | reflect vector a to the unity vector e_1={1,0,...,0}
householderReflexion_en | reflect vector a to the unity vector e_n={0, ..., 0, 1}
householderVector | Calculate a normalized householder vector to reflect vector a onto vector b
length | Return length of a vector
printVector | print vector

## Modelica_LinearSystems2.Math.Vectors.find

find element in vector

### Information

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Name | Description
--- | ---
s | Search for s
v[:] | Vector

### Outputs

Name | Description
--- | ---
result | v[result] = s (first occurrence of s); result=0, if not found

## Modelica_LinearSystems2.Math.Vectors.householderReflexion

reflect vector a on a plane with orthogonal vector u

### Information

### Inputs

Name | Description
--- | ---
a[:] |
u[size(a, 1)] | householder vector

### Outputs

Name | Description
--- | ---
ra[size(u, 1)] | reflexion of a

## Modelica_LinearSystems2.Math.Vectors.householderReflexion_e1

reflect vector a to the unity vector e_1={1,0,...,0}

### Inputs

Name | Description
--- | ---
a[:] |
u[size(a, 1)] | householder vector

### Outputs

Name | Description
--- | ---
ra[size(u, 1)] | reflexion of a

## Modelica_LinearSystems2.Math.Vectors.householderReflexion_en

reflect vector a to the unity vector e_n={0, ..., 0, 1}

### Inputs

Name | Description
--- | ---
a[:] |
u[size(a, 1)] | householder vector

### Outputs

Name | Description
--- | ---
ra[size(u, 1)] | reflexion of a

## Modelica_LinearSystems2.Math.Vectors.householderVector

Calculate a normalized householder vector to reflect vector a onto vector b

### Information

#### Syntax

>     Vectors.Utilities.householderVector(a,b);

#### Description

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

> Q = I - 2*u*u',

i.e., vector a is mapped to

> a -> Q*a=c*b

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.

> Q = inv(Q) = Q'

#### Example

> ###

> ###

> ##

> ###

> ####

> ####

> ####

> ####

> ###

> ###

> ##

> ###

> ###

>       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

>     Inputs

>     NameDescription
>     a[:]Real vector to be reflected
>     b[size(a, 1)]Real vector b vector a is mapped onto

>     Outputs

>     NameDescription
>     u[size(a, 1)]Housholder vector to map a onto b

>     Modelica_LinearSystems2.Math.Vectors.length
>     Return length of a vector
>     Information

>     Syntax

>     Vectors.length(v);

>     Description

>     The function call "Vectors.length(v)" returns the
>     Euclidean length "sqrt(v*v)" of vector v.
>     The function call is equivalent to Vectors.norm(v). The advantage of
>     length(v) over norm(v)"is that function length(..) is implemented
>     in one statement and therefore the function is usually automatically
>     inlined. Further symbolic processing is therefore possible, which is
>     not the case with function norm(..).

>     Example

>       v = {2, -4, -2, -1};
>       length(v);  // = 5

>     See also
>     Vectors.norm

>     Inputs

>     NameDescription
>     v[:]Vector

>     Outputs

>     NameDescription
>     resultLength of vector v

>     Modelica_LinearSystems2.Math.Vectors.printVector
>     print vector
>     Inputs

>     NameDescription
>     v[:]
>     significantDigitsNumber of significant digits that are shown
>     nameIndependent variable name used for printing

>     Outputs

>     NameDescription
>     s