EYE
Updated 2023-10-19 13:30:23.847000
Syntax
SELECT [westclintech].[wct].[EYE](
<@m, int,>
,<@n, int,>)
Description
Generate an m-by-n identity matrix.
Arguments
@m
The number of rows in the identity matrix.
@n
The number of columns in the identity matrix.
Return Type
nvarchar(max)
Remarks
@m must be greater than or equal to 1.
@n must be greater than or equal to 1.
Examples
The following statement will produce the 5-by-5 identity matrix.
SELECT wct.EYE(5, 5) as I;
This produces the following result.
{"columns":[{"field":"I"}],"rows":[{"I":"1,0,0,0,0;0,1,0,0,0;0,0,1,0,0;0,0,0,1,0;0,0,0,0,1"}]}
We can use the table-valued function MATRIX to produce the output in third-normal form.
SELECT *
FROM wct.MATRIX((wct.EYE(5, 5)));
This produces the following result.
RowNum ColNum ItemValue
----------- ----------- ----------------------
0 0 1
0 1 0
0 2 0
0 3 0
0 4 0
1 0 0
1 1 1
1 2 0
1 3 0
1 4 0
2 0 0
2 1 0
2 2 1
2 3 0
2 4 0
3 0 0
3 1 0
3 2 0
3 3 1
3 4 0
4 0 0
4 1 0
4 2 0
4 3 0
4 4 1