I don't know why I keep getting these errors. I have looked at the coed and as far as I can see the variables that cause the errors to arise are within scope and to be honest the errors just don't seem to be making any sense.
class Clusteringclass {
distances dist = new distances();
double theRow = 1;
double theCoulmn =0;
double newRow = 1;
public Clusteringclass(){
dist.getMatrix();
}
private void obtainClusters(double distanceMatrix[][]){
int all;
//int i;
for (int i=0;i<distanceMatrix.length; ++i){
for (all = 1; all<distanceMatrix.length; ++all)
for (double checkDistanceVal = 100; checkDistanceVal > distanceMatrix[i][all] && distanceMatrix[i][all] !=0;
checkDistanceVal = distanceMatrix[i][all] )
//checkDistanceVal = distanceMatrix[i][all];/*This will hold the final value ie, the value with the smallest distance.*/
double row =(double)i;
double column = (double)all;/*These assignments ensure that the corresponding row and column numbers are stored for the
shortest value.*/
}
}
public double[][] addElement(double[][] distanceMatrix, double row, double column ){
double[][] newArray = new double [distanceMatrix.length - 1][distanceMatrix.length - 1];/*Creates a brand new array of greater
length*/
for ( int i = 0; i < distanceMatrix.length; i++){
system.out.println (i+"\n");
if (i != row && i != column){/*As long as the element of distance matrix being covered is not*/
newArray[i - 1] = distanceMatrix[i];/*Assigns elements of the distance matrix to the new Array. use -1 because obviously
the array size will decrease since the rows that are of the shortest distance will be amalgamated into 1. */
}
}
for (int i = 0; i < theDistanceMatrix.length; ++i){
newArray[newRow][theColumn] = Math.min(double [row][i], double [column][i]);/*Puts the minimum value into the new array at the
beginning.*/
++newRow;/*Only increment the row value because going to input the new values downwards. */
}
distanceMatrix = newArray;
return distanceMatrix;
}
}
[ March 05, 2004: Message edited by: Naf Rash ]
class Clusteringclass {
distances dist = new distances();
double theRow = 1;
double theCoulmn =0;
double newRow = 1;
public Clusteringclass(){
dist.getMatrix();
}
private void obtainClusters(double distanceMatrix[][]){
int all;
//int i;
for (int i=0;i<distanceMatrix.length; ++i){
for (all = 1; all<distanceMatrix.length; ++all)
for (double checkDistanceVal = 100; checkDistanceVal > distanceMatrix[i][all] && distanceMatrix[i][all] !=0;
checkDistanceVal = distanceMatrix[i][all] )
//checkDistanceVal = distanceMatrix[i][all];/*This will hold the final value ie, the value with the smallest distance.*/
double row =(double)i;
double column = (double)all;/*These assignments ensure that the corresponding row and column numbers are stored for the
shortest value.*/
}
}
public double[][] addElement(double[][] distanceMatrix, double row, double column ){
double[][] newArray = new double [distanceMatrix.length - 1][distanceMatrix.length - 1];/*Creates a brand new array of greater
length*/
for ( int i = 0; i < distanceMatrix.length; i++){
system.out.println (i+"\n");
if (i != row && i != column){/*As long as the element of distance matrix being covered is not*/
newArray[i - 1] = distanceMatrix[i];/*Assigns elements of the distance matrix to the new Array. use -1 because obviously
the array size will decrease since the rows that are of the shortest distance will be amalgamated into 1. */
}
}
for (int i = 0; i < theDistanceMatrix.length; ++i){
newArray[newRow][theColumn] = Math.min(double [row][i], double [column][i]);/*Puts the minimum value into the new array at the
beginning.*/
++newRow;/*Only increment the row value because going to input the new values downwards. */
}
distanceMatrix = newArray;
return distanceMatrix;
}
}
[ March 05, 2004: Message edited by: Naf Rash ]