SPECRAD
Updated: 06 April 2016
Use SPECRAD to calculate the spectral radius of a square matrix. The spectral radius of the square matrix is the eigenvalue with the greatest absolute value.
Syntax
SELECT [wct].[MRANK](
<@MatrixQuery, nvarchar(max),>
,<@IS3N, bit,>)
Arguments
@MatrixQuery
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.
@Is3N
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
float
Remarks
· If @MatrixQuery does not return a square matrix then NULL is returned.
Examples
Example #1
In the example we calculate the spectral radius of a matrix in 'spreadsheet' format; i.e. in row/column format.
SELECT
wct.SPECRAD('
SELECT *
FROM (VALUES
(1,1,1,1,1)
,(1,2,4,8,16)
,(1,3,9,27,81)
,(1,4,16,64,256)
,(1,5,25,125,625)
)n(x1,x2,x3,x4,x5)'
,0) as [Spectral Radius]
This produces the following result.
Example #2
Using the same matrix content as Example #1 but with the data in 3rd normal form.
SELECT
wct.SPECRAD(
'SELECT *
FROM (VALUES
(0,0,1)
,(0,1,1)
,(0,2,1)
,(0,3,1)
,(0,4,1)
,(1,0,1)
,(1,1,2)
,(1,2,4)
,(1,3,8)
,(1,4,16)
,(2,0,1)
,(2,1,3)
,(2,2,9)
,(2,3,27)
,(2,4,81)
,(3,0,1)
,(3,1,4)
,(3,2,16)
,(3,3,64)
,(3,4,256)
,(4,0,1)
,(4,1,5)
,(4,2,25)
,(4,3,125)
,(4,4,625)
)n(r,c,x)'
,1) as [Spectral Radius]
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.SPECRAD('1,1,1,1,1;1,2,4,8,16;1,3,9,27,81;1,4,16,64,256;1,5,25,125,625',0) as [Spectral Radius]
This produces the following result.
See Also