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