So for my class I have been tasked with scanning through a large 15x15 matrix for all possible combinations of a 4x4 matrix, both horizontally and vertically. This is what I've come up with, but it returns a null pointer exception. Any advice as to how I could fix this?
public double compareMatrices(int[][] num,int[][] mat){
int o=0;
double score=0;
for(int n=0;n+4<mat.length;n++){
int[][] rows=new int[4][];
for(int m=0;m+4<15;m++){
for(;o<4;o++){
rows[o]=Arrays.copyOfRange(mat[o], m, m+4);
}
for(int p=0;p<rows.length;p++){
for(int q=0;q < rows.length;q++){
if((rows[p][q]==1)&&(num[p][q]==1)){
score+=1;
}else if((num[p][q]==1)&&(rows[p][q]==0)){
score-=.25;
}else if((num[p][q]==0)&&(rows[p][q]==0)){
score+=.25;
}
}
}
}
}
return(score);
}
for(;o<4;o++)