// f06ya Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class F06YAE { static int m = 2; static int n = 2; static int k = 2; static void Main(String[] args) { StartExample(); } public static void StartExample() { try { double[,] a = { { 1, 2 }, { 3, 4 }}; double[,] b = { { 5,6 }, { 7,8 } }; double[,] cN = new double[m, n]; double[,] cT = new double[m, n]; double alpha = 1.0; double beta = 1.0; int ifail; Console.WriteLine("\nMATRIX A MULTIPLIED BY MATRIX B WITH BOTH NON TRANSPOSED \n"); Console.WriteLine("\n======================================================\n"); string transa = "N"; string transb = "N"; F06.f06ya(transa, transb, m, n, k, alpha, a, b, beta, cN, out ifail); displayMatrices(a, b, cN); Console.WriteLine("\nMATRIX A MULTIPLIED BY MATRIX B WITH BOTH TRANSPOSED \n"); Console.WriteLine("\n======================================================\n"); transa = "T"; transb = "T"; F06.f06ya(transa, transb, m, n, k, alpha, a, b, beta, cT, out ifail); displayMatrices(a, b, cT); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } private static void displayMatrices(double[,]a , double[,]b, double[,]c) { Console.WriteLine("\nMATRIX A\n\n"); for (int i = 0; i < m; i++) { for (int j = 0; j < k; j++) { Console.Write("{0,10:f2}", a[i, j]); } Console.WriteLine(""); } Console.WriteLine("\nMATRIX B \n\n"); for (int i = 0; i < k; i++) { for (int j = 0; j < n; j++) { Console.Write("{0,10:f2}", b[i, j]); } Console.WriteLine(""); } Console.WriteLine("\nRESULTANT MATRIX C \n\n"); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { Console.Write("{0,10:f2}", c[i, j]); } Console.WriteLine(""); } } } }