Problem With Grid Application
Hi,
Problem in displaying output using this grid matrix multiplication application.
using System;
using Alchemi.Core;
using Alchemi.Core.Owner;
namespace matrix_multiplication
{
/// <summary>
/// Summary description for Class1.
/// </summary>
[Serializable]
public class Matrix_thread :GThread
{
/// <summary>
/// The main entry point for the application.
/// </summary>
public int[,] in1=new int[10,10];
public int[,] in2=new int[10,10];
public int[,] outm=new int[10,10];
static int n=2;
int row=0;
public Matrix_thread(int i)
{
row=i;
//this.Start();
}
public override void Start()
{
int i,j;
Console.WriteLine("pandya");
try
{
for(i=0;i<n;i++)
{
outm[row,i]=0;
for(j=0;j<n;j++)
{
outm[row,i]=outm[row,i]+in1[row,j]*in2[j,i];
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
class matrixapplication
{
static GApplication ga=new GApplication();
[STAThread]
static void Main(string[] args)
{
// Initialize the application to start
Console.WriteLine("Press [Enter] to start grid application");
Console.ReadLine();
// Read the matrix order from the user
Console.WriteLine("Enter the Order Of Matrix : ");
int order=Int16.Parse(Console.ReadLine());
int[,] in1=new int[100,100];
int[,] in2=new int[100,100];
int[,] outm=new int[100,100];
int i,j;
// Get the mtrices for multiplication
// First matrix
Console.WriteLine("Enter the elements for the first matrix : ");
for(i=0;i<order;i++)
{
for(j=0;j<order;j++)
{
in1[i,j]=Int16.Parse(Console.ReadLine());
}
}
// Second Matrix
Console.WriteLine("Enter the elements for the second matrix :");
for(i=0;i<order;i++)
{
for(j=0;j<order;j++)
{
in2[i,j]=Int16.Parse(Console.ReadLine());
}
}
// Create a grid application
GConnectionDialog dg=new GConnectionDialog();
if(dg.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
ga=new GApplication(dg.Connection);
}
else
{
Console.WriteLine("A connection must be created");
return;
}
// tell the program to send itself over network (add dependency)
ga.Manifest.Add(new ModuleDependency(typeof(Matrix_thread).Module));
// Create Thread
try
{
for(i=0;i<order;i++)
{
Matrix_thread thread=new Matrix_thread(i);
ga.Threads.Add(thread);
//Console.Write(outm[i,i++] + "\t");
}
ga.ThreadFinish+=new GThreadFinish(ThreadFinished);
ga.Start();
Console.ReadLine();
for(i=0;i<order;i++)
{
for(j=0;j<order;j++)
{
Console.Write(outm[i,j] + "\t");
}
Console.WriteLine(" \n ");
}
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
ga.Stop();
}
static void ThreadFinished(GThread th)
{
// cast GThread back to MultiplierThread
Matrix_thread thrd=(Matrix_thread)th;
//Console.WriteLine("Resultant Matrix",thrd.Id);
}
}
}