Пример #1
0
 static void Main(string[] args)
 {
     System.Console.WriteLine("Sparse Array -> ");
     SparseArrays.execute();
     System.Console.WriteLine("\n\nLinked List Operations-> ");
     LinkedList.execute();
 }
        public void matchinString_Test01()
        {
            SparseArrays obj = new SparseArrays();

            var expected = new int[] { 2, 1, 0 };
            var actual   = obj.matchingStrings(new string[] { "aba", "baba", "aba", "xzxb" }, new string[] { "aba", "xzxb", "ab" });

            for (int i = 0; i < actual.Length; i++)
            {
                Assert.Equal(actual[i], expected[i]);
            }
        }
Пример #3
0
        /// <summary>
        /// Creates a new <see cref="CscMatrix"/> instance, that is transpose to this: result[i, j] = this[j, i].
        /// </summary>
        public CscMatrix TransposeToCSC()
        {
            // Use C# port of the scipy method.
            // TODO: Perhaps it could be done faster by making extra assumptions. Otherwise use SparseBLAS
            int nnz           = this.values.Length;
            var csrValues     = new double[nnz];
            var csrColIndices = new int[nnz];
            var csrRowOffsets = new int[NumRows + 1];

            SparseArrays.CsrToCsc(NumColumns, NumRows, this.colOffsets, this.rowIndices, this.values,
                                  csrRowOffsets, csrColIndices, csrValues);

            return(new CscMatrix(NumColumns, NumRows, csrValues, csrColIndices, csrRowOffsets));
        }