示例#1
0
        private static void TestRandomMatrix()
        {
            // Create the random matrix and write it to a temporary file
            DokSymmetric originalMatrix   = RandomUtilities.CreateRandomMatrix(1000, 0.2);
            var          coordinateWriter = new CoordinateTextFileWriter();

            coordinateWriter.NumericFormat = new ExponentialFormat {
                NumDecimalDigits = 10
            };
            string tempFile = "temp.txt";

            coordinateWriter.WriteToFile(originalMatrix, tempFile);

            // Read the temporary file and compare it with the generated matrix
            var          reader     = new CoordinateTextFileReader();
            DokSymmetric readMatrix = reader.ReadFileAsDokSymmetricColMajor(tempFile);
            bool         success    = comparer.AreEqual(originalMatrix, readMatrix);

            // Clean up
            File.Delete(tempFile);
            Assert.True(success);
        }