using System; using System.Collections.Generic; using System.Linq; using System.Text; using L = Science.Mathematics.LinearAlgebra; namespace Strang3Ed.Chapter05.Section1 { public class ExampleA { public ExampleA() { } private string result; public string Result { get { return result; } } public void Compute() { double[,] x = {{0.0,0.0,1.0}, {0.0,2.0,3.0}, {4.0,5.0,6.0}}; L.Matrix A = new L.Matrix(x); result += A.Determinant.ToString()+"\r\n"; result += A.ToString() + " "; for (int i = 0; i < A.SizeOfRow; i++) for (int j = 0; j < A.SizeOfRow; j++) A[i, j] = Math.Pow(-1.0, i + j) * A[i, j]; result += A.Determinant.ToString() + "\r\n"; result += A.ToString() + " "; L.Matrix B = new L.Matrix(3, 3); for (int i = 0; i < A.SizeOfRow; i++) for (int j = 0; j < A.SizeOfRow; j++) { double sum = 0.0; for (int k = 0; k < A.SizeOfRow; k++) sum += A[i, k] * A[j, k]; B[i, j] = sum; } result += B.Determinant.ToString() + "\r\n"; result += B.ToString() + " "; } } } /* -8 0 0 1 0 2 3 4 5 6 -8 0 0 1 0 2 -3 4 -5 6 64 1 -3 6 -3 13 -28 6 -28 77 */