Exemplo n.º 1
0
        /// <summary>
        /// 7. Работа с ленточными последовательностями элементов
        /// </summary>
        private static async Task DataSequencesBandTests()
        {
            using (SparseMatrixRepSeq sparseMatrixRepSeq = new SparseMatrixRepSeq("7"))
            {
                await sparseMatrixRepSeq.ClearAsync();

                Console.WriteLine(sparseMatrixRepSeq.GetNumSequences());
                // Объявляем последовательности элементов
                double[] seq0 = new double[] { -5.55, 0, 15, 211, 0.09 };
                double[] seq1 = new double[] { 1.1, 2.2, -0.6 };
                double[] seq2 = new double[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 };
                double[] seq3 = new double[] { 1000, 0, 15, 211, 0.09 };
                double[] seq4 = new double[] { -4.55, 4, 45, 411, 4.09, 43.98, 4, -4, -44.432 };
                #region Добавление последовательностей
                Console.WriteLine("Добавление последовательности double[] seq0 = new double[] { -5.55, 0, 15, 211, 0.09 };");
                int seqIndex0 = await sparseMatrixRepSeq.AddSequence(seq0);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                Console.WriteLine("Добавление последовательности double[] seq1 = new double[] { 1.1, 2.2, -0.6 };");
                int seqIndex1 = await sparseMatrixRepSeq.AddSequence(seq1);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                Console.WriteLine("Добавление последовательности double[] seq2 = new double[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 };");
                int seqIndex2 = await sparseMatrixRepSeq.AddSequence(seq2);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                Console.WriteLine("Добавление последовательности double[] seq3 = new double[] { 1000, 0, 15, 211, 0.09 };");
                int seqIndex3 = await sparseMatrixRepSeq.AddSequence(seq3);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                Console.WriteLine("Добавление последовательности double[] seq4 = new double[] { -4.55, 4, 45, 411, 4.09, 43.98, 4, -4, -44.432 };");
                int seqIndex4 = await sparseMatrixRepSeq.AddSequence(seq4);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                #endregion

                #region Добавление координат размещения первых элементов последовательностей
                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceBandCoord(seqIndex0, 0, 5, 2)");
                int sequenceCoordIndex0 = await sparseMatrixRepSeq.AddSequenceBandCoord(seqIndex0, 0, 5, 2);

                await sparseMatrixRepSeq.PrintMatrixSequenceBandCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceBandCoord(seqIndex1, 2, 5, 2)");
                int sequenceCoordIndex1 = await sparseMatrixRepSeq.AddSequenceBandCoord(seqIndex1, 2, 5, 2);

                await sparseMatrixRepSeq.PrintMatrixSequenceBandCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceBandCoord(seqIndex2, 4, 5, 2)");
                int sequenceCoordIndex2 = await sparseMatrixRepSeq.AddSequenceBandCoord(seqIndex2, 4, 5, 2);

                await sparseMatrixRepSeq.PrintMatrixSequenceBandCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceBandCoord(seqIndex3, 6, 5, 2)");
                int sequenceCoordIndex3 = await sparseMatrixRepSeq.AddSequenceBandCoord(seqIndex3, 6, 5, 2);

                await sparseMatrixRepSeq.PrintMatrixSequenceBandCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceBandCoord(seqIndex4, 8, 5, 2)");
                int sequenceCoordIndex4_1 = await sparseMatrixRepSeq.AddSequenceBandCoord(seqIndex4, 8, 5, 2);

                await sparseMatrixRepSeq.PrintMatrixSequenceBandCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceBandCoord(seqIndex4, 10, 6, 2)");
                int sequenceCoordIndex4_2 = await sparseMatrixRepSeq.AddSequenceBandCoord(seqIndex4, 10, 6, 2);

                await sparseMatrixRepSeq.PrintMatrixSequenceBandCoordinatesFile();

                #endregion

                await sparseMatrixRepSeq.SetNumColsAsync(20);

                #region Запрос строк из последовательностей
                Console.WriteLine("Запрос строки 0");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(0);

                Console.WriteLine("Запрос строки 1");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(1);

                Console.WriteLine("Запрос строки 2");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(2);

                Console.WriteLine("Запрос строки 3");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(3);

                Console.WriteLine("Запрос строки 4");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(4);

                Console.WriteLine("Запрос строки 5");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(5);

                Console.WriteLine("Запрос строки 6");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(6);

                Console.WriteLine("Запрос строки 7");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(7);

                Console.WriteLine("Запрос строки 8");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(8);

                Console.WriteLine("Запрос строки 9");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(9);

                Console.WriteLine("Запрос строки 10");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(10);

                Console.WriteLine("Запрос строки 11");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(11);

                Console.WriteLine("Запрос несуществующей строки 12");
                await sparseMatrixRepSeq.PrintRowFromSequenceBand(12);

                #endregion
            }
            Console.WriteLine("---Successful end of method---");
        }