複素数クラスの実装1 実部と虚部をメンバに持つ 加減算は高速で、乗除算は低速
Inheritance: Complex
Exemple #1
0
        public override Complex Div(Complex z)
        {
            CartesianComplex w = new CartesianComplex(this.re * z.Re + this.im * z.Im, this.im * z.Re - this.re * z.Im);

            w.re /= z.Norm();
            w.im /= z.Norm();
            return(w);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Complex z, w;

            z = new CartesianComplex(1, 1);
            w = new CartesianComplex(0, 1);
            Show(z, w);             // Cartesian 同士

            z = new PolarComplex(Math.Sqrt(2), Math.PI / 4);
            Show(z, w);             // Polar と Cartesian

            w = new PolarComplex(1, Math.PI / 2);
            Show(z, w);             // Polar 同士

            z = new CartesianComplex(1, 1);
            Show(z, w); // Cartesian と Polar
        }               //Main
Exemple #3
0
		static void Main(string[] args)
		{
			Complex z, w;

			z = new CartesianComplex(1, 1);
			w = new CartesianComplex(0, 1);
			Show(z, w); // Cartesian 同士

			z = new PolarComplex(Math.Sqrt(2), Math.PI/4);
			Show(z, w); // Polar と Cartesian

			w = new PolarComplex(1, Math.PI/2);
			Show(z, w); // Polar 同士

			z = new CartesianComplex(1, 1);
			Show(z, w); // Cartesian と Polar
		}//Main
		public override Complex Div(Complex z)
		{
			CartesianComplex w = new CartesianComplex(this.re * z.Re + this.im * z.Im, this.im * z.Re - this.re * z.Im);
			w.re /= z.Norm();
			w.im /= z.Norm();
			return w;
		}