﻿ ComplexMatrix – Algosim documentation
Algosim documentation: ComplexMatrix

# ComplexMatrix

Converts an object to a complex matrix.

## Syntax

• `ComplexMatrix(X)`

• `X` is any object

## Description

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

Specifically,

• If `X` is a number, then `ComplexMatrix(X)` returns the 1×1 complex matrix containing `X` as its only entry.

• If `X` is a vector, then `ComplexMatrix(X)` returns `X` as a single-column complex matrix.

• If `X` is a matrix, then `ComplexMatrix(X)` returns `X` as a complex matrix.

• If `X` is a two-dimensional list of numbers, then `ComplexMatrix(X)` returns `X` as a complex matrix.

• If `X` is a string, then `ComplexMatrix(X)` attempts to parse it as a complex matrix by splitting it on newlines (rows) and commas, semicolons, and tabs (columns).

## Examples

`ComplexMatrix(❨4, i, 2❩)`
```⎛4⎞
⎜i⎟
⎝2⎠
```
`ComplexMatrix("1 + i, 2 − 2⋅i, 3 + 2⋅i"~¶~"5, 6 − 3⋅i, i")`
```⎛  1 + i  2 − 2⋅i  3 + 2⋅i⎞
⎝      5  6 − 3⋅i        i⎠
```
`ComplexMatrix(compute(√(a⋅b), a, −2, 2, b, −2, 2))`
```⎛              2    1.41421356237                0  1.41421356237⋅i              2⋅i⎞
⎜  1.41421356237                1                0                i  1.41421356237⋅i⎟
⎜              0                0                0                0                0⎟
⎜1.41421356237⋅i                i                0                1    1.41421356237⎟
⎝            2⋅i  1.41421356237⋅i                0    1.41421356237                2⎠
```