0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C#で複素数を扱う

Posted at

背景

C#で複素数を扱うことがありまして、調べたのでメモ書き。
やりたかったことは、Real/ImaginaryからMagnitude/Angleへの変換。
Complexクラスに放りこむだけで簡単に変換できるので超~楽ちん!

やり方

  1. プロジェクトの参照設定にSystem.Numericsを追加する。

    image.png
  2. Complex形式でコンストラクタを使って変数定義する。
using System.Numerics

double Re = 1.0;      // Real
double Im = 1.0;      // Imaginary

Complex z = new Complex(Re, Im);

// z.Magnitude    <= 1.41421356
// z.Phase        <= unit:radian
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?