本文整理汇总了C#中Complex类的典型用法代码示例。如果您正苦于以下问题:C# Complex类的具体用法?C# Complex怎么用?C# Complex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Complex类属于命名空间,在下文中一共展示了Complex类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: GetCorrelation
/// <summary>
/// Gets the correlation.
/// </summary>
/// <param name="originalVector">The original vector.</param>
/// <param name="correlationVector">The correlation vector.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentException">Different length of vectors</exception>
public static Complex[] GetCorrelation(Complex[] originalVector, Complex[] correlationVector)
{
if (originalVector.Length != correlationVector.Length)
{
throw new ArgumentException("Different length of vectors");
}
CorrelationComplexibility = 0;
// ReSharper disable once InconsistentNaming
var N = originalVector.Length;
var result = new Complex[N];
for (var i = 0; i < N; i++)
{
for (var j = 0; j < N; j++)
{
if (i + j < N)
{
result[i] += originalVector[j] * correlationVector[i + j];
CorrelationComplexibility++;
}
else
{
result[i] += originalVector[j] * correlationVector[i + j - N];
CorrelationComplexibility++;
}
}
result[i] /= N;
}
return result;
}
开发者ID:ptorchilov,项目名称:DigitalSignalAndProcessing,代码行数:41,代码来源:CorrelationUtils.cs
示例17: divide
}//multiply
public cFloat divide(cFloat c1, cFloat c2){
Complex comp1 = new Complex(c1.getReal(), c1.getImg());
Complex comp2 = new Complex(c2.getReal(), c1.getImg());
Complex comp3 = comp1 / comp2;
return new cFloat((float)comp3.Real, (float)comp3.Imaginary);
}//divide
开发者ID:th58,项目名称:Windows_Programming,代码行数:9,代码来源:complex.cs
示例18: VerifyBinaryMultiplyResult
private static void VerifyBinaryMultiplyResult(Double realFirst, Double imgFirst, Double realSecond, Double imgSecond)
{
// calculate the expected results
Double realExpectedResult = realFirst * realSecond - imgFirst * imgSecond;
Double imaginaryExpectedResult = realFirst * imgSecond + imgFirst * realSecond;
// Create complex numbers
Complex cFirst = new Complex(realFirst, imgFirst);
Complex cSecond = new Complex(realSecond, imgSecond);
// arithmetic multiply (binary) operation
Complex cResult = cFirst * cSecond;
// verify the result
if (false == Support.VerifyRealImaginaryProperties(cResult, realExpectedResult, imaginaryExpectedResult))
{
Console.WriteLine("ErRoR! Binary Multiply Error!");
Console.WriteLine("Binary Multiply test = ({0}, {1}) * ({2}, {3})", realFirst, imgFirst, realSecond, imgSecond);
Assert.True(false, "Verification Failed");
}
// arithmetic multiply (static) operation
cResult = Complex.Multiply(cFirst, cSecond);
// verify the result
if (false == Support.VerifyRealImaginaryProperties(cResult, realExpectedResult, imaginaryExpectedResult))
{
Console.WriteLine("ErRoR! Multiply (Static) Error!");
Console.WriteLine("Multiply (Static) test = ({0}, {1}) * ({2}, {3})", realFirst, imgFirst, realSecond, imgSecond);
Assert.True(false, "Verification Failed");
}
}
开发者ID:gitter-badger,项目名称:corefx,代码行数:32,代码来源:arithmaticOperation_BinaryMultiply_Multiply.cs
示例19: Clamp
/// <summary>
/// Clamp elements in the complex array to range [minimum,maximum]
/// </summary>
/// <param name="array"></param>
/// <param name="minimum"></param>
/// <param name="maximum"></param>
public static void Clamp( Complex[] array, Complex minimum, Complex maximum )
{
for( int i = 0; i < array.Length; i ++ ) {
array[i].Re = Math.Min( Math.Max( array[ i ].Re, minimum.Re ), maximum.Re );
array[i].Im = Math.Min( Math.Max( array[ i ].Re, minimum.Im ), maximum.Im );
}
}
开发者ID:devsprasad,项目名称:OpenSignalLib,代码行数:13,代码来源:ComplexArray.cs
示例20: VerifySqrtWithRectangularForm
private static void VerifySqrtWithRectangularForm(Double real, Double imaginary)
{
// sqrt(a+bi) = +- (sqrt(r + a) + i sqrt(r - a) sign(b)) sqrt(2) / 2, unless a=-r and y = 0
Complex complex = new Complex(real, imaginary);
Double expectedReal = 0.0;
Double expectedImaginary = 0.0;
if (0 == imaginary)
{
if (real == -complex.Magnitude)
expectedImaginary = Math.Sqrt(-real);
else
expectedReal = Math.Sqrt(real);
}
else
{
Double scale = 1 / Math.Sqrt(2);
expectedReal = scale * Math.Sqrt(complex.Magnitude + complex.Real);
expectedImaginary = scale * Math.Sqrt(complex.Magnitude - complex.Real);
if (complex.Imaginary < 0)
{
expectedImaginary = -expectedImaginary;
}
}
VerifySqrtWithRectangularForm(real, imaginary, expectedReal, expectedImaginary);
}
开发者ID:gitter-badger,项目名称:corefx,代码行数:27,代码来源:standardNumericalFunctions_Sqrt.cs
注:本文中的Complex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论