Click or drag to resize
sqx

SQXMatrixFromQuery Method

Procedure MatrixFromQuery [nvarchar](max) @Query, [bit] @Population, [Matrix] @A OUTPUT

Namespace:  sqx
Assembly:  SQX (in SQX.dll) Version: 1.0.2.6 (1.0.2.6)
Syntax
C#
public static int MatrixFromQuery(
	SqlChars Query,
	SqlBoolean SnapShot,
	out Matrix A
)

Parameters

Query
Type: System.Data.SqlTypesSqlChars
[nvarchar](max)
SnapShot
Type: System.Data.SqlTypesSqlBoolean
[bit] 0 Read Commited | 1 SnapShot
A
Type: sqxMatrix
[Matrix] OUTPUT

Return Value

Type: Int32
[int] 0 success | -1 failure
Remarks
Matrix do not preserve the original data type. All data will be converted to float.

NOTE: Query must return a dataset with only the matrix columns with numeric data type.

NOTE: Use ORDER BY clause.
Examples
SQL
declare @Query nvarchar(max) = N'
;WITH sample_data AS (SELECT [ID],[1],[2],[3],[4],[5] FROM (VALUES
((0),(5.1),(3.5),(1.4),(0.2),(0)),
((1),(4.9),(3.1),(1.5),(0.1),(0)),
((2),(5.1),(3.8),(1.5),(0.3),(0)),
((3),(7),(3.2),(4.7),(1.4),(1)),
((4),(5),(2),(3.5),(1),(1)),
((5),(5.9),(3.2),(4.8),(1.8),(1)),
((6),(6.3),(3.3),(6),(2.5),(2)),
((7),(6.5),(3.2),(5.1),(2),(2)),
((8),(6.9),(3.2),(5.7),(2.3),(2))
) AS T([ID],[1],[2],[3],[4],[5]))
SELECT [1],[2],[3],[4] FROM sample_data ORDER BY [ID]
'
declare @A sqx.Matrix
exec sqx.MatrixFromQuery @Query = @Query, @SnapShot = 0, @A = @A OUTPUT
print @A.ToString()
/*
5.1,3.5,1.4,0.2;
4.9,3.1,1.5,0.1;
5.1,3.8,1.5,0.3;
7,3.2,4.7,1.4;
5,2,3.5,1;
5.9,3.2,4.8,1.8;
6.3,3.3,6,2.5;
6.5,3.2,5.1,2;
6.9,3.2,5.7,2.3*/
See Also