vector
Converts an object to a vector and implements vector and matrix brackets.
Syntax
-
vector(X)
-
X
is any object other than a vector
-
-
vector(a[, [b, ...]])
-
a, b, ...
are numbers
-
-
vector(a[, [b, ...]])
-
a, b, ...
are vectors
-
Description
If X
is any object other than a vector, then vector(X)
returns X
converted into a vector:
-
If
X
is a number, the single-element vector(X)
is returned. -
If
X
is a matrix of sizem
×n
, them⋅n
-dimensional vector obtained by concatenating the rows ofA
is returned. -
If
X
is a list of numbers and possibly other objects, the vector containing the numbers inX
(in the same order as inX
) is returned. -
If
X
is a set, a vector containing all numbers inX
is returned. The order of the components is undefined. -
If
X
is a structure, the vector containing the number-typed values inX
(in the same order as inX
) is returned.
The remaining overloads are mainly supposed to be be accessed implicitly by the vector brackets used to create vectors and matrices:
-
❨a, b, ...❩
, implemented asvector(a, b, ...)
, returns the vector containing the numbersa, b, ...
(in that order). -
❨❨a11, a12, ..., a1m❩, ❨a21, a22, ..., a2m❩, ..., ❨an1, an2, ..., anm❩❩
creates them
×n
matrix with componentsaij
.
More generally,
-
❨v1, v2, ..., vm❩
, where eachvi
is a vector of dimensionn
creates them
×n
matrix having thevi
’s as its rows.
See also
-
Creating a matrix (conceptual)
-
Type conversion functions (list)