本文整理汇总了C#中Altaxo.Calc.ComplexFloat类的典型用法代码示例。如果您正苦于以下问题:C# ComplexFloat类的具体用法?C# ComplexFloat怎么用?C# ComplexFloat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComplexFloat类属于Altaxo.Calc命名空间,在下文中一共展示了ComplexFloat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EqualsTest
public void EqualsTest()
{
ComplexFloat cf1 = new ComplexFloat(-1.1f, 2.2f);
ComplexFloat cf2 = new ComplexFloat(-1.1f, 2.2f);
Assert.IsTrue(cf1 == cf2);
Assert.IsTrue(cf1.Equals(cf2));
}
示例2: OperatorsTest
public void OperatorsTest()
{
ComplexFloat cf1 = new ComplexFloat(1.1f, -2.2f);
ComplexFloat cf2 = new ComplexFloat(-3.3f, 4.4f);
ComplexFloat test = cf1 * cf2;
Assert.AreEqual(test.Real,6.05);
Assert.AreEqual(test.Imag,12.1);
test = cf1 / cf2;
Assert.AreEqual(test.Real,-0.44);
Assert.AreEqual(test.Imag,0.08,TOLERENCE);
test = cf1 + cf2;
Assert.AreEqual(test.Real,-2.2);
Assert.AreEqual(test.Imag,2.2);
test = cf1 - cf2;
Assert.AreEqual(test.Real,4.4);
Assert.AreEqual(test.Imag,-6.6);
//test = cf1 ^ cf2;
//Assert.AreEqual(test.Real,1.593,TOLERENCE);
//Assert.AreEqual(test.Imag,6.503,TOLERENCE);
}
示例3: NaNTest
public void NaNTest()
{
ComplexFloat cf = new ComplexFloat(Single.NaN, 1.1f);
Assert.IsTrue(cf.IsNaN());
cf = new ComplexFloat(1.1f, Single.NaN);
Assert.IsTrue(cf.IsNaN());
cf = new ComplexFloat(1.1f, 2.2f);
Assert.IsFalse(cf.IsNaN());
}
示例4: ConversionTest
public void ConversionTest()
{
Complex cd1 = 2.2;
ComplexFloat cf = new ComplexFloat(-1.1f, 2.2f);
Complex cd2 = cf;
Assert.AreEqual(cd1.Real, 2.2);
Assert.AreEqual(cd1.Imag, 0);
Assert.AreEqual(cd2.Real, -1.1, TOLERENCE);
Assert.AreEqual(cd2.Imag, 2.2, TOLERENCE);
}
示例5: EqualsTest
public void EqualsTest()
{
Complex cd1 = new Complex(-1.1, 2.2);
Complex cd2 = new Complex(-1.1, 2.2);
Complex cd3 = new Complex(-1, 2);
ComplexFloat cf = new ComplexFloat(-1, 2);
Assert.IsTrue(cd1 == cd2);
Assert.IsTrue(cd1.Equals(cd2));
Assert.IsTrue(cd3 == cf);
Assert.IsTrue(cd3.Equals(cf));
}
示例6: CtorInitialValues
public void CtorInitialValues()
{
ComplexFloatMatrix test = new ComplexFloatMatrix(2,2,new ComplexFloat(1,1));
Assert.AreEqual(test.RowLength, 2);
Assert.AreEqual(test.ColumnLength, 2);
ComplexFloat value = new ComplexFloat(1,1);
Assert.AreEqual(test[0,0], value);
Assert.AreEqual(test[0,1], value);
Assert.AreEqual(test[1,0], value);
Assert.AreEqual(test[1,1], value);
}
示例7: ComplexFloatLUDecompTest
static ComplexFloatLUDecompTest()
{
ComplexFloatMatrix a = new ComplexFloatMatrix(3);
a[0,0] = new ComplexFloat(-1,1);
a[0,1] = 5;
a[0,2] = 6;
a[1,0] = 3;
a[1,1] = -6;
a[1,2] = 1;
a[2,0] = 6;
a[2,1] = 8;
a[2,2] = 9;
lu = new ComplexFloatLUDecomp(a);
}
示例8: ComplexFloatCholeskyDecompTest
static ComplexFloatCholeskyDecompTest()
{
ComplexFloatMatrix a = new ComplexFloatMatrix(3);
a[0,0] = 2;
a[0,1] = new ComplexFloat(1,-1);
a[0,2] = 0;
a[1,0] = new ComplexFloat(1,-1);
a[1,1] = 2;
a[1,2] = 0;
a[2,0] = 0;
a[2,1] = 0;
a[2,2] = 3;
cd = new ComplexFloatCholeskyDecomp(a);
}
示例9: SquareDecomp
public void SquareDecomp()
{
ComplexFloatMatrix a = new ComplexFloatMatrix(3);
a[0,0] = new ComplexFloat(1.1f, 1.1f);
a[0,1] = new ComplexFloat(2.2f, -2.2f);
a[0,2] = new ComplexFloat(3.3f, 3.3f);
a[1,0] = new ComplexFloat(4.4f, -4.4f);
a[1,1] = new ComplexFloat(5.5f, 5.5f);
a[1,2] = new ComplexFloat(6.6f, -6.6f);
a[2,0] = new ComplexFloat(7.7f, 7.7f);
a[2,1] = new ComplexFloat(8.8f, -8.8f);
a[2,2] = new ComplexFloat(9.9f, 9.9f);
ComplexFloatQRDecomp qrd = new ComplexFloatQRDecomp(a);
ComplexFloatMatrix qq = qrd.Q.GetConjugateTranspose()*qrd.Q;
ComplexFloatMatrix qr = qrd.Q*qrd.R;
ComplexFloatMatrix I = ComplexFloatMatrix.CreateIdentity(3);
// determine the maximum relative error
double MaxError = 0.0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; i < 3; i++)
{
double E = ComplexMath.Absolute((qq[i, j] - I[i, j]));
if (E > MaxError)
{
MaxError = E;
}
}
}
Assert.IsTrue(MaxError < 1.0E-6);
MaxError = 0.0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; i < 3; i++)
{
double E = ComplexMath.Absolute((qr[i, j] - a[i, j]) / a[i, j]);
if (E > MaxError)
{
MaxError = E;
}
}
}
Assert.IsTrue(MaxError < 2.4E-6);
}
示例10: CtorCopy
public void CtorCopy()
{
ComplexFloatMatrix a = new ComplexFloatMatrix(2,2);
a[0,0] = new ComplexFloat(1,1);
a[0,1] = new ComplexFloat(2,2);
a[1,0] = new ComplexFloat(3,3);
a[1,1] = new ComplexFloat(4,4);
ComplexFloatMatrix b = new ComplexFloatMatrix(a);
Assert.AreEqual(a.RowLength, b.RowLength);
Assert.AreEqual(a.ColumnLength, b.ColumnLength);
Assert.AreEqual(a[0,0], b[0,0]);
Assert.AreEqual(a[0,1], b[0,1]);
Assert.AreEqual(a[1,0], b[1,0]);
Assert.AreEqual(a[1,1], b[1,1]);
}
示例11: Absolute
public void Absolute()
{
Complex cd1 = new Complex(1.1, -2.2);
Complex cd2 = new Complex(0, -2.2);
Complex cd3 = new Complex(1.1, 0);
Complex cd4 = new Complex(-1.1, 2.2);
ComplexFloat cf1 = new ComplexFloat(1.1f, -2.2f);
ComplexFloat cf2 = new ComplexFloat(0, -2.2f);
ComplexFloat cf3 = new ComplexFloat(1.1f, 0);
ComplexFloat cf4 = new ComplexFloat(-1.1f, 2.2f);
Assert.AreEqual(ComplexMath.Absolute(cd1),2.460,TOLERENCE);
Assert.AreEqual(ComplexMath.Absolute(cd2),2.2,TOLERENCE);
Assert.AreEqual(ComplexMath.Absolute(cd3),1.1,TOLERENCE);
Assert.AreEqual(ComplexMath.Absolute(cd4),2.460,TOLERENCE);
Assert.AreEqual(ComplexMath.Absolute(cf1),2.460,TOLERENCE);
Assert.AreEqual(ComplexMath.Absolute(cf2),2.2,TOLERENCE);
Assert.AreEqual(ComplexMath.Absolute(cf3),1.1,TOLERENCE);
Assert.AreEqual(ComplexMath.Absolute(cf4),2.460,TOLERENCE);
}
示例12: Argument2
public void Argument2()
{
Complex cd1 = new Complex(1.1, -2.2);
Complex cd2 = new Complex(0, -2.2);
Complex cd3 = new Complex(1.1, 0);
Complex cd4 = new Complex(-1.1, 2.2);
ComplexFloat cf1 = new ComplexFloat(1.1f, -2.2f);
ComplexFloat cf2 = new ComplexFloat(0, -2.2f);
ComplexFloat cf3 = new ComplexFloat(1.1f, 0);
ComplexFloat cf4 = new ComplexFloat(-1.1f, 2.2f);
Assert.AreEqual(ComplexMath.Argument2(cd1),-1.107,TOLERENCE);
Assert.AreEqual(ComplexMath.Argument2(cd2),-1.571,TOLERENCE);
Assert.AreEqual(ComplexMath.Argument2(cd3),0,TOLERENCE);
Assert.AreEqual(ComplexMath.Argument2(cd4),2.034,TOLERENCE);
Assert.AreEqual(ComplexMath.Argument2(cf1),-1.107,TOLERENCE);
Assert.AreEqual(ComplexMath.Argument2(cf2),-1.571,TOLERENCE);
Assert.AreEqual(ComplexMath.Argument2(cf3),0,TOLERENCE);
Assert.AreEqual(ComplexMath.Argument2(cf4),2.034,TOLERENCE);
}
示例13: OperatorsTest
public void OperatorsTest()
{
ComplexFloat cf1 = new ComplexFloat(1.1f, -2.2f);
ComplexFloat cf2 = new ComplexFloat(-3.3f, 4.4f);
ComplexFloat test = cf1 * cf2;
Assert.AreEqual(test.Real, 6.05f);
Assert.AreEqual(test.Imag, 12.1f);
test = cf1 / cf2;
Assert.AreEqual(test.Real, -0.44f);
Assert.AreEqual(test.Imag, 0.08f, TOLERANCE);
test = cf1 + cf2;
Assert.AreEqual(test.Real, (1.1f - 3.3f));
Assert.AreEqual(test.Imag, (-2.2f + 4.4f));
test = cf1 - cf2;
Assert.AreEqual(test.Real, (1.1f + 3.3f));
Assert.AreEqual(test.Imag, (-2.2f - 4.4f));
}
示例14: SumRecursion
static private ComplexFloat SumRecursion( ComplexFloat[] data, int start, int end )
{
Debug.Assert( 0 <= start, "start = " + start );
Debug.Assert( start < end, "start = " + start + " and end = " + end );
Debug.Assert( end <= data.Length, "end = " + end + " and data.Length = " + data.Length );
if( ( end - start ) <= 1000 )
{
ComplexFloat sum = ComplexFloat.Zero;
for( int i = start; i < end; i ++ )
{
sum += data[ i ];
}
return sum;
}
else
{
int middle = ( start + end ) >> 1;
return SumRecursion( data, start, middle ) + SumRecursion( data, middle, end );
}
}
示例15: SetupTestCases
public void SetupTestCases()
{
a = new ComplexFloatMatrix(3);
a[0,0] = new ComplexFloat(1.1f, 1.1f);
a[0,1] = new ComplexFloat(2.2f, -2.2f);
a[0,2] = new ComplexFloat(3.3f, 3.3f);
a[1,0] = new ComplexFloat(4.4f, -4.4f);
a[1,1] = new ComplexFloat(5.5f, 5.5f);
a[1,2] = new ComplexFloat(6.6f, -6.6f);
a[2,0] = new ComplexFloat(7.7f, 7.7f);
a[2,1] = new ComplexFloat(8.8f, -8.8f);
a[2,2] = new ComplexFloat(9.9f, 9.9f);
svd = new ComplexFloatSVDDecomp(a, true);
wa = new ComplexFloatMatrix(2,4);
wa[0,0] = new ComplexFloat(1.1f, 1.1f);
wa[0,1] = new ComplexFloat(2.2f, -2.2f);
wa[0,2] = new ComplexFloat(3.3f, 3.3f);
wa[0,3] = new ComplexFloat(4.4f, -4.4f);
wa[1,0] = new ComplexFloat(5.5f, 5.5f);
wa[1,1] = new ComplexFloat(6.6f, -6.6f);
wa[1,2] = new ComplexFloat(7.7f, 7.7f);
wa[1,3] = new ComplexFloat(8.8f, -8.8f);
wsvd = new ComplexFloatSVDDecomp(wa, true);
la = new ComplexFloatMatrix(4,2);
la[0,0] = new ComplexFloat(1.1f, 1.1f);
la[0,1] = new ComplexFloat(2.2f, -2.2f);
la[1,0] = new ComplexFloat(3.3f, 3.3f);
la[1,1] = new ComplexFloat(4.4f, -4.4f);
la[2,0] = new ComplexFloat(5.5f, 5.5f);
la[2,1] = new ComplexFloat(6.6f, -6.6f);
la[3,0] = new ComplexFloat(7.7f, 7.7f);
la[3,1] = new ComplexFloat(8.8f, -8.8f);
lsvd = new ComplexFloatSVDDecomp(la, true);
}