本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Complex32.DenseVector类的典型用法代码示例。如果您正苦于以下问题:C# DenseVector类的具体用法?C# DenseVector怎么用?C# DenseVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DenseVector类属于MathNet.Numerics.LinearAlgebra.Complex32命名空间,在下文中一共展示了DenseVector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SolveLongMatrixThrowsArgumentException
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
var input = new DenseVector(3);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => matrix.SolveIterative(input, solver));
}
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:8,代码来源:BiCgStabTest.cs
示例2: 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));
}
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:8,代码来源:TFQMRTest.cs
示例3: SolveWideMatrixThrowsArgumentException
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
var input = new DenseVector(2);
var solver = new GpBiCg();
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
开发者ID:larzw,项目名称:mathnet-numerics,代码行数:8,代码来源:GpBiCgTest.cs
示例4: SolveLongMatrixThrowsArgumentException
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
var input = new DenseVector(3);
var solver = new TFQMR();
Assert.That(() => matrix.SolveIterative(input, solver), Throws.ArgumentException);
}
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:8,代码来源:TFQMRTest.cs
示例5: 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,代码行数:14,代码来源:PreConditionerTest.cs
示例6: 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<Complex32> CreateVector(IList<Complex32> data)
{
var vector = new DenseVector(data.Count);
for (var index = 0; index < data.Count; index++)
{
vector[index] = data[index];
}
return vector;
}
开发者ID:larzw,项目名称:mathnet-numerics,代码行数:15,代码来源:DenseVectorTests.cs
示例7: 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.0f, result[i]);
}
}
开发者ID:skair39,项目名称:mathnet-numerics,代码行数:13,代码来源:DenseVectorTests.cs
示例8: 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<Complex32> preconditioner, SparseMatrix matrix, Vector<Complex32> vector, Vector<Complex32> 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(vector[i].Real.AlmostEqualNumbersBetween(product[i].Real, -Epsilon.Magnitude()), "#02-" + i);
Assert.IsTrue(vector[i].Imaginary.AlmostEqualNumbersBetween(product[i].Imaginary, -Epsilon.Magnitude()), "#03-" + i);
}
}
开发者ID:EricGT,项目名称:mathnet-numerics,代码行数:21,代码来源:DiagonalTest.cs
示例9: 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:nakamoton,项目名称:mathnet-numerics,代码行数:14,代码来源:PreConditionerTest.cs
示例10: CanCreateDenseVectorFromArray
public void CanCreateDenseVectorFromArray()
{
var data = new Complex32[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 Complex32(10.0f, 1);
Assert.AreEqual(new Complex32(10.0f, 1), data[0]);
}
开发者ID:larzw,项目名称:mathnet-numerics,代码行数:14,代码来源:DenseVectorTests.cs
示例11: CanMultiplyWithVector
public void CanMultiplyWithVector()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(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:larzw,项目名称:mathnet-numerics,代码行数:15,代码来源:MatrixTests.Arithmetic.cs
示例12: 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="formatProvider">
/// An <see cref="IFormatProvider"/> that supplies culture-specific formatting information about value.
/// </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, IFormatProvider formatProvider, out DenseVector result)
{
bool ret;
try
{
result = Parse(value, formatProvider);
ret = true;
}
catch (ArgumentNullException)
{
result = null;
ret = false;
}
catch (FormatException)
{
result = null;
ret = false;
}
return ret;
}
开发者ID:Rickasaurus,项目名称:mathnet-numerics,代码行数:38,代码来源:DenseVector.cs
示例13: CanDivideDenseVectorByComplexUsingOperators
public void CanDivideDenseVectorByComplexUsingOperators()
{
var vector = new DenseVector(Data);
vector = vector/new Complex32(2.0f, 1);
for (var i = 0; i < Data.Length; i++)
{
AssertHelpers.AlmostEqualRelative(Data[i]/new Complex32(2.0f, 1), vector[i], 6);
}
vector = vector/1.0f;
for (var i = 0; i < Data.Length; i++)
{
AssertHelpers.AlmostEqualRelative(Data[i]/new Complex32(2.0f, 1), vector[i], 6);
}
}
开发者ID:skair39,项目名称:mathnet-numerics,代码行数:16,代码来源:DenseVectorTests.cs
示例14: CanCreateDenseMatrix
public void CanCreateDenseMatrix()
{
var vector = new DenseVector(3);
var matrix = Matrix<Complex32>.Build.SameAs(vector, 2, 3);
Assert.IsInstanceOf<DenseMatrix>(matrix);
Assert.AreEqual(2, matrix.RowCount);
Assert.AreEqual(3, matrix.ColumnCount);
}
开发者ID:skair39,项目名称:mathnet-numerics,代码行数:8,代码来源:DenseVectorTests.cs
示例15: DoMultiply
/// <summary>
/// Multiplies this matrix with another matrix and places the results into the result matrix.
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
protected override void DoMultiply(Matrix<Complex32> other, Matrix<Complex32> result)
{
result.Clear();
var columnVector = new DenseVector(other.RowCount);
var rowPointers = _storage.RowPointers;
var columnIndices = _storage.ColumnIndices;
var values = _storage.Values;
for (var row = 0; row < RowCount; row++)
{
var startIndex = rowPointers[row];
var endIndex = rowPointers[row + 1];
if (startIndex == endIndex)
{
continue;
}
for (var column = 0; column < other.ColumnCount; column++)
{
// Multiply row of matrix A on column of matrix B
other.Column(column, columnVector);
var sum = Complex32.Zero;
for (var index = startIndex; index < endIndex; index++)
{
sum += values[index] * columnVector[columnIndices[index]];
}
result.At(row, column, sum);
}
}
}
开发者ID:smoothdeveloper,项目名称:mathnet-numerics,代码行数:39,代码来源:SparseMatrix.cs
示例16: DetermineStatus
public void DetermineStatus()
{
var criterium = new FailureStopCriterium<Complex32>();
Assert.IsNotNull(criterium, "There should be a criterium");
var solution = new DenseVector(new[] {new Complex32(3.0f, 0), new Complex32(2.0f, 0), new Complex32(1, 0)});
var source = new DenseVector(new[] {new Complex32(1001.0f, 0), Complex32.Zero, new Complex32(2003.0f, 0)});
var residual = new DenseVector(new[] {new Complex32(1.0f, 0), new Complex32(2.0f, 0), new Complex32(3, 0)});
var status = criterium.DetermineStatus(5, solution, source, residual);
Assert.AreEqual(IterationStatus.Continue, status, "Should be running");
}
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:12,代码来源:FailureStopCriteriumTest.cs
示例17: CanSolveForRandomVectorWhenResultVectorGiven
public void CanSolveForRandomVectorWhenResultVectorGiven(int order)
{
var matrixA = Matrix<Complex32>.Build.Random(order, order, 1);
var matrixACopy = matrixA.Clone();
var factorLU = matrixA.LU();
var vectorb = Vector<Complex32>.Build.Random(order, 1);
var vectorbCopy = vectorb.Clone();
var resultx = new DenseVector(order);
factorLU.Solve(vectorb, resultx);
Assert.AreEqual(vectorb.Count, resultx.Count);
var matrixBReconstruct = matrixA * resultx;
// Check the reconstruction.
for (var i = 0; i < vectorb.Count; i++)
{
Assert.AreEqual(vectorb[i].Real, matrixBReconstruct[i].Real, 1e-3f);
Assert.AreEqual(vectorb[i].Imaginary, matrixBReconstruct[i].Imaginary, 1e-3f);
}
// 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:skair39,项目名称:mathnet-numerics,代码行数:36,代码来源:LUTests.cs
示例18: DetermineStatusWithSolutionNaN
public void DetermineStatusWithSolutionNaN()
{
var criterium = new FailureStopCriterium<Complex32>();
Assert.IsNotNull(criterium, "There should be a criterium");
var solution = new DenseVector(new[] {new Complex32(1.0f, 0), new Complex32(1.0f, 0), new Complex32(float.NaN, 0)});
var source = new DenseVector(new[] {new Complex32(1001.0f, 0), Complex32.Zero, new Complex32(2003.0f, 0)});
var residual = new DenseVector(new[] {new Complex32(1000, 0), new Complex32(1000, 0), new Complex32(2001, 0)});
var status = criterium.DetermineStatus(5, solution, source, residual);
Assert.AreEqual(IterationStatus.Failure, status, "Should be failed");
}
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:12,代码来源:FailureStopCriteriumTest.cs
示例19: CanMultiplyWithVectorIntoResultWhenUpdatingInputArgument
public void CanMultiplyWithVectorIntoResultWhenUpdatingInputArgument()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1) });
var y = x;
matrix.Multiply(x, x);
Assert.AreSame(y, x);
y = new DenseVector(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1) });
for (var i = 0; i < matrix.RowCount; i++)
{
var ar = matrix.Row(i);
var dot = ar * y;
Assert.AreEqual(dot, x[i]);
}
}
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:17,代码来源:MatrixTests.Arithmetic.cs
示例20: SolveLongMatrixThrowsArgumentException
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
var input = new DenseVector(3);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
}
开发者ID:primebing,项目名称:mathnet-numerics,代码行数:8,代码来源:TFQMRTest.cs
注:本文中的MathNet.Numerics.LinearAlgebra.Complex32.DenseVector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论