static void Main(string[] args) { Matrix2 m1 = new Matrix2(4, 2, 9, 0); Matrix2 m2 = new Matrix2(3, 1, -3, 4); Console.WriteLine(m1); Console.WriteLine(m2); Console.WriteLine(m2.Inverse()); Console.WriteLine(m1.Det()); Console.WriteLine(m1.Transpose()); Console.WriteLine(m1 + m2); Console.WriteLine(m1 - m2); Console.WriteLine(m1 * m2); Console.WriteLine(m1 / m2); }
static void Main(string[] args) { Random random = new Random(); do { Matrix2 A = new Matrix2(random.Next(), random.Next(), random.Next(), random.Next()); Matrix2 B = new Matrix2(random.Next(), random.Next()); Console.WriteLine($"A: {A}"); Console.WriteLine($"B: {A}"); try { Console.WriteLine($"A^(-1)"); Console.WriteLine(A.Inverse()); } catch (Exception e) { Console.WriteLine(e.Message); } try { Console.WriteLine($"B^(-1)"); Console.WriteLine(B.Inverse()); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine($"A^T\r\n{A.Transponse()}"); Console.WriteLine($"B^T\r\n{B.Transponse()}"); Console.WriteLine($"A - B: \r\n{A - B}"); Console.WriteLine($"A + B: \r\n{A + B}"); Console.WriteLine($"A * B: \r\n{A * B}"); try { Console.WriteLine("A / B"); Console.WriteLine(A / B); } catch (Exception e) { Console.WriteLine(e.Message); } try { Console.WriteLine("A / a"); Console.WriteLine(A / random.Next()); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine($"A * random.Next() \r\n {A * random.Next()}"); }while (Console.ReadKey(true).Key != ConsoleKey.Escape); }
public static Matrix2 operator |(Matrix2 m1, Matrix2 m2) { Matrix2 m3 = m1 * m2; return(m3 * m3.Det()); }