Programmer Guide/Command Reference/EVAL/complex arithmetic: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
|- | |- | ||
!result ''rc'' | !result ''rc'' | ||
| same complex type as ''xc'' | | same '''complex''' type as ''xc'' | ||
|} | |} | ||
Line 19: | Line 19: | ||
|- | |- | ||
| '''<code>''rc''=cp2r(''xc'')</code>''' || ... convert ''xc'' from polar (length, phase) to cartesian (real, imaginary) format | | '''<code>''rc''=cp2r(''xc'')</code>''' || ... convert ''xc'' from polar (length, phase) to cartesian (real, imaginary) format | ||
|- | |||
| '''<code>''rc''=conj(''xc'')</code>''' || ... cojugate ''xc'' (''xc'' must be in cartesian format) | |||
|} | |} | ||
Line 27: | Line 29: | ||
|- | |- | ||
!result ''r'' | !result ''r'' | ||
| same ''real'' type as ''xc'' | | same '''real''' type as ''xc'' | ||
|} | |} | ||
Line 44: | Line 46: | ||
!argument ''x'' | !argument ''x'' | ||
| any real type | | any real type | ||
|- | |||
!argument ''y'' | !argument ''y'' | ||
|same type as ''x'' | |||
|- | |- | ||
!result ''rc'' | !result ''rc'' | ||
| same ''complex'' type as ''x'' | | same '''complex''' type as ''x'' | ||
|} | |} | ||
Line 54: | Line 57: | ||
| '''<code>''rc''=cset(''x'',''y'')</code>''' || ... combine ''x'' (real part or length) and ''y'' (imaginary part or phase) elements to a complex numbers | | '''<code>''rc''=cset(''x'',''y'')</code>''' || ... combine ''x'' (real part or length) and ''y'' (imaginary part or phase) elements to a complex numbers | ||
|} | |} | ||
;complex multiplication | |||
:{|class="keinrahmen" | |||
| '''<code>''rc''=cset(''xc'',''nc'')</code>''' | |||
;special functions | |||
:;<code>''rc''=cdot(''xc'',''yc'')</code>: the result ''rc'' (complex number) is the dot product of the complex vectors ''xc'' and ''yc'' | |||
:;<code>''rc''=ctrn(''xc'')</code>: the result ''rc'' is transposed matrix of the complex matrix ''xc'' | |||
Revision as of 13:25, 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)
... cojugate 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 x (real part or length) and y (imaginary part or phase) elements to a complex numbers
- complex multiplication
rc=cset(xc,nc)
- 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
cr2p
Convert Cartesian coordinates to Polar coordinates
Usage:
cr2p(xC)
Return Type:
like xC
complex numbers