本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Single.SparseMatrix.SetRow方法的典型用法代码示例。如果您正苦于以下问题:C# SparseMatrix.SetRow方法的具体用法?C# SparseMatrix.SetRow怎么用?C# SparseMatrix.SetRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MathNet.Numerics.LinearAlgebra.Single.SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix.SetRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertRow
/// <summary>
/// Creates a new <see cref="SparseMatrix"/> and inserts the given row at the given index.
/// </summary>
/// <param name="rowIndex">The index of where to insert the row.</param>
/// <param name="row">The row to insert.</param>
/// <returns>A new <see cref="SparseMatrix"/> with the inserted column.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="row"/> is <see langword="null" />. </exception>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="rowIndex"/> is < zero or > the number of rows.</exception>
/// <exception cref="ArgumentException">If the size of <paramref name="row"/> != the number of columns.</exception>
public override Matrix<float> InsertRow(int rowIndex, Vector<float> row)
{
if (row == null)
{
throw new ArgumentNullException("row");
}
if (rowIndex < 0 || rowIndex > RowCount)
{
throw new ArgumentOutOfRangeException("rowIndex");
}
if (row.Count != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "row");
}
var result = new SparseMatrix(RowCount + 1, ColumnCount);
for (var i = 0; i < rowIndex; i++)
{
result.At(i, i, At(i, i));
}
result.SetRow(rowIndex, row);
for (var i = rowIndex + 1; i < result.RowCount; i++)
{
result.At(i, i - 1, At(i - 1, i - 1));
}
return result;
}