SUMX2MY2
Updated 2023-10-17 15:12:40.083000
Syntax
SELECT [westclintech].[wct].[SUMX2MY2] (
<@Matrix1, nvarchar(max),>
,<@Matrix2, nvarchar(max),>)
Description
Use the scalar function SUMX2MY2 to calculate the sum of the difference of squares of corresponding values in two matrices.
Arguments
@Matrix1
The string representation of the lhs matrix with columns separated by commas and rows separated by semi-colons.
@Matrix2
The string representation of the rhs matrix with columns separated by commas and rows separated by semi-colons.
Return Type
float
Remarks
Matrix1 and Matrix2 must have the same number of rows and columns or NULL is returned.
Examples
Example #1
DECLARE @a as nvarchar(max)
= wct.MATRIX2STRING_q('
SELECT
POWER(n.x,m.p1),
POWER(n.x,m.p2),
POWER(n.x,m.p3),
POWER(n.x,m.p4)
FROM (VALUES (1),(2),(3),(4))n(x)
CROSS APPLY (VALUES (0,1,2,3))m(p1,p2,p3,p4)');
DECLARE @B as nvarchar(max) = wct.MUPDATE(@a, NULL, NULL, NULL, NULL, '+', wct.ONES(
4, 4), NULL, NULL, NULL, NULL);
SELECT wct.SUMX2MY2(@a, @b) as SUMX2MY2;
This produces the following result.
{"columns":[{"field":"SUMX2MY2","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"SUMX2MY2":"-304"}]}
See Also
MNORM - calculate matrix norms
SUMPRODUCT - calculate the sum of elementwise multiplication on a group of matrices
SUMX2PY2 - the sum of the sum of the squares for corresponding elements in 2 matrices