#vulnerable code 
                                public int getRank() {

        final Array1D<Double> tmpSingularValues = this.getSingularValues();
        int retVal = tmpSingularValues.size();

        // Tolerance based on min-dim but should be max-dim
        final double tmpTolerance = retVal * (tmpSingularValues.doubleValue(0) * PrimitiveMath.MACHINE_EPSILON);

        for (int i = retVal - 1; i >= 0; i--) {
            if (tmpSingularValues.doubleValue(i) <= tmpTolerance) {
                retVal--;
            } else {
                return retVal;
            }
        }

        return retVal;
    } 
                            #location 4 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public int getRank() {
        final double tolerance = s[0] * this.getDimensionalEpsilon();
        int rank = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] > tolerance) {
                rank++;
            }
        }
        return rank;
    }