IMPRODUCT
Updated 2024-03-13 19:34:54.087000
Syntax
SELECT [westclintech].[wct].[IMPRODUCT] (
<@IMValues_Tablename, nvarchar(4000),>
,<@ColumnName, nvarchar(4000),>
,<@GroupedColumnName, nvarchar(4000),>
,<@GroupedColumnValue, sql_variant,>)
Description
Use the scalar function IMPRODUCT to return the product of a dataset containing complex numbers in x + yi or x + yj text format using dynamic SQL. The product of 2 complex numbers is computed as:
(a+bi)(c+di)=(ac-bd)+(ad+bc)i
Arguments
@GroupedColumnName
the name, as text, of the column in the table or view specified by @IMValues_Tablename which will be used for grouping the results.
@IMValues_Tablename
the name, as text, of the table or view that contains the complex numbers to be used in the IMPRODUCT calculation.
@ColumnName
the name, as text, of the column in the table or view specified by @IMValues_Tablename that contains the complex numbers to be used in the IMPRODUCT calculation.
@GroupedColumnValue
the column value to do the grouping on.
Return Type
nvarchar(4000)
Remarks
Use COMPLEX to convert real and imaginary coefficients into a complex number.
For more complex queries consider using the IMPRODUCT_q function.
Examples
create table #p1
(
inumber varchar(50)
);
insert into #p1
values
('2+i');
insert into #p1
values
('2-i');
insert into #p1
values
('3+2i');
insert into #p1
values
('3-2i');
select wct.improduct('#p1', 'inumber', '', NULL);
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":""},{"column 1":"65"}]}
select wct.IMMULT(wct.IMMULT('2+i', '2-i'), wct.IMMULT('3+2i', '3-2i'));
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":""},{"column 1":"65"}]}