Login     Register

        Contact Us     Search

XLeratorDB/math Documentation

SQL Server matrix rank


Updated: 06 April 2016

Use MRANK to calculate the rank of a matrix. The rank of the matrix is calculated from its singular value decomposition where the rank is the number of elements in in the diagonal matrix which are greater than the tolerance. The tolerance is calculated as the W0 * MAX(m, n) * eps where m is the number of rows in the input matrix, n is the number of columns in the input matrix and eps is 2-53.
  <@MatrixQuery, nvarchar(max),>
 ,<@IS3N, bit,>)
the SELECT statement, as text, used to return the input matrix for this function. The SELECT statement specifies the column names from the table or view or can be used to enter the matrix values directly. Data returned from the @MatrixQuery select must be of the type float or of a type that implicitly converts to float.
a bit value identifying the form for the resultant table returned by @MatrixQuery. Enter 'True' for a resultant table in 3rd normal form. Enter 'False' for a de-normalized table in 'spreadsheet' form.
Return Type
·         If @MatrixQuery does not return a square or a rectangular matrix an error will be generated.
·         Available in XLeratorDB / math 2008 only
Example #1
In the example we calculate the rank of a matrix in 'spreadsheet' format; i.e. in row/column format.
       SELECT *
       ,0) as [Matrix Rank]
This produces the following result.

Example #2
Using the same matrix content as Example #1 but with the data in 3rd normal form.
   'SELECT *
   ,1) as [Matrix Rank]
This produces the following result.

Example #3
With the matrix in CSV format, with the columns separated by commas and the rows separated by semi-colons.
SELECT wct.MRANK('1,1,1,1;1,2,4,8;1,3,9,27;1,4,16,64;1,5,25,125', 0) as [Matrix Rank]
This produces the following result.


See Also


Copyright 2008-2023 Westclintech LLC         Privacy Policy        Terms of Service