本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Single.DenseVector类的典型用法代码示例。如果您正苦于以下问题:C# DenseVector类的具体用法?C# DenseVector怎么用?C# DenseVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DenseVector类属于MathNet.Numerics.LinearAlgebra.Single命名空间,在下文中一共展示了DenseVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HeapSortWithDecreasingDoubleArray
public void HeapSortWithDecreasingDoubleArray()
{
var sortedIndices = new int[10];
var values = new DenseVector(10);
values[0] = 9;
values[1] = 8;
values[2] = 7;
values[3] = 6;
values[4] = 5;
values[5] = 4;
values[6] = 3;
values[7] = 2;
values[8] = 1;
values[9] = 0;
for (var i = 0; i < sortedIndices.Length; i++)
{
sortedIndices[i] = i;
}
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(i, sortedIndices[i], "#01-" + i);
}
}
示例2: SolveWideMatrixThrowsArgumentException
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
var input = new DenseVector(2);
var solver = new MlkBiCgStab();
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
示例3: SolveLongMatrixThrowsArgumentException
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
var input = new DenseVector(3);
var solver = new GpBiCg();
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
示例4: ApproximateWithNonInitializedPreconditionerThrowsArgumentException
public void ApproximateWithNonInitializedPreconditionerThrowsArgumentException()
{
const int Size = 10;
var vector = CreateStandardBcVector(Size);
var preconditioner = CreatePreconditioner();
var result = new DenseVector(vector.Count);
Assert.Throws<ArgumentException>(() => preconditioner.Approximate(vector, result));
}
示例5: ComputeMecanumDriveMotorSpeed
private float ComputeMecanumDriveMotorSpeed(DenseVector desiredMovement, VectorComponent wheelForceVectorInput)
{
var wheelForceVector = new DenseVector(new[] { wheelForceVectorInput.X, wheelForceVectorInput.Y });
var wheelForceVectorUnit = wheelForceVector.Normalize(2);
var scale = wheelForceVectorUnit.DotProduct(desiredMovement);
// Console.WriteLine(wheelForceVector + " " + wheelForceVectorUnit + " " + desiredMovement + " " + scale);
return scale;
}
示例6: SolveWideMatrixThrowsArgumentException
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
var input = new DenseVector(2);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
}
示例7: SolveLongMatrixThrowsArgumentException
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
var input = new DenseVector(3);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
}
示例8: CreateStandardBcVector
/// <summary>
/// Create standard vector.
/// </summary>
/// <param name="size">Size of the vector.</param>
/// <returns>New vector.</returns>
protected DenseVector CreateStandardBcVector(int size)
{
var vector = new DenseVector(size);
for (var i = 0; i < size; i++)
{
vector[i] = i + 1;
}
return vector;
}
示例9: CreateVector
/// <summary>
/// Creates a new instance of the Vector class.
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new <c>Vector</c>.</returns>
protected override Vector<float> CreateVector(IList<float> data)
{
var vector = new DenseVector(data.Count);
for (var index = 0; index < data.Count; index++)
{
vector[index] = data[index];
}
return vector;
}
示例10: DetermineStatus
public void DetermineStatus()
{
var criterion = new FailureStopCriterion<float>();
Assert.IsNotNull(criterion, "There should be a criterion");
var solution = new DenseVector(new[] { 3.0f, 2.0f, 1.0f });
var source = new DenseVector(new[] { 1001.0f, 0.0f, 2003.0f });
var residual = new DenseVector(new[] { 1.0f, 2.0f, 3.0f });
var status = criterion.DetermineStatus(5, solution, source, residual);
Assert.AreEqual(IterationStatus.Continue, status, "Should be running");
}
示例11: CheckResult
/// <summary>
/// Check the result.
/// </summary>
/// <param name="preconditioner">Specific preconditioner.</param>
/// <param name="matrix">Source matrix.</param>
/// <param name="vector">Initial vector.</param>
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<float> preconditioner, SparseMatrix matrix, Vector<float> vector, Vector<float> result)
{
Assert.AreEqual(typeof (DiagonalPreconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)
{
Assert.IsTrue(((double) vector[i]).AlmostEqualNumbersBetween(product[i], -Epsilon.Magnitude()), "#02-" + i);
}
}
示例12: ApproximateReturningOldVector
public void ApproximateReturningOldVector()
{
const int Size = 10;
var newMatrix = CreateUnitMatrix(Size);
var vector = CreateStandardBcVector(Size);
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}
示例13: CanCreateDenseVectorFromArray
public void CanCreateDenseVectorFromArray()
{
var data = new float[Data.Length];
Array.Copy(Data, data, Data.Length);
var vector = new DenseVector(data);
for (var i = 0; i < data.Length; i++)
{
Assert.AreEqual(data[i], vector[i]);
}
vector[0] = 100.0f;
Assert.AreEqual(100.0f, data[0]);
}
示例14: MecanumDrive
public HolonomicDriveValues MecanumDrive(HolonomicDriveTrain driveTrain, float x, float y, bool inputsSquared = false)
{
x = InputUtilities.TransformWithWarning(x, square: inputsSquared);
y = InputUtilities.TransformWithWarning(y, square: inputsSquared);
var desiredMovement = new DenseVector(new [] { x, y });
// var desiredMovement = new DenseVector(new [] { 1f, 0f });
HolonomicDriveValues result = new HolonomicDriveValues();
result.FrontLeft = ComputeMecanumDriveMotorSpeed(desiredMovement, driveTrain.FrontLeft.GetComponent<VectorComponent>(DeviceComponentType.DriveWheelForceVector));
result.FrontRight = ComputeMecanumDriveMotorSpeed(desiredMovement, driveTrain.FrontRight.GetComponent<VectorComponent>(DeviceComponentType.DriveWheelForceVector));
result.RearLeft = ComputeMecanumDriveMotorSpeed(desiredMovement, driveTrain.RearLeft.GetComponent<VectorComponent>(DeviceComponentType.DriveWheelForceVector));
result.RearRight = ComputeMecanumDriveMotorSpeed(desiredMovement, driveTrain.RearRight.GetComponent<VectorComponent>(DeviceComponentType.DriveWheelForceVector));
return result;
}
示例15: CanMultiplyWithVector
public void CanMultiplyWithVector()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { 1.0f, 2.0f, 3.0f });
var y = matrix * x;
Assert.AreEqual(matrix.RowCount, y.Count);
for (var i = 0; i < matrix.RowCount; i++)
{
var ar = matrix.Row(i);
var dot = ar * x;
Assert.AreEqual(dot, y[i]);
}
}