Programmer Guide/Command Reference/EVAL/complex arithmetic: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 44: Line 44:
:;<code>''rc''=cset(''x'',''y'')</code>: Combine elements of ''x'' (real part or length) and ''y'' (imaginary part or phase) to a complex numbers  
:;<code>''rc''=cset(''x'',''y'')</code>: Combine elements of ''x'' (real part or length) and ''y'' (imaginary part or phase) to a complex numbers  


;complex multiplication
;multiplication (element-wise)
:{|class="einrahmen"
:{|class="einrahmen"
!argument ''xc''  
!argument ''xc''  
Line 61: Line 61:
:;<code>''rc''=cmul(''n'',''xc'')</code>: Multiply each element of ''xc'' with the real or complex number ''n''.
:;<code>''rc''=cmul(''n'',''xc'')</code>: Multiply each element of ''xc'' with the real or complex number ''n''.
:;<code>''rc''=cmul(''xc'',''yc'')</code>: Multiply ''xc'' and ''yc'' element by element.
:;<code>''rc''=cmul(''xc'',''yc'')</code>: Multiply ''xc'' and ''yc'' element by element.
;vector and matrix multiplication
:;<code>''rc''<sub>matrix</sub>=cmulv(''xc''<sub>vector</sub>,''yc''<sub>vector</sub>): Compute the tensor (or dyadic) product of the two complex vectors ''xc'' and ''yc''.
:::<code>''rc''<sub>i,j</sub> = ''xc''<sub>i</sub> * ''yc''<sub>j</sub>


;special functions
;special functions
Line 67: Line 71:




 
;See also: [[Programmer_Guide/Command_Reference/EVAL/fft|fft]], [[Programmer_Guide/Command_Reference/EVAL#complex numbers|complex numbers]]
;See also: [[Programmer_Guide/Command_Reference/EVAL/window|window]], [[Programmer_Guide/Command_Reference/EVAL/fft|fft]]


[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
=====cr2p=====
Convert Cartesian coordinates to Polar coordinates
=====Usage:=====
<code>cr2p(<var>x</var>C)</code>
=====Return Type:=====
like <var>x</var>C
complex numbers

Revision as of 14:49, 7 April 2011

Because the current version of the STx EVAL command do not support a complex data type, a package of functions is used to implement arithmetic and special handling for complex numbers.

Note:

  • A numerical object containing N x M complex numbers (N>=1, M>=1), consists of 2N rows and M columns, because each complex number uses two cells of a row.
  • If a numerical object containing N x M complex numbers, is converted element-wise to real numbers, the resulting object consists of N rows and M columns.
complex -> complex
argument xc any complex type
result rc same complex type as xc
rc=cr2p(xc)
Convert xc from cartesian (real, imaginary) to polar (length, phase) format.
rc=cp2r(xc)
Convert xc from polar (length, phase) to cartesian (real, imaginary) format.
rc=conj(xc)
Conjugate xc; xc must be in cartesian format.
complex -> real
argument xc any complex type
result r same real type as xc
r=cr2len(xc): Compute length of xc; xc is stored in cartesian format.
r=cr2phi(xc)
Compute phase of xc; xc is stored in cartesian format.
r=cget(xc,0)
Get real part or length of xc (depends on format of xc).
r=cget(xc,1)
Get imaginary part or phase of xc (depends on format of xc).
real -> complex
argument x any real type
argument y same type as x
result rc same complex type as x
rc=cset(x,y)
Combine elements of x (real part or length) and y (imaginary part or phase) to a complex numbers
multiplication (element-wise)
argument xc any complex type (re,im)
argument yc same type as 'xc'
argument n a real or complex number (re,im)
result rc same complex type as xc
rc=cmul(xc,n)
rc=cmul(n,xc)
Multiply each element of xc with the real or complex number n.
rc=cmul(xc,yc)
Multiply xc and yc element by element.
vector and matrix multiplication
rcmatrix=cmulv(xcvector,ycvector): Compute the tensor (or dyadic) product of the two complex vectors xc and yc.
rci,j = xci * ycj
special functions
rc=cdot(xc,yc)
the result rc (complex number) is the dot product of the complex vectors xc and yc
rc=ctrn(xc)
the result rc is transposed matrix of the complex matrix xc


See also
fft, complex numbers

<function list>

Navigation menu

Personal tools