﻿ vector – Algosim documentation
Algosim documentation: vector

# 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 size `m`×`n`, the `m⋅n`-dimensional vector obtained by concatenating the rows of `A` is returned.

• If `X` is a list of numbers and possibly other objects, the vector containing the numbers in `X` (in the same order as in `X`) is returned.

• If `X` is a set, a vector containing all numbers in `X` is returned. The order of the components is undefined.

• If `X` is a structure, the vector containing the number-typed values in `X` (in the same order as in `X`) 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 as `vector(a, b, ...)`, returns the vector containing the numbers `a, b, ...` (in that order).

• `❨❨a11, a12, ..., a1m❩, ❨a21, a22, ..., a2m❩, ..., ❨an1, an2, ..., anm❩❩` creates the `m`×`n` matrix with components `aij`.

More generally,

• `❨v1, v2, ..., vm❩`, where each `vi` is a vector of dimension `n` creates the `m`×`n` matrix having the `vi`’s as its rows.