当前位置: 首页>>代码示例>>C#>>正文


C# Complex类代码示例

本文整理汇总了C#中Complex的典型用法代码示例。如果您正苦于以下问题:C# Complex类的具体用法?C# Complex怎么用?C# Complex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Complex类属于命名空间,在下文中一共展示了Complex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Exp

 //b == Exp(a)
 //c == 1/Exp(a)
 public static void Exp(Complex a, out Complex b, out Complex c)
 {
     double d = Math.Exp(a.Real);
     Complex e = new Complex(Math.Cos(a.Imaginary), Math.Sin(a.Imaginary));
     b = e * d;
     c = b.Reciprocal();
 }
开发者ID:JesusFreke,项目名称:didjimp,代码行数:9,代码来源:ComplexMathUtils.cs

示例2: Tanh

		public static Complex Tanh(Complex z)
		{
			double x = Math.Tanh(z.Re);
			double y = Math.Tan(z.Im);

			return new Complex(x, y) / new Complex(1, x * y);
		}
开发者ID:ufcpp,项目名称:UfcppSample,代码行数:7,代码来源:ComplexMath.cs

示例3: addOpperand

 public override void addOpperand(Calc calc,Complex c)
 {
     //calc.Opperand1=calc.Total;
     //calc.Opperand2=c;
     calc.Total=c;
     calc.CurrentState=OpperandEnteredState.Singleton;
 }
开发者ID:eggie5,项目名称:SDSU-COMPE361-FALL12,代码行数:7,代码来源:CompState.cs

示例4: JuliaWithClouds

 public JuliaWithClouds(ulong IterCount, double LeftEdge, double RightEdge, double TopEdge, double BottomEdge, Complex ComplexConst,int MaxAmmountAtTrace=100,int AbcissStepSize=20,int OrdinateStepSize=20)
     : base(IterCount,LeftEdge,RightEdge,TopEdge,BottomEdge,ComplexConst)
 {
     _max_ammount_at_trace = MaxAmmountAtTrace;
     _abciss_step_length = AbcissStepSize;
     _ordinate_step_length = OrdinateStepSize;
 }
开发者ID:asteroidsuper,项目名称:FractalBrowser,代码行数:7,代码来源:JuliaWithClouds.cs

示例5: Hash

 public Hash(Complex[][] comData)
 {
     this.comData = comData;
     width = comData.Length;
     if (width != 0)
         height = 600;
 }
开发者ID:vlad7777,项目名称:Music-Recognition,代码行数:7,代码来源:Hash.cs

示例6: Start

        public static void Start(Random rnd)
        {
            int length = 4096;
            var masComplex1 = new Complex[length];
            var masSimdComplex1 = new Vector2[length];
            var masComplex2 = new Complex[length];
            var masSimdComplex2 = new Vector2[length];
            for (int i = 0; i < length; i++)
            {
                float v1 = (float) rnd.NextDouble()*1000;
                float v2 = (float) rnd.NextDouble()*1000;
                masComplex1[i] = new Complex(v1, v2);
                masSimdComplex1[i] = new Vector2(v1,v2);

                v1 = (float)rnd.NextDouble() * 1000;
                v2 = (float)rnd.NextDouble() * 1000;
                masComplex2[i] = new Complex(v1, v2);
                masSimdComplex2[i] = new Vector2(v1, v2);
            }

            Extensions.TestTime(() =>
                TestWithoutSimd(masComplex1, masComplex2),
                "Время для complex       ");

            Extensions.TestTime(() =>
                TestWithSimd(masSimdComplex1, masSimdComplex2),
                "Время для complex(simd) ");
        }
开发者ID:annhv,项目名称:parp,代码行数:28,代码来源:Task4.cs

示例7: VerifyFactoryMethod

        private static void VerifyFactoryMethod(double magnitude, double phase)
        {
            double m = magnitude;
            double p = phase;
            Complex c_new = Complex.FromPolarCoordinates(magnitude, phase);
            //Double.IsNaN(magnitude) is checked in the verifiation method.
            if (Double.IsNaN(phase) || Double.IsInfinity(phase))
            {
                magnitude = Double.NaN;
                phase = Double.NaN;
            }
            // Special check in Complex.Abs method
            else if (Double.IsInfinity(magnitude))
            {
                magnitude = Double.PositiveInfinity;
                phase = Double.NaN;
            }

            if (false == Support.VerifyMagnitudePhaseProperties(c_new, magnitude, phase))
            {
                Console.WriteLine("Error_89fdl!!! FromPolorCoordinates: ({0}, {1})", m, p);

                Assert.True(false, "Verification Failed");
            }
            else // if the first verification returns TrUe, do the second one!
            {
                Complex c_new_ctor = new Complex(c_new.Real, c_new.Imaginary);
                if (false == Support.VerifyMagnitudePhaseProperties(c_new_ctor, magnitude, phase))
                {
                    Console.WriteLine("Error_fs46!!! FromPolorCoordinates: ({0}, {1})", m, p);

                    Assert.True(false, "Verification Failed");
                }
            }
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:35,代码来源:factoryMethod.cs

示例8: ClampLength

 //---------------------------------------------------------------------------------------------
 /// <summary>
 ///   Clamp length (modulus) of the elements in the complex array
 /// </summary>
 /// <param name = "array"></param>
 /// <param name = "fMinimum"></param>
 /// <param name = "fMaximum"></param>
 public static void ClampLength(Complex[] array, double fMinimum, double fMaximum)
 {
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = Complex.FromModulusArgument(Math.Max(fMinimum, Math.Min(fMaximum, array[i].GetModulus())), array[i].GetArgument());
     }
 }
开发者ID:eugentorica,项目名称:soundfingerprinting,代码行数:14,代码来源:ComplexArray.cs

示例9: Create

        /// <summary>
        /// Initializes a new instance of the <see cref="UserQR"/> class. This object will compute the
        /// QR factorization when the constructor is called and cache it's factorization.
        /// </summary>
        /// <param name="matrix">The matrix to factor.</param>
        /// <param name="method">The QR factorization method to use.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="matrix"/> is <c>null</c>.</exception>
        public static UserQR Create(Matrix<Complex> matrix, QRMethod method = QRMethod.Full)
        {
            if (matrix.RowCount < matrix.ColumnCount)
            {
                throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
            }

            Matrix<Complex> q;
            Matrix<Complex> r;

            var minmn = Math.Min(matrix.RowCount, matrix.ColumnCount);
            var u = new Complex[minmn][];

            if (method == QRMethod.Full)
            {
                r = matrix.Clone();
                q = Matrix<Complex>.Build.SameAs(matrix, matrix.RowCount, matrix.RowCount);

                for (var i = 0; i < matrix.RowCount; i++)
                {
                    q.At(i, i, 1.0f);
                }

                for (var i = 0; i < minmn; i++)
                {
                    u[i] = GenerateColumn(r, i, i);
                    ComputeQR(u[i], r, i, matrix.RowCount, i + 1, matrix.ColumnCount, Control.MaxDegreeOfParallelism);
                }

                for (var i = minmn - 1; i >= 0; i--)
                {
                    ComputeQR(u[i], q, i, matrix.RowCount, i, matrix.RowCount, Control.MaxDegreeOfParallelism);
                }
            }
            else
            {
                q = matrix.Clone();

                for (var i = 0; i < minmn; i++)
                {
                    u[i] = GenerateColumn(q, i, i);
                    ComputeQR(u[i], q, i, matrix.RowCount, i + 1, matrix.ColumnCount, Control.MaxDegreeOfParallelism);
                }

                r = q.SubMatrix(0, matrix.ColumnCount, 0, matrix.ColumnCount);
                q.Clear();

                for (var i = 0; i < matrix.ColumnCount; i++)
                {
                    q.At(i, i, 1.0f);
                }

                for (var i = minmn - 1; i >= 0; i--)
                {
                    ComputeQR(u[i], q, i, matrix.RowCount, i, matrix.ColumnCount, Control.MaxDegreeOfParallelism);
                }
            }

            return new UserQR(q, r, method);
        }
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:67,代码来源:UserQR.cs

示例10: Complex

        public static Complex operator +(Complex c1, Complex c2)
        {
            int cnt = c1.b * c2.b;
            int sum = c2.b * c1.a + c1.b * c2.a;
            if (cnt > sum)
            {
                for (int i = sum; i > 2; i--)
                {
                    if (cnt % i == 0 && sum % i == 0)
                    {
                        cnt = cnt / i;
                        sum = sum / i;
                        break;
                    }
                }
            }
            else
            {
                for (int i = cnt; i > 2; i--)
                {
                    if (cnt % i == 0 && sum % i == 0)
                    {
                        cnt = cnt / i;
                        sum = sum / i;
                        break;
                    }

                }
            }
            Complex c3 = new Complex(sum, cnt);
            return c3;
        }
开发者ID:zhaziraumirkalykova,项目名称:example,代码行数:32,代码来源:Program.cs

示例11: Main

        static void Main(string[] args)
        {
            Complex c1 = new Complex(1, 2);
            Complex c2 = new Complex(1, 2);
            Complex c3 = new Complex();

            Console.WriteLine(c1);
            Console.WriteLine(c2);
            Console.WriteLine(c3);

            Complex c4 = c1.Add(c2);
            Console.WriteLine(c4);

            Complex c5 = c2.Subtract(c1);
            Console.WriteLine(c5);

            Complex c6 = c1.Multiply(c2);
            Console.WriteLine(c6);

                      
            if(c1.Equals(c2))
                Console.WriteLine("c1 este egal cu c2");
            else
                Console.WriteLine("c1 nu este egal cu c2");

        }
开发者ID:HoreaOros,项目名称:Cosmin,代码行数:26,代码来源:Program.cs

示例12: SetVar

 public void SetVar(string varname, Complex value)
 {
     var root = Root;
     if (root.m_variables == null)
         root.m_variables = new Dictionary<string, Complex>();
     root.m_variables[varname.ToLower()] = value;
 }
开发者ID:zdimension,项目名称:IMPression,代码行数:7,代码来源:EquationElement.cs

示例13: ExecuteWithParamsTest

        public void ExecuteWithParamsTest()
        {
            var complex = new Complex(5, 2);
            var exp = new ComplexNumber(complex);

            Assert.Equal(complex, exp.Execute(null));
        }
开发者ID:sys27,项目名称:xFunc,代码行数:7,代码来源:ComplexNumberTest.cs

示例14: ExecuteTest

        public void ExecuteTest()
        {
            var complex = new Complex(5, 2);
            var exp = new ComplexNumber(complex);

            Assert.Equal(complex, exp.Execute());
        }
开发者ID:sys27,项目名称:xFunc,代码行数:7,代码来源:ComplexNumberTest.cs

示例15: processData

        public void processData(ref Complex[][] res, ref int resLen)
        {
            resLen = 0;

            int channels = 2;
            int pbs = 4096*2*channels;

            for(int i = 0; i<len/pbs; i++)
            {

                comData = new Complex[10000];
                comLen = 0;

                for (int j = i*pbs, cur = 0; j < (i+1)*pbs; j+=2*channels, cur++)
                {
                    float sum = 0;
                    for (int k = 0; k < channels; k++)
                        sum += (buf[j + 2 * k + 1] << 8) | (buf[j + 2 * k]);
                    sum /= channels;
                    comData[comLen].X = sum;
                    comData[comLen].X *= (float)FastFourierTransform.HammingWindow(cur, 4096);
                    comData[comLen].Y = 0;
                    comLen++;
                }

                FastFourierTransform.FFT(true, 12, comData);

                res[resLen] = comData;
                resLen++;
            }
            resLen++;
            resLen--;
        }
开发者ID:vlad7777,项目名称:Music-Recognition,代码行数:33,代码来源:mp3Processor.cs


注:本文中的Complex类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。