本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Complex.DenseVector类的典型用法代码示例。如果您正苦于以下问题:C# DenseVector类的具体用法?C# DenseVector怎么用?C# DenseVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DenseVector类属于MathNet.Numerics.LinearAlgebra.Complex命名空间,在下文中一共展示了DenseVector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HeapSortWithDecreasingDoubleArray
public void HeapSortWithDecreasingDoubleArray()
{
var sortedIndices = new int[10];
Vector<Complex> 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);
}
}
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:25,代码来源:IluptElementSorterTest.cs
示例2: SolveWideMatrixThrowsArgumentException
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
var input = new DenseVector(2);
var solver = new TFQMR();
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:8,代码来源:TFQMRTest.cs
示例3: SolveLongMatrixThrowsArgumentException
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
var input = new DenseVector(3);
var solver = new BiCgStab();
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
开发者ID:jafffy,项目名称:mathnet-numerics,代码行数:8,代码来源:BiCgStabTest.cs
示例4: SolveLongMatrixThrowsArgumentException
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
var input = new DenseVector(3);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
}
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:8,代码来源:TFQMRTest.cs
示例5: SolveWideMatrixThrowsArgumentException
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
var input = new DenseVector(2);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
}
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:8,代码来源:GpBiCgTest.cs
示例6: 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;
}
开发者ID:larzw,项目名称:mathnet-numerics,代码行数:15,代码来源:PreConditionerTest.cs
示例7: 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<Complex> CreateVector(IList<Complex> data)
{
var vector = new DenseVector(data.Count);
for (var index = 0; index < data.Count; index++)
{
vector[index] = data[index];
}
return vector;
}
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:15,代码来源:DenseVectorTests.cs
示例8: DetermineStatus
public void DetermineStatus()
{
var criterium = new FailureStopCriterium();
Assert.IsNotNull(criterium, "There should be a criterium");
var solution = new DenseVector(new[] {new Complex(3.0, 0), new Complex(2.0, 0), new Complex(1, 0)});
var source = new DenseVector(new[] {new Complex(1001.0, 0), Complex.Zero, new Complex(2003.0, 0)});
var residual = new DenseVector(new[] {new Complex(1.0, 0), new Complex(2.0, 0), new Complex(3, 0)});
var status = criterium.DetermineStatus(5, solution, source, residual);
Assert.AreEqual(IterationStatus.Continue, status, "Should be running");
}
开发者ID:TransientResponse,项目名称:mathnet-numerics,代码行数:12,代码来源:FailureStopCriteriumTest.cs
示例9: CanAddTwoDenseVectorsUsingOperator
public void CanAddTwoDenseVectorsUsingOperator()
{
var vector = new DenseVector(Data);
var other = new DenseVector(Data);
var result = vector + other;
CollectionAssert.AreEqual(Data, vector, "Making sure the original vector wasn't modified.");
CollectionAssert.AreEqual(Data, other, "Making sure the original vector wasn't modified.");
for (var i = 0; i < Data.Length; i++)
{
Assert.AreEqual(Data[i]*2.0, result[i]);
}
}
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:13,代码来源:DenseVectorTests.cs
示例10: 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);
}
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:14,代码来源:PreConditionerTest.cs
示例11: CanCreateDenseVectorFromArray
public void CanCreateDenseVectorFromArray()
{
var data = new Complex[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] = new Complex(10.0, 1);
Assert.AreEqual(new Complex(10.0, 1), data[0]);
}
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:14,代码来源:DenseVectorTests.cs
示例12: CanMultiplyWithVector
public void CanMultiplyWithVector()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex(1, 1), new Complex(2, 1), new Complex(3, 1) });
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]);
}
}
开发者ID:jafffy,项目名称:mathnet-numerics,代码行数:15,代码来源:MatrixTests.Arithmetic.cs
示例13: 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<Complex> preconditioner, SparseMatrix matrix, Vector<Complex> vector, Vector<Complex> result)
{
Assert.AreEqual(typeof(Diagonal), 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(vector[i].Real.AlmostEqual(product[i].Real, -Epsilon.Magnitude()), "#02-" + i);
Assert.IsTrue(vector[i].Imaginary.AlmostEqual(product[i].Imaginary, -Epsilon.Magnitude()), "#03-" + i);
}
}
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:22,代码来源:DiagonalTest.cs
示例14: CanSolveForRandomVectorWhenResultVectorGiven
public void CanSolveForRandomVectorWhenResultVectorGiven(int row, int column)
{
var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column);
var matrixACopy = matrixA.Clone();
var factorSvd = matrixA.Svd();
var vectorb = MatrixLoader.GenerateRandomDenseVector(row);
var vectorbCopy = vectorb.Clone();
var resultx = new DenseVector(column);
factorSvd.Solve(vectorb, resultx);
var matrixBReconstruct = matrixA*resultx;
// Check the reconstruction.
for (var i = 0; i < vectorb.Count; i++)
{
AssertHelpers.AlmostEqual(vectorb[i], matrixBReconstruct[i], 9);
}
// Make sure A didn't change.
for (var i = 0; i < matrixA.RowCount; i++)
{
for (var j = 0; j < matrixA.ColumnCount; j++)
{
Assert.AreEqual(matrixACopy[i, j], matrixA[i, j]);
}
}
// Make sure b didn't change.
for (var i = 0; i < vectorb.Count; i++)
{
Assert.AreEqual(vectorbCopy[i], vectorb[i]);
}
}
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:33,代码来源:SvdTests.cs
示例15: CanCallUnaryNegationOperatorOnDenseVector
public void CanCallUnaryNegationOperatorOnDenseVector()
{
var vector = new DenseVector(Data);
var other = -vector;
for (var i = 0; i < Data.Length; i++)
{
Assert.AreEqual(-Data[i], other[i]);
}
}
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:9,代码来源:DenseVectorTests.cs
示例16: CanMultiplyDenseVectorByScalarUsingOperators
public void CanMultiplyDenseVectorByScalarUsingOperators()
{
var vector = new DenseVector(Data);
vector = vector*new Complex(2.0, 1);
for (var i = 0; i < Data.Length; i++)
{
Assert.AreEqual(Data[i]*new Complex(2.0, 1), vector[i]);
}
vector = vector*1.0;
for (var i = 0; i < Data.Length; i++)
{
Assert.AreEqual(Data[i]*new Complex(2.0, 1), vector[i]);
}
vector = new DenseVector(Data);
vector = new Complex(2.0, 1)*vector;
for (var i = 0; i < Data.Length; i++)
{
Assert.AreEqual(Data[i]*new Complex(2.0, 1), vector[i]);
}
vector = 1.0*vector;
for (var i = 0; i < Data.Length; i++)
{
Assert.AreEqual(Data[i]*new Complex(2.0, 1), vector[i]);
}
}
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:30,代码来源:DenseVectorTests.cs
示例17: CanDivideDenseVectorByComplexUsingOperators
public void CanDivideDenseVectorByComplexUsingOperators()
{
var vector = new DenseVector(Data);
vector = vector/new Complex(2.0, 1);
for (var i = 0; i < Data.Length; i++)
{
AssertHelpers.AlmostEqual(Data[i]/new Complex(2.0, 1), vector[i], 14);
}
vector = vector/1.0;
for (var i = 0; i < Data.Length; i++)
{
AssertHelpers.AlmostEqual(Data[i]/new Complex(2.0, 1), vector[i], 14);
}
}
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:16,代码来源:DenseVectorTests.cs
示例18: CanCreateDenseVectorFromAnotherDenseVector
public void CanCreateDenseVectorFromAnotherDenseVector()
{
var vector = new DenseVector(Data);
var other = DenseVector.OfVector(vector);
Assert.AreNotSame(vector, other);
for (var i = 0; i < Data.Length; i++)
{
Assert.AreEqual(vector[i], other[i]);
}
}
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:11,代码来源:DenseVectorTests.cs
示例19: TryParse
/// <summary>
/// Converts the string representation of a complex dense vector to double-precision dense vector equivalent.
/// A return value indicates whether the conversion succeeded or failed.
/// </summary>
/// <param name="value">
/// A string containing a complex vector to convert.
/// </param>
/// <param name="result">
/// The parsed value.
/// </param>
/// <returns>
/// If the conversion succeeds, the result will contain a complex number equivalent to value.
/// Otherwise the result will be <c>null</c>.
/// </returns>
public static bool TryParse(string value, out DenseVector result)
{
return TryParse(value, null, out result);
}
开发者ID:cdrnet,项目名称:mathnet-numerics-native,代码行数:18,代码来源:DenseVector.cs
示例20: OuterProduct
/// <summary>
/// Outer product of two vectors
/// </summary>
/// <param name="u">First vector</param>
/// <param name="v">Second vector</param>
/// <returns>Matrix M[i,j] = u[i]*v[j] </returns>
/// <exception cref="ArgumentNullException">If the u vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the v vector is <see langword="null" />.</exception>
public static DenseMatrix OuterProduct(DenseVector u, DenseVector v)
{
if (u == null)
{
throw new ArgumentNullException("u");
}
if (v == null)
{
throw new ArgumentNullException("v");
}
var matrix = new DenseMatrix(u.Count, v.Count);
CommonParallel.For(
0,
u.Count,
i =>
{
for (var j = 0; j < v.Count; j++)
{
matrix.At(i, j, u._values[i] * v._values[j]);
}
});
return matrix;
}
开发者ID:cdrnet,项目名称:mathnet-numerics-native,代码行数:33,代码来源:DenseVector.cs
注:本文中的MathNet.Numerics.LinearAlgebra.Complex.DenseVector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论