Login     Register

        Contact Us     Search

XLeratorDB/math Documentation

SQL Server Matrix Norm function


MNORM
Updated: 25 April 2017

Use the scalar function MNORM to compute a matrix norm. The norm can be the one ('O') norm, the infinity ('I') norm, the Frobenius ('F') norm, the maximum modulus ('M') among elements of a matrix, or the '2'-norm.

Syntax
SELECT [wct].[MNORM] (
   <@Matrix, nvarchar(max),>
  ,<@NormType, nvarchar(4000),>)
Arguments
Input NameDescription
@MatrixThe string representation of the matrix with columns separated by commas and rows separated by semi-colons.
@NormTypeThe matrix norm to be calculated
Return Type
float
Remarks
  • If @NormType IS NULL then @NormType = '0'
  • Set @NormType = '0' or '1' for the 1-norm, the maximum absolute column sum
  • Set @NormType = 'I' for the infinity-norm, the maximum absolute row sum
  • Set @NormType = 'M' for the maximum modulus of all the matrix elements
  • Set @NormType = 'F' for the Frobenius norm, the square root of the sum of the square of the elements
  • Set @NormType = '2' for the 2-norm, the largest singular value of @Matrix
  • Available in XLeratorDB / math 2008 only
Examples
Example #1
--Matrix dimension
DECLARE @n as int = 9
 
--Create the Hilbert Matrix
DECLARE @H as nvarchar(max) = (SELECT wct.NMATRIX2STRING(i,j,val)
FROM (
    SELECT
        i.SeriesValue - 1 as i,
        j.SeriesValue - 1 as j,
        1/(i.SeriesValue+j.SeriesValue-1) as val
    FROM
        wct.SeriesFloat(1,@n,NULL,NULL,NULL)i
    CROSS APPLY
        wct.SeriesInt(1,@n,NULL,NULL,NULL)j
    )n
)
 
--Calculate each norm
SELECT
    x.type,
    wct.MNORM(@H,x.type) as norm
FROM (VALUES ('1'),('F'),('M'),('I'),('2'))x(type)
ORDER BY
    1

This produces the following result.

See Also


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service