View Single Post
  #1 (permalink)  
Old 06-12-2007, 07:39 AM
sania21 sania21 is offline
Newbie
 
Join Date: May 2007
Posts: 29
Rep Power: 6
sania21 is on a distinguished road
Default Need help on matrix.

ok,well here is my problem i am trying to work on pivot method of matrix,but i have got stuck in it
In my program,with the first pivot element (ie 00 element) the complete row gets divided.than the operation takes place on second till the end of rows now after this operation completes again i want the second pivot element (ei. 11 element ) and again divide now this time second row with 11 element and the process goes on so as to get the inverse on the other side.

Below shown is my code can anyone give me some advice so that i could proceed on my work it wil be most welcome.

here MAtr A is user given matrix and Matr I is identity matrix and refresh(A) method gives current state of matrix.


I am unable to get the second pivot element ie(11 element) using for loop ,i can get it manualy but each time i have to write a for loop for that bcoz after getting each pivot element i have to divide the complete row with that as well as perform some operations on other rows also i want to make my program generalised so that it could work on large matrix.

public void operation1(Matr I) throws NumberFormatException, IOException
{
Matr A=this;
double d1=0;


for(i=0;i<1;i++)
{
for(j=0;j<N;j++)
{


if(i==j)
{
d1=A.data[i][j];
}

for(i=0;i<1;i++)
{
for(j=0;j<N;j++)
{

System.out.println("val of d1 "+d1);

I.data[i][j]=(I.data[i][j]/d1);
A.data[i][j]=(A.data[i][j]/d1);
}
}

}




refresh(A);

for(i=1;i<M;i++)
{
for(j=N-1;j>=0;j--)
{
I.data[i][j]=(I.data[i][j]-(A.data[i][j-j]*I.data[i-i][j]));
A.data[i][j]=(A.data[i][j]-(A.data[i][j-j]*A.data[i-i][j]));
}

}

refresh(A);


}
Reply With Quote

Sponsored Links