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, thenRealVector(X)
returns the one-dimensional vector with single componentX
. To force a possibly complex number with zero imaginary part into a one-dimensional real vector, you must writeRealVector(RealNumber(X))
. -
If
X
is of type complex number (even if its imaginary part is zero), thenRealVector(X)
returns the two-dimensional vector❨Re(X), Im(X)❩
. -
If
X
is a real vector or a complex vector with zero imaginary part, thenRealVector(X)
returnsX
as a real vector. -
If
X
is a real matrix or a complex matrix with zero imaginary part, thenRealVector(X)
returns the real vector containing the entries ofX
in row-major order. -
If
X
is a list of numbers with zero imaginary parts, thenRealVector(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, thenRealVector(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, thenRealVector(X)
returns the real vector containing these numbers. Any non-numbers inX
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 ⎠
See also
-
Type conversion functions (list)