﻿ ComplexVector – Algosim documentation
Algosim documentation: ComplexVector

# ComplexVector

Converts an object to a complex vector.

## Syntax

• `ComplexVector(X)`

• `X` is any object

## Description

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

Specifically,

• If `X` is number, then `ComplexVector(X)` returns the one-dimensional vector with single component `X`.

• If `X` is a real or complex vector, then `ComplexVector(X)` returns `X` as a complex vector.

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

• If `X` is a list of numbers, then `ComplexVector(X)` returns the complex vector containing these numbers. If the list contains any non-numbers, they are ignored.

• If `X` is a set of numbers, then `ComplexVector(X)` returns a complex vector containing these numbers in undefined order. If the set contains any non-numbers, they are ignored.

• If `X` is a structure containing numbers, then `ComplexVector(X)` returns the complex 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 complex vector.

## Examples

`ComplexVector(IdentityMatrix(3))`
`(1, 0, 0, 0, 1, 0, 0, 0, 1)`
`ComplexVector("1, i, 0, −i, 0")`
``` ⎛1 ⎞
⎜i ⎟
e⎜0 ⎟
⎜−i⎟
⎝0 ⎠
```