﻿ RealVector – Algosim documentation
Algosim documentation: RealVector

# RealVector

Converts an object to a real vector.

## Syntax

• `RealVector(X)`

• `X` is any object

## Description

If `X` is any object, then `RealVector(X)` returns `X` as a real vector, if possible.

Specifically,

• If `X` is a real number, not of datatype complex number, then `RealVector(X)` returns the one-dimensional vector with single component `X`. To force a possibly complex number with zero imaginary part into a one-dimensional real vector, you must write `RealVector(RealNumber(X))`.

• If `X` is of type complex number (even if its imaginary part is zero), then `RealVector(X)` returns the two-dimensional vector `❨Re(X), Im(X)❩`.

• If `X` is a real vector or a complex vector with zero imaginary part, then `RealVector(X)` returns `X` as a real vector.

• If `X` is a real matrix or a complex matrix with zero imaginary part, then `RealVector(X)` returns the real vector containing the entries of `X` in row-major order.

• If `X` is a list of numbers with zero imaginary parts, then `RealVector(X)` returns the real vector containing these numbers. If the list contains any non-numbers, they are ignored.

• If `X` is a set of numbers with zero imaginary parts, then `RealVector(X)` returns a real vector containing these numbers in undefined order. If the set contains any non-numbers, they are ignored.

• If `X` is a structure containing numbers with zero imaginary parts, then `RealVector(X)` returns the real vector containing these numbers. Any non-numbers in `X` are ignored.

• If `X` is a string, it is split on comma, semicolon, tab, and linebreaks, in an attempt to parse it as a real vector.

## Examples

`RealVector(IdentityMatrix(3))`
`(1, 0, 0, 0, 1, 0, 0, 0, 1)`
`RealVector(e^(π⋅i/3))`
``` ⎛     0.5      ⎞
e⎝0.866025403784⎠
```
`RealVector("1, 0, 0")`
``` ⎛1⎞
e⎜0⎟
⎝0⎠
```
`RealVector(date())`
``` ⎛2020⎞
e⎜ 9  ⎟
⎝ 5  ⎠
```