%mathpiper,def="BaseVector"

Function("BaseVector",{row,n})
[
    Local(i,result);
    result:=ZeroVector(n);
    result[row] := 1;
    result;
];

%/mathpiper



%mathpiper_docs,name="BaseVector",categories="User Functions;Linear Algebra"
*CMD BaseVector --- base vector
*STD
*CALL
	BaseVector(k, n)

*PARMS

{k} -- index of the base vector to construct

{n} -- dimension of the vector

*DESC

This command returns the "k"-th base vector of dimension "n". This
is a vector of length "n" with all zeros except for the "k"-th
entry, which contains a 1.

*E.G.

In> BaseVector(2,4)
Result: {0,1,0,0};

*SEE ZeroVector, Identity
%/mathpiper_docs