IMPRODUCT_q
Updated 2024-03-13 19:35:43.150000
Syntax
SELECT [westclintech].[wct].[IMPRODUCT_q] (
<@IMValues_RangeQuery, nvarchar(4000),>)
Description
Use the scalar function IMPRODUCT_q 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
@IMValues_RangeQuery
the select statement, as text, used to determine the complex numbers to be used in the IMPRODUCT_q calculation.
Return Type
nvarchar(4000)
Remarks
Use COMPLEX to convert real and imaginary coefficients into a complex number.
For more simpler queries consider using the IMPRODUCT 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_q('select inumber from #p1');
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"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":"65"}]}