EYE
Updated: 31 January 2012
Use the scalar function EYE to generate an m-by-n identity matrix.
Syntax
SELECT [wctMath].[wct].[EYE](
<@m, int,>
,<@n, int,>)
GO
Arguments
@m
The number of rows in the identity matrix.
@n
The number of columns in the identity matrix.
Return Types
[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.
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