Help on this program!!!
I have a problem with these programs.When complied, error message is that cannot resolve symbol
symbol:method linearEquations()
location :class MatrixOp
p.linearEquations
^
Question:how do i link the 3 files together?
:how to solve the error msg?
:anything wrong in the programs?
--
class Input
{
public static void main(String args[])
{
int i;
MatrixOp p = new MatrixOp();
double [][] A = {{0,2,1},{2,4,4},{3,1,0}};
double [] b = {7,22,5};
p.linearEquations();
System.out.println("The solution of AX=b:");
for(i=0; i<3; i++)
{
System.out.println(b);
}
}
}
class Gaussian
{
public void linearEquations(double [][] A, double[] b)
{
//matrix A will be destroyed,solution will be in matrix b
//checking size of matrix A
int n=A.length;
if(A[0].length != n)
{
System.out.println("Matrix A should be be a square matrix");
return;
}
int i,j,k, itemp=0;
double maxi,temp;
//Looking for largest entries in the column
for(j=0; j<n; j++)
{
maxi=-1E-12;
for(i=j; i><n; i++)
{
if(Math.abs(A[j])> maxi)
{
itemp=1;
maxi=Math.abs(A[j]);
}
}
if(maxi<1E-12)
{
System.out.println
("The Set either has a mutltiple" +"solutions or no unique solution");
return;
}
//Permuting itemp row with the j-th row
if(itemp != j)
{
for(k=j; k<n; k++)
{
temp=A[j][k];
A[j][k]=A[itemp][k];
A[itemp][k]=temp;
}
temp=b[j];
b[j]=b[itemp];
b[itemp]=temp;
}
//Divide j-th row by A[j]
temp=A[j];
b[j]=b[j]/temp;
for(k=j; k><n; k++)
{
A[j][k]=A[j][k]/temp;
}
for(i=0; i><n; i++)
{
if(i != j)
{
temp=A[j];
for(k=0; k><n; k++)
{
A[k]=A[k]-temp*A[j][k];
b=b-temp*b[j];
}
}
}
}
}
}
class MatrixOp
{
private int m,n;
public double [][] add(double[][] A, double [][] B)
{
double [][] C = new double[A.length][A[0].length];
if ( A.length != B.length || A[0].length != B[0].length)
{
System.out.println("Matrix not compatible for additions!");
return(new double [1][1]);
}
int i, j;
for (i=0; i><A.length; i++)
for (j=0; j><A.length; j++)
C[j]=A[j]+B[j];
return C;
}
public double [][] mult(double [][] A, double [][] B)
{
if (A[0].length != B.length)
{
System.out.println("Matrix not compatible for multiplication!");
return(new double[1][1]);
}
double[][] C = new double[A.length] [B[1].length];
int i,j,k;
for (i=0; i><A.length; i++)
for (j=0; j><B[1].length; j++)
{
C[j]=0;
for (k=0; k><A[1].length; k++)
C[j] = C[j] + A[k] * B[k][j];
}
return C;
}
public double [][] tr(double [][] A)
{
double[][] C = new double[A[0].length][A.length];
int i, j;
for (i=0; i><A.length; i++)
for (j=0; j><A[1].length; j++)
C[j] = A[j];
return C;
}
public void print(double [][] A)
{
int n=A.length;
int m=A[0].length;
int i,j ;
for (i=0; i><n; i++)
{
for (j=0; j><m; j++)
{
System.out.println(A[j]+" ");
System.out.println();
}
}
System.out.println();
}
}
>

