/// <summary> /// Run example /// </summary> /// <seealso cref="http://en.wikipedia.org/wiki/Determinant">Determinant</seealso> /// <seealso cref="http://en.wikipedia.org/wiki/Rank_%28linear_algebra%29">Rank (linear algebra)</seealso> /// <seealso cref="http://en.wikipedia.org/wiki/Trace_%28linear_algebra%29">Trace (linear algebra)</seealso> /// <seealso cref="http://en.wikipedia.org/wiki/Condition_number">Condition number</seealso> public void Run() { // Format matrix output to console var formatProvider = (CultureInfo)CultureInfo.InvariantCulture.Clone(); formatProvider.TextInfo.ListSeparator = " "; // Create random square matrix var matrix = new DenseMatrix(5); var rnd = new Random(1); for (var i = 0; i < matrix.RowCount; i++) { for (var j = 0; j < matrix.ColumnCount; j++) { matrix[i, j] = rnd.NextDouble(); } } Console.WriteLine(@"Initial matrix"); Console.WriteLine(matrix.ToString("#0.00\t", formatProvider)); Console.WriteLine(); // 1. Determinant Console.WriteLine(@"1. Determinant"); Console.WriteLine(matrix.Determinant()); Console.WriteLine(); // 2. Rank Console.WriteLine(@"2. Rank"); Console.WriteLine(matrix.Rank()); Console.WriteLine(); // 3. Condition number Console.WriteLine(@"2. Condition number"); Console.WriteLine(matrix.ConditionNumber()); Console.WriteLine(); // 4. Trace Console.WriteLine(@"4. Trace"); Console.WriteLine(matrix.Trace()); Console.WriteLine(); }