Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

linalg::vectorOf

Type specifier for vectors

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

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 object '[1, 2]' is incorrect. The type of argument number 1 must be 'slot(Type, vectorOf)(Type::AnyType, 2)'.
  Evaluating: orth

Parameters

R

The component ring: a library domain

n

A positive integer

Return Values

Type expression of the domain type Type.

See Also

MuPAD Functions

Was this topic helpful?