|
|
|
@ -36,155 +36,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
|
|
|
/// </summary>
|
|
|
|
public abstract partial class MatrixTests : MatrixLoader |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Get a row at specific start position and length of a matrix into a too small vector throws <c>ArgumentException</c>.
|
|
|
|
/// </summary>
|
|
|
|
[Test] |
|
|
|
public void GetRowWithRangeIntoTooSmallResultVectorThrowsArgumentException() |
|
|
|
{ |
|
|
|
var matrix = TestMatrices["Singular3x3"]; |
|
|
|
var result = CreateVector(matrix.ColumnCount - 1); |
|
|
|
Assert.Throws<ArgumentException>(() => matrix.Row(0, 0, 0, result)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Can get a column of a matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="colIndex">Row index.</param>
|
|
|
|
/// <param name="name">Matrix name.</param>
|
|
|
|
[TestCase(0, "Singular3x3")] |
|
|
|
[TestCase(1, "Square3x3")] |
|
|
|
[TestCase(2, "Square3x3")] |
|
|
|
public void CanGetColumn(int colIndex, string name) |
|
|
|
{ |
|
|
|
var matrix = TestMatrices[name]; |
|
|
|
var col = matrix.Column(colIndex); |
|
|
|
|
|
|
|
Assert.AreEqual(matrix.RowCount, col.Count); |
|
|
|
for (var j = 0; j < matrix.RowCount; j++) |
|
|
|
{ |
|
|
|
Assert.AreEqual(matrix[j, colIndex], col[j]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get a column with negative index throws <c>ArgumentOutOfRangeException</c>.
|
|
|
|
/// </summary>
|
|
|
|
[Test] |
|
|
|
public void GetColumnWithNegativeIndexThrowsArgumentOutOfRangeException() |
|
|
|
{ |
|
|
|
var matrix = TestMatrices["Singular3x3"]; |
|
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Column(-1)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get column with overflowing row index throws <c>ArgumentOutOfRangeException</c>.
|
|
|
|
/// </summary>
|
|
|
|
[Test] |
|
|
|
public void GetColumnWithOverflowingRowIndexThrowsArgumentOutOfRangeException() |
|
|
|
{ |
|
|
|
var matrix = TestMatrices["Singular3x3"]; |
|
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Column(matrix.ColumnCount)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Can get a column into a result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="colIndex">Column index.</param>
|
|
|
|
/// <param name="name">Matrix name.</param>
|
|
|
|
[TestCase(0, "Singular3x3")] |
|
|
|
[TestCase(1, "Square3x3")] |
|
|
|
[TestCase(2, "Square3x3")] |
|
|
|
public void CanGetColumnIntoResult(int colIndex, string name) |
|
|
|
{ |
|
|
|
var matrix = TestMatrices[name]; |
|
|
|
var col = CreateVector(matrix.RowCount); |
|
|
|
matrix.Column(colIndex, col); |
|
|
|
|
|
|
|
Assert.AreEqual(matrix.RowCount, col.Count); |
|
|
|
for (var j = 0; j < matrix.RowCount; j++) |
|
|
|
{ |
|
|
|
Assert.AreEqual(matrix[j, colIndex], col[j]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get a column when result vector is <c>null</c> throws <c>ArgumentNullException</c>.
|
|
|
|
/// </summary>
|
|
|
|
[Test] |
|
|
|
public void GetColumnWhenResultIsNullThrowsArgumentNullException() |
|
|
|
{ |
|
|
|
var matrix = TestMatrices["Singular3x3"]; |
|
|
|
Assert.Throws<ArgumentNullException>(() => matrix.Column(0, null)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get a column into result vector with negative index throws <c>ArgumentOutOfRangeException</c>.
|
|
|
|
/// </summary>
|
|
|
|
[Test] |
|
|
|
public void GetColumnIntoResultWithNegativeIndexThrowsArgumentOutOfRangeException() |
|
|
|
{ |
|
|
|
var matrix = TestMatrices["Singular3x3"]; |
|
|
|
var column = CreateVector(matrix.ColumnCount); |
|
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Column(-1, column)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get a column into result with overflowing row index throws <c>ArgumentOutOfRangeException</c>.
|
|
|
|
/// </summary>
|
|
|
|
[Test] |
|
|
|
public void GetColumnIntoResultWithOverflowingRowIndexThrowsArgumentOutOfRangeException() |
|
|
|
{ |
|
|
|
var matrix = TestMatrices["Singular3x3"]; |
|
|
|
var column = CreateVector(matrix.RowCount); |
|
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => matrix.Row(matrix.ColumnCount, column)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Can get a column with range.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="colIndex">Column index.</param>
|
|
|
|
/// <param name="start">Start index.</param>
|
|
|
|
/// <param name="length">Column length.</param>
|
|
|
|
/// <param name="name">Matrix name.</param>
|
|
|
|
[TestCase(0, 0, 1, "Singular3x3")] |
|
|
|
[TestCase(1, 1, 2, "Singular3x3")] |
|
|
|
[TestCase(2, 0, 3, "Singular3x3")] |
|
|
|
[TestCase(2, 0, 3, "Square3x3")] |
|
|
|
public void CanGetColumnWithRange(int colIndex, int start, int length, string name) |
|
|
|
{ |
|
|
|
var matrix = TestMatrices[name]; |
|
|
|
var col = matrix.Column(colIndex, start, length); |
|
|
|
|
|
|
|
Assert.AreEqual(length, col.Count); |
|
|
|
for (var j = start; j < start + length; j++) |
|
|
|
{ |
|
|
|
Assert.AreEqual(matrix[j, colIndex], col[j - start]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get a column range into a result vector when length is zero throws <c>ArgumentException</c>.
|
|
|
|
/// </summary>
|
|
|
|
[Test] |
|
|
|
public void GetColumnRangeIntoResultWhenLengthIsZeroThrowsArgumentException() |
|
|
|
{ |
|
|
|
var matrix = TestMatrices["Singular3x3"]; |
|
|
|
var col = CreateVector(matrix.RowCount); |
|
|
|
Assert.Throws<ArgumentException>(() => matrix.Column(0, 0, 0, col)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get a column range into too small result vector throws <c>ArgumentException</c>.
|
|
|
|
/// </summary>
|
|
|
|
[Test] |
|
|
|
public void GetColumnRangeIntoTooSmallResultVectorThrowsArgumentException() |
|
|
|
{ |
|
|
|
var matrix = TestMatrices["Singular3x3"]; |
|
|
|
var result = CreateVector(matrix.RowCount - 1); |
|
|
|
Assert.Throws<ArgumentException>(() => matrix.Column(0, 0, matrix.RowCount, result)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Can set a row.
|
|
|
|
/// </summary>
|
|
|
|
|