Logo

MDETERM

Updated 2023-10-16 20:25:37.437000

Syntax

SELECT [westclintech].[wct].[MDETERM] (
  <@Matrix_TableName, nvarchar(4000),>
 ,<@ColumnNames, nvarchar(4000),>
 ,<@GroupedColumnName, nvarchar(4000),>
 ,<@GroupedColumnValue, sql_variant,>)

Description

Use MDETERM to calculate the determinant of an N x N matrix, where N specifies the number of columns in the matrix. For matrices in normalized form, use the MDETERMN function.

Arguments

@ColumnNames

the name, as text, of the columns in the table or view specified by @MatrixTableName that contains the matrix values to be used in the MDETERM calculation. Data returned from the @ColumnNames 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 @Matrix_TableName which will be used for grouping the results.

@Matrix_TableName

the name, as text, of the table or view that contains the matrix values to be used in the MDETERM calculation.

@GroupedColumnValue

the column value to do the grouping on.

Return Type

float

Remarks

If the number of rows in the matrix is not equal to the number of columns, MDETERM will return an error.

No GROUP BY is required for this function even though it produces aggregated results.

Use the MDETERM_q function for more complex queries.

Use MDETERMN for a table in normal form.

The function returns an error if the matrix contains NULL.

Examples

CREATE TABLE #m

(

    Col1 float,

    Col2 float,

    Col3 float,

    Col4 float

);

INSERT INTO #m

SELECT 1,

       2,

       3,

       10

UNION ALL

SELECT 6,

       4,

       4,

       11

UNION ALL

SELECT 7,

       8,

       9,

       12

UNION ALL

SELECT 16,

       15,

       14,

       13;

SELECT wct.MDETERM('#m', 'Col1, Col2, Col3, Col4', '', NULL) as [|A|];

This produces the following result.

{"columns":[{"field":"|A|","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"|A|":"208"}]}