本文整理汇总了C#中ResidualStopCriterium类的典型用法代码示例。如果您正苦于以下问题:C# ResidualStopCriterium类的具体用法?C# ResidualStopCriterium怎么用?C# ResidualStopCriterium使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResidualStopCriterium类属于命名空间,在下文中一共展示了ResidualStopCriterium类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public void Create()
{
var criterium = new ResidualStopCriterium<float>(1e-6f, 50);
Assert.AreEqual(1e-6f, criterium.Maximum, "Incorrect maximum");
Assert.AreEqual(50, criterium.MinimumIterationsBelowMaximum, "Incorrect iteration count");
}
示例2: ResetMaximum
public void ResetMaximum()
{
var criterium = new ResidualStopCriterium(1e-8, 50);
Assert.IsNotNull(criterium, "There should be a criterium");
criterium.ResetMaximumResidualToDefault();
Assert.AreEqual(ResidualStopCriterium.DefaultMaximumResidual, criterium.Maximum, "Incorrect maximum");
}
示例3: Create
public void Create()
{
var criterium = new ResidualStopCriterium(1e-8, 50);
Assert.IsNotNull(criterium, "There should be a criterium");
Assert.AreEqual(1e-8, criterium.Maximum, "Incorrect maximum");
Assert.AreEqual(50, criterium.MinimumIterationsBelowMaximum, "Incorrect iteration count");
}
示例4: DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException
public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
{
var criterium = new ResidualStopCriterium<Complex32>(1e-6f, 50);
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(
-1,
DenseVector.Create(3, i => 4),
DenseVector.Create(3, i => 5),
DenseVector.Create(3, i => 6)));
}
示例5: Clone
public void Clone()
{
var criterium = new ResidualStopCriterium<Complex32>(1e-3f, 10);
var clone = criterium.Clone();
Assert.IsInstanceOf(typeof(ResidualStopCriterium<Complex32>), clone, "Wrong criterium type");
var clonedCriterium = clone as ResidualStopCriterium<Complex32>;
Assert.IsNotNull(clonedCriterium);
Assert.AreEqual(criterium.Maximum, clonedCriterium.Maximum, "Clone failed");
Assert.AreEqual(criterium.MinimumIterationsBelowMaximum, clonedCriterium.MinimumIterationsBelowMaximum, "Clone failed");
}
示例6: Clone
public void Clone()
{
var criterium = new ResidualStopCriterium(1e-3, 10);
Assert.IsNotNull(criterium, "There should be a criterium");
var clone = criterium.Clone();
Assert.IsInstanceOfType(typeof(ResidualStopCriterium), clone, "Wrong criterium type");
var clonedCriterium = clone as ResidualStopCriterium;
Assert.IsNotNull(clonedCriterium);
// ReSharper disable PossibleNullReferenceException
Assert.AreEqual(criterium.Maximum, clonedCriterium.Maximum, "Clone failed");
Assert.AreEqual(criterium.MinimumIterationsBelowMaximum, clonedCriterium.MinimumIterationsBelowMaximum, "Clone failed");
// ReSharper restore PossibleNullReferenceException
}
示例7: DetermineStatus
public void DetermineStatus()
{
var criterium = new ResidualStopCriterium(1e-3, 10);
Assert.IsNotNull(criterium, "There should be a criterium");
// Note that the solution vector isn't actually being used so ...
var solution = new DenseVector(new[] { double.NaN, double.NaN, double.NaN });
// Set the source values
var source = new DenseVector(new[] { 1.000, 1.000, 2.001 });
// Set the residual values
var residual = new DenseVector(new[] { 0.001, 0.001, 0.002 });
criterium.DetermineStatus(5, solution, source, residual);
Assert.IsInstanceOfType(typeof(CalculationRunning), criterium.Status, "Should still be running");
criterium.DetermineStatus(16, solution, source, residual);
Assert.IsInstanceOfType(typeof(CalculationConverged), criterium.Status, "Should be done");
}
示例8: DetermineStatusWithNonMatchingSourceVectorThrowsArgumentException
public void DetermineStatusWithNonMatchingSourceVectorThrowsArgumentException()
{
var criterium = new ResidualStopCriterium<float>(1e-6f, 50);
Assert.Throws<ArgumentException>(() => criterium.DetermineStatus(
1,
Vector<float>.Build.Dense(3, 4),
Vector<float>.Build.Dense(4, 4),
Vector<float>.Build.Dense(3, 4)));
}
示例9: DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException
public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
{
var criterium = new ResidualStopCriterium<float>(1e-6f, 50);
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(
-1,
Vector<float>.Build.Dense(3, 4),
Vector<float>.Build.Dense(3, 5),
Vector<float>.Build.Dense(3, 6)));
}
示例10: DetermineStatusWithNonMatchingSolutionVector
public void DetermineStatusWithNonMatchingSolutionVector()
{
var criterium = new ResidualStopCriterium(1e-8, 50);
Assert.IsNotNull(criterium, "There should be a criterium");
criterium.DetermineStatus(1,
new DenseVector(4, 4),
new DenseVector(3, 4),
new DenseVector(3, 4));
}
示例11: ResetMinimumIterationsBelowMaximum
public void ResetMinimumIterationsBelowMaximum()
{
var criterium = new ResidualStopCriterium(1e-8, 50);
Assert.IsNotNull(criterium, "There should be a criterium");
criterium.ResetMinimumIterationsBelowMaximumToDefault();
Assert.AreEqual(ResidualStopCriterium.DefaultMinimumIterationsBelowMaximum, criterium.MinimumIterationsBelowMaximum, "Incorrect iteration count");
}
示例12: DetermineStatusWithSourceNaN
public void DetermineStatusWithSourceNaN()
{
var criterium = new ResidualStopCriterium(1e-3, 10);
Assert.IsNotNull(criterium, "There should be a criterium");
var solution = new DenseVector(new[] { 1.0, 1.0, 2.0 });
var source = new DenseVector(new[] { 1.0, 1.0, double.NaN });
var residual = new DenseVector(new[] { 1000.0, 1000.0, 2001.0 });
criterium.DetermineStatus(5, solution, source, residual);
Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Should be diverged");
}
示例13: DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException
public void DetermineStatusWithIllegalIterationNumberThrowsArgumentOutOfRangeException()
{
var criterium = new ResidualStopCriterium(1e-8, 50);
Assert.IsNotNull(criterium, "There should be a criterium");
Assert.Throws<ArgumentOutOfRangeException>(() => criterium.DetermineStatus(
-1,
new DenseVector(3, 4),
new DenseVector(3, 5),
new DenseVector(3, 6)));
}
示例14: ResetCalculationState
public void ResetCalculationState()
{
var criterium = new ResidualStopCriterium<Complex>(1e-3, 10);
var solution = new DenseVector(new[] {new Complex(0.001, 1), new Complex(0.001, 1), new Complex(0.002, 1)});
var source = new DenseVector(new[] {new Complex(0.001, 1), new Complex(0.001, 1), new Complex(0.002, 1)});
var residual = new DenseVector(new[] {new Complex(1.000, 0), new Complex(1.000, 0), new Complex(2.001, 0)});
var status = criterium.DetermineStatus(5, solution, source, residual);
Assert.AreEqual(IterationStatus.Continue, status, "Should be running");
criterium.Reset();
Assert.AreEqual(IterationStatus.Continue, criterium.Status, "Should not have started");
}
示例15: DetermineStatusWithSourceNaN
public void DetermineStatusWithSourceNaN()
{
var criterium = new ResidualStopCriterium(1e-3f, 10);
Assert.IsNotNull(criterium, "There should be a criterium");
var solution = new DenseVector(new[] { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) });
var source = new DenseVector(new[] { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(float.NaN, 1) });
var residual = new DenseVector(new[] { new Complex32(1000.0f, 1), new Complex32(1000.0f, 1), new Complex32(2001.0f, 1) });
criterium.DetermineStatus(5, solution, source, residual);
Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Should be diverged");
}