これは、Javaのスパース行列から要素を取得するメソッドです。エラーが発生し続けjava.lang.NullPointerException
ます。コードを調べましたが、エラーが見つかりません。
public int getElement(int row,int col){
int result = 0;
MatrixEntry matrixentry = null;
if ((row >= 0) && (row < getNumRows()) &&
(col >= 0) && (col < getNumCols())) {
if (col == colArray[col].getColumn() && row ==rowArray[row].getRow()){
matrixentry = rowArray[row];
while (matrixentry.getColumn() < col) {
matrixentry = matrixentry.getNextColumn();
} // end while
if (matrixentry.getColumn() > col){
return 0;
}
if (matrixentry == null){
return 0;
}//
result = matrixentry.getData();
}//
}//
return result;
} // end