本文整理汇总了C#中SparseMatrix.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# SparseMatrix.RemoveAt方法的具体用法?C# SparseMatrix.RemoveAt怎么用?C# SparseMatrix.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix.RemoveAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
matrix[2, 3] = "m";
matrix[3][4] = "n";
Console.WriteLine(matrix.ToString("E"));
// check for items
Console.WriteLine("Check for items ...");
Console.WriteLine(matrix.ContainsAt(0, 1));
Console.WriteLine(matrix.ContainsAt(1, 1));
Console.WriteLine(matrix.Contains("c"));
Console.WriteLine(matrix.Contains("C"));
int rowIdx = -1, colIdx = -1;
matrix.IndexOf("c", ref rowIdx, ref colIdx);
Console.WriteLine("{0}, {1}", rowIdx, colIdx);
// check for rows and columns
Console.WriteLine("Check for rows and columns ...");
Console.WriteLine(matrix.ContainsColAt(0));
Console.WriteLine(matrix.ContainsColAt(100));
Console.WriteLine(matrix.ContainsRowAt(0));
Console.WriteLine(matrix.ContainsRowAt(100));
// get first and last non-empty row and column index
Console.WriteLine("Get first and last non-empty row and column index ...");
Console.WriteLine(matrix.GetFirstNonEmptyRowIdx());
Console.WriteLine(matrix.GetLastNonEmptyRowIdx());
Console.WriteLine(matrix.GetFirstNonEmptyColIdx());
Console.WriteLine(matrix.GetLastNonEmptyColIdx());
// get first and last item in row
Console.WriteLine("Get first and last item in row ...");
Console.WriteLine(matrix[0].First);
Console.WriteLine(matrix[3].Last);
// create another SparseMatrix
Console.WriteLine("Create another SparseMatrix ...");
SparseMatrix<string> matrix2 = new SparseMatrix<string>();
matrix2[0] = new SparseVector<string>(new IdxDat<string>[] {
new IdxDat<string>(0, "A"),
new IdxDat<string>(2, "B"),
new IdxDat<string>(3, "C") });
matrix2[2] = new SparseVector<string>(new IdxDat<string>[] {
new IdxDat<string>(1, "D"),
new IdxDat<string>(3, "E") });
matrix2[3] = new SparseVector<string>(new IdxDat<string>[] {
new IdxDat<string>(0, "G"),
new IdxDat<string>(1, "H"),
new IdxDat<string>(2, "I") });
Console.WriteLine(matrix2.ToString("E"));
// concatenate
Console.WriteLine("Concatenate ...");
matrix.AppendCols(matrix2, matrix.GetLastNonEmptyColIdx() + 1);
Console.WriteLine(matrix.ToString("E"));
// remove items
Console.WriteLine("Remove items ...");
matrix.RemoveAt(0, 1);
matrix.RemoveAt(3, 5);
Console.WriteLine(matrix.ToString("E"));
// directly access to items
Console.WriteLine("Directly access to items ...");
int idx = matrix[0].GetDirectIdx(4);
Console.WriteLine(idx);
Console.WriteLine(matrix[0].GetDirect(idx));
matrix[0].SetDirect(idx, "C");
Console.WriteLine(matrix[1].GetDirect(0));
matrix[1].RemoveDirect(0);
Console.WriteLine(matrix.ToString("E"));
// get properties
Console.WriteLine("Get properties ...");
Console.WriteLine("{0:0.00}%", matrix.GetSparseness(matrix.GetLastNonEmptyRowIdx() + 1, matrix.GetLastNonEmptyColIdx() + 1) * 100.0);
Console.WriteLine(matrix.IsSymmetric());
Console.WriteLine(matrix.ContainsDiagonalElement());
Console.WriteLine(matrix.CountValues());
// perform unary operation
Console.WriteLine("Perform unary operation ...");
matrix.PerformUnaryOperation(delegate(string item) { return item.ToUpper(); });
Console.WriteLine(matrix.ToString("E"));
// merge
Console.WriteLine("Merge ...");
matrix.Merge(matrix2, delegate(string a, string b) { return string.Format("{0}+{1}", a, b); });
Console.WriteLine(matrix.ToString("E"));
// clear row and column
Console.WriteLine("Clear row and column ...");
matrix.RemoveRowAt(2);
matrix.RemoveColAt(1);
Console.WriteLine(matrix.ToString("E"));
// purge row and column
Console.WriteLine("Purge row and column ...");
matrix.PurgeRowAt(2);
matrix.PurgeColAt(1);
Console.WriteLine(matrix.ToString("E"));
// get column copy
Console.WriteLine("Get column copy ...");
Console.WriteLine(matrix.GetColCopy(0));
// transpose
Console.WriteLine("Transpose ...");
Console.WriteLine(matrix.GetTransposedCopy().ToString("E"));
// set diagonal
Console.WriteLine("Set diagonal ...");
matrix.SetDiagonal(matrix.GetLastNonEmptyColIdx() + 1, "X");
Console.WriteLine(matrix.ToString("E"));
// make symmetric
Console.WriteLine("Make symmetric ...");
matrix.Symmetrize(delegate(string a, string b) { return string.Format("{0}+{1}", a, b); });
Console.WriteLine(matrix.ToString("E"));
}