vector
Converts an object to a vector and implements vector and matrix brackets.
Syntax
-
vector(X)-
Xis 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
Xis a number, the single-element vector(X)is returned. -
If
Xis a matrix of sizem×n, them⋅n-dimensional vector obtained by concatenating the rows ofAis returned. -
If
Xis a list of numbers and possibly other objects, the vector containing the numbers inX(in the same order as inX) is returned. -
If
Xis a set, a vector containing all numbers inXis returned. The order of the components is undefined. -
If
Xis 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×nmatrix with componentsaij.
More generally,
-
❨v1, v2, ..., vm❩, where eachviis a vector of dimensionncreates them×nmatrix having thevi’s as its rows.
See also
-
Creating a matrix (conceptual)
-
Type conversion functions (list)