Accelerating the pace of engineering and science

Documentation Center

• Trial Software

linalg::vectorOf

Type specifier for vectors

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

```linalg::vectorOf(R)
linalg::vectorOf(R, n)
```

Description

linalg::vectorOf(R) is a type specifier representing all objects of a domain of category Cat::Matrix with component ring R and number of rows or number of columns equal to one.

linalg::vectorOf(R,n) is a type specifier representing all objects of a domain of category Cat::Matrix with component ring R and number of rows equal to n and number of columns equal to one, or vice versa.

linalg::vectorOf(Type::AnyType,n) is a type specifier representing all objects of a domain of category Cat::Matrix with an arbitrary component ring R and number of rows equal to n and number of columns equal to one, or vice versa.

Examples

Example 1

linalg::vectorOf can be used together with testtype to check whether a MuPAD® object is a vector:

```MatZ := Dom::Matrix(Dom::Integer):
v := MatZ([1, 0, -1])```

The following yields FALSE because v is 3-dimensional vector:

`testtype(v, linalg::vectorOf(Dom::Integer, 4))`

The following yields FALSE because v is defined over the integers:

`testtype(v, linalg::vectorOf(Dom::Rational))`

Of course, v can be converted into a vector over the rationals, as shown by the following call:

`bool(coerce(v, Dom::Matrix(Dom::Rational)) <> FAIL)`

This shows that testtype in conjunction with linalg::vectorOf(R) does not check whether an object can be converted into a vector over the specified component ring R. It checks only if the object is a vector whose component ring is R.

The following test returns TRUE because v is a 3-dimensional vector:

`testtype(v, linalg::vectorOf(Type::AnyType, 3))`

Example 2

linalg::vectorOf can also be used for checking parameters of procedures. The following procedure computes the orthogonal complement of a 2-dimensional vector:

```orth := proc(v:linalg::vectorOf(Type::AnyType, 2))
begin
[v[1], v[2]] := [-v[2],v[1]];
return(v)
end:

u := matrix([[1, 2]]); u_ := orth(u)```

Calling the procedure orth with an invalid parameter leads to an error message:

`orth([1, 2])`
```Error: The type of argument number 1 must be 'slot(Type, vectorOf)(Type::AnyType, 2)'. The object '[1, 2]' is incorrect.
Evaluating: orth
```

Parameters

 R The component ring: a library domain n A positive integer

Return Values

Type expression of the domain type Type.