Login     Register

        Contact Us     Search

XLeratorDB/math Documentation

SQL Server MDETERM function


MDETERMN
 
Updated: 17 August 2010

Use MDETERMN to calculate the determinant of an N x N matrix, where N specifies the number of columns in the matrix. For matrices in de-normalized form, use the MDETERM function.
Syntax
SELECT [wctMath].[wct].[MDETERMN] (
  <@Matrix_TableName, nvarchar(4000),>
 ,<@Key1Columnname, nvarchar(4000),>
 ,<@Key2ColumnName, nvarchar(4000),>
 ,<@DataColumnName, nvarchar(4000),>
 ,<@GroupedColumnName, nvarchar(4000),>
 ,<@GroupedColumnValue, sql_variant,>)
Arguments
@Matrix_TableName
the name, as text, of the table or view that contains the matrix values to be used in the MDETERMN calculation.
@Key1Columnname
the name, as text, of the column in the table or view specified by @Matrix_TableName that contains the ‘row number’ value used in storing the normalized matrix
@Key2ColumnName
the name, as text, of the column in the table or view specified by @Matrix_TableName that contains the ‘column number’ value used in storing the normalized matrix
@DataColumnName
The name, as text, of the column in the table or view specified by @Matrix_TableName that contains the matrix values to be used in the determinant. Data returned from the @DataColumnName must be of the type float or of a type that implicitly converts to float.
@GroupedColumnName
the name, as text, of the column in the table or view specified by @TableName which will be used for grouping the results.
@GroupedColumnValue
the column value to do the grouping on.
Return Types
float
Remarks
·         If the number of rows in the matrix is not equal to the number of columns, MDETERMN will return an error.
·         No GROUP BY is required for this function even though it produces aggregated results.
·         Use the MDETERMN_q function for more complex queries.
·         Use MDETERM for a de-normalized table.
·         The function returns an error if the matrix contains NULL.
Examples
CREATE TABLE #m(
      rowno int,
      colno int,
      val         float
)
 
INSERT INTO #m VALUES (0,0,1)
INSERT INTO #m VALUES (0,1,2)
INSERT INTO #m VALUES (0,2,3)
INSERT INTO #m VALUES (0,3,10)
INSERT INTO #m VALUES (1,0,6)
INSERT INTO #m VALUES (1,1,4)
INSERT INTO #m VALUES (1,2,4)
INSERT INTO #m VALUES (1,3,11)
INSERT INTO #m VALUES (2,0,7)
INSERT INTO #m VALUES (2,1,8)
INSERT INTO #m VALUES (2,2,9)
INSERT INTO #m VALUES (2,3,12)
INSERT INTO #m VALUES (3,0,16)
INSERT INTO #m VALUES (3,1,15)
INSERT INTO #m VALUES (3,2,14)
INSERT INTO #m VALUES (3,3,13)
 
SELECT wct.MDETERMN(
       '#m'
      ,'rowno'
      ,'colno'
      ,'val'
      ,''
      ,NULL
      ) as [|A|]
 

This produces the following result

                   |A|
----------------------
                   208
 
(1 row(s) affected)

See Also

·         Blog Post - SQL Server Matrix Functions


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service