Login     Register

        Contact Us     Search

XLeratorDB/math Documentation

SQL Server m-by-n matrix of zeroes


ZERO

Updated: 31 January 2012


Use the scalar function ZERO to generate an m-by-n matrix of zeroes.
SELECT [wctMath].[wct].[ZERO](
  <@m, int,>
 ,<@n, int,>)
Arguments
@m
The number of rows in the zeroes matrix.
@n
The number of columns in the zeroes 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 ones matrix.
SELECT wct.ZERO(5,5) as ZEROES
This produces the following result.
ZEROES
-------------------------------------------------
0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0
We can use the table-valued function MATRIX to produce the output in third-normal form.
SELECT *
FROM wct.MATRIX((wct.ZERO(5,5)))
This produces the following result.
     RowNum      ColNum              ItemValue
----------- ----------- ----------------------
          0           0                      0
          0           1                      0
          0           2                      0
          0           3                      0
          0           4                      0
          1           0                      0
          1           1                      0
          1           2                      0
          1           3                      0
          1           4                      0
          2           0                      0
          2           1                      0
          2           2                      0
          2           3                      0
          2           4                      0
          3           0                      0
          3           1                      0
          3           2                      0
          3           3                      0
          3           4                      0
          4           0                      0
          4           1                      0
          4           2                      0
          4           3                      0
          4           4                      0
 


Copyright 2008-2017 Westclintech LLC         Privacy Policy        Terms of Service