Hello
I'm currently working on a method that is supposed to row reduce a given array. However, before I've started the coding on the row reduction. I'm trying to create a method that can control if a given array is eligble for row reduction or not.
So the thing is, I have a method that attempts to go through a given matrix [][], and checking if all elements are numbers. However this matrix below
int [][] matrixFalse2 = {{},{},{}};
passes through without any problem (without any numbers at all...). I don't know how to write the code so the method returns false for this kind of matrix.
Currently this code below is my current one for the number checking part,
int elements = matrix.length*matrix[1].length; int counter = 0; for(int rows=0; rows<matrix.length; rows++){ for(int columns=0; columns<matrix[rows].length; columns++){ if(matrix[rows][columns]>=0 || matrix[rows][columns] <0){ counter = counter + 1; //System.out.println(counter + " . " + elements); just debug code } } } if(counter==elements){ return true; }else{ return false; }
If the first row makes you wonder why it has the number 1, it's because I've already checked the matrix if the dimensions are correct, so number 1 is arbitrary in this case - feel free to ignore it.
So I was thinking of adding something like this (see below) but of course the syntax is very wrong (which is why I need help).
if(matrix[i][j]==null){ return false; }
And then I would loop through the matrix with the variables i & j. How am I supposed to tackle this problem?
I hope you understand my problem. Thanks in advance.
//Robin