UnitVector
UnitVector[k]
gives the two-dimensional unit vector in the k direction.
UnitVector[n,k]
gives the n-dimensional unit vector in the k direction.
Details and Options
- UnitVector[n,k] is a list of length n with a 1 in position k and 0s elsewhere.
- UnitVector by default creates a vector containing exact integers.
- The option WorkingPrecision can be used to specify the precision of vector components.
Examples
open allclose allBasic Examples (2)
Scope (2)
Applications (3)
Properties & Relations (1)
Possible Issues (1)
For very large dimensions n, the vector given by UnitVector may use a lot of memory:
An alternative is to use a SparseArray to represent the same thing:
Text
Wolfram Research (2007), UnitVector, Wolfram Language function, https://reference.wolfram.com/language/ref/UnitVector.html (updated 2008).
CMS
Wolfram Language. 2007. "UnitVector." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2008. https://reference.wolfram.com/language/ref/UnitVector.html.
APA
Wolfram Language. (2007). UnitVector. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UnitVector.html