複素数を計算する
c = complex(u) c = complex(a, b)
a and b are not
scalars, they must have the same sizes.
u or of
a and b.
If u is sparse, or if a and
b have the same sizes and both are sparse,
then c is also sparse.
Otherwise c is dense-encoded.
c = complex(u) は, uを実部,
0 を虚部とする複素数を作成します.
c = complex(a,b) は実部a ,
虚部bの複素数を作成します.
This function is equivalent to a + imult(b), which
handles properly special Inf and NaN real and imaginary parts.
以下の例では,実部と虚部から複素数を生成します.
a のみが指定された場合, 虚部は0に設定されます.
a がスカラーで b が
行列の場合, 結果 c は,
bと同じ大きさとなります.
同様に, b がスカラーで a
が行列の場合, 結果 c は
aと同じ大きさになります.
a と b が
異なる大きさの行列の場合,以下のセッションのような
エラーが発生します.
-->complex(ones(2,3),ones(4,5)) !--error 10000 complex: Incompatible input arguments #1 and #2: Same sizes expected. at line 33 of function complex called by : complex(ones(2,3),ones(4,5))
With special real or/and imaginary parts:
r = [0 0 0 %inf %inf %inf %nan %nan %nan].'; i = [0 %inf %nan 0 %inf %nan 0 %inf %nan].'; [r, i] // Then let's compare complex(r, i) with r + i*%i : [complex(r,i), r+i*%i] | ![]() | ![]() |
--> [r, i] ans = 0. 0. 0. Inf 0. Nan Inf 0. Inf Inf Inf Nan Nan 0. Nan Inf Nan Nan // Then let's compare complex(r, i) with r + i*%i : --> [complex(r,i), r+i*%i] ans = 0. + 0.i 0. + 0.i 0. + Infi Nan + Infi 0. + Nani Nan + Nani Inf + 0.i Inf + 0.i Inf + Infi Nan + Infi Inf + Nani Nan + Nani Nan + 0.i Nan + 0.i Nan + Infi Nan + Infi Nan + Nani Nan + Nani
| Version | Description |
| 6.1.1 | Extension to sparse arrays. |