Computes the total error based on a matrix of error values.
@param errorMatrix A matrix of the error values.
@returns float Total error, defined as the sum of the squared errors.
505803
function calculateTotalError(errorMatrix)
{
	var totError = 0.0;
	for(var i = 1; i <= errorMatrix.rows(); i++)
	{
		for(var j = 1; j <= errorMatrix.cols(); j++)
		{
			totError += Math.pow(errorMatrix.e(i, j), 2);
		}
	}
	
	return totError;
}
92419
public static int min(int[][] matrix) {
        int m = matrix[0][0];

        for (int[] x : matrix) {
            for (int y : x) {
                if (m > y) {
                    m = y;
                }
            }
        }

        return m;
    }
573270
public double errorSum() {
        if (isLeaf()) {
            return 0.0;
        } else if (isPreTerminal()) {
            return error();
        } else {
            double error = 0.0;
            for (Tree child : children()) {
                error += child.errorSum();
            }
            return error() + error;
        }
    }
63714
public static void multLowerTranB( DMatrixRMaj mat ) {
        int m = mat.numCols;
        double[] L = mat.data;
        for( int i = 0; i < m; i++ ) {
            for( int j = m-1; j >= i; j-- ) {
                double val = 0;
                for( int k = 0; k <= i; k++ ) {
                    val += L[ i*m + k] * L[ j*m + k ];
                }
                L[ i*m + j ] = val;
            }
        }
        // copy the results into the lower portion
        for( int i = 0; i < m; i++ ) {
            for (int j = 0; j < i; j++) {
                L[i*m+j] = L[j*m+i];
            }
        }
    }
644304
@Override
   public double error(){
        errorForEachExperimentalData.clear();
        double error =0;
        for (ExperimentalData pair: experimental){
            double temperature = pair.getTemperature();
            substance.setTemperature(temperature);
            substance.dewPressure(substance.getPressure());
            double expP = pair.getPressure();
            double calcP = substance.getPressure();
            double relativeError = (calcP - expP)/expP;
            double squareError = Math.pow(relativeError,2);
            
            
            if(!Double.isNaN(squareError) && Double.isFinite(squareError)){
	            error += squareError;
	            errorForEachExperimentalData.add(new ErrorData(expP, calcP, relativeError,temperature));
            }
        }   
        totalError = error;
        return error;   
   }
1323001
public static AssociativeArray sum(DataTable2D classifierClassProbabilityMatrix) {
        AssociativeArray combinedClassProbabilities = new AssociativeArray(); 
        
        for(Map.Entry<Object, AssociativeArray> entry : classifierClassProbabilityMatrix.entrySet()) {
            //Object classifier = entry.getKey();
            AssociativeArray listOfClassProbabilities = entry.getValue();
            for(Map.Entry<Object, Object> entry2 : listOfClassProbabilities.entrySet()) {
                Object theClass = entry2.getKey();
                Double probability = TypeInference.toDouble(entry2.getValue());
                
                Double previousValue = combinedClassProbabilities.getDouble(theClass);
                if(previousValue==null) { 
                    previousValue=0.0;
                }
                
                combinedClassProbabilities.put(theClass, previousValue+probability);
            }
        }
        
        return combinedClassProbabilities;
    }
199133
public Matrix add(Matrix m) throws MatrixException
    {
        // Validate m's size.
        if ((nRows != m.nRows) && (nCols != m.nCols)) {
            throw new MatrixException(
                                MatrixException.INVALID_DIMENSIONS);
        }

        double sv[][] = new double[nRows][nCols]; // sum values

        // Compute values of the sum.
        for (int r = 0; r < nRows; ++r) {
            for (int c = 0; c < nCols; ++c) {
                sv[r][c] = values[r][c] + m.values[r][c];
            }
        }

        return new Matrix(sv);
    }
737133
def _normalizeImpurityMatrix(matrix):
    
    newMatrix = list()
    for line in matrix:
        total = sum(line)
        if total != 0:
            newMatrix.append([i / total for i in line])
        else:
            newMatrix.append(line)
    return newMatrix
1172695
public static void square( DMatrix1Row mat )
    {
        int index = 1;
        int indexEnd = mat.numCols;
        for( int i = 0; i < mat.numRows;
             i++ , index += i+1 , indexEnd += mat.numCols ) {
            int indexOther = (i+1)*mat.numCols + i;
            for( ; index < indexEnd; index++, indexOther += mat.numCols) {
                double val = mat.data[ index ];
                mat.data[ index ] = mat.data[ indexOther ];
                mat.data[indexOther] = val;
            }
        }
    }
770261
public static void setMatrix(final double[][] m1, final int r0, final int r1, final int c0, final int c1, final double[][] m2) {
    assert r0 <= r1 && c0 <= c1 : ERR_INVALID_RANGE;
    assert r1 <= m1.length && c1 <= m1[0].length : ERR_MATRIX_DIMENSIONS;
    final int coldim = c1 - c0;
    for(int i = r0; i < r1; i++) {
      System.arraycopy(m2[i - r0], 0, m1[i], c0, coldim);
    }
  }
791785
public static double[][] unitMatrix(final int dim) {
    final double[][] e = new double[dim][dim];
    for(int i = 0; i < dim; i++) {
      e[i][i] = 1;
    }
    return e;
  }
718811
public static double elementSumAbs( DMatrixD1 mat ) {
        double total = 0;

        int size = mat.getNumElements();

        for( int i = 0; i < size; i++ ) {
            total += Math.abs(mat.get(i));
        }

        return total;
    }
1221987
private function assertValidMatrix(array $matrix)
    {
        $count = count($matrix);
        if ($count === 3) {
            for ($x = 0; $x < $count; $x++) {
                if (!is_array($matrix[$x])) {
                    throw new \RuntimeException(sprintf(
                            'Item "%d" In The Given Matrix Is Not An Array', $x
                    ));
                }

                $subcount = count($matrix[$x]);
                if ($subcount < 3 || $subcount > 3) {
                    throw new \RuntimeException(sprintf(
                            'Item "%d" In The Given Matrix Must Be An Array With (3) '
                            . 'Flotas But "%d" Float(s) Was Found'
                            , $x, $subcount
                    ));
                }
            }
        } else {
            throw new \RuntimeException(sprintf(
                    'Expect Matrix (3*3) But The Given Matrix Length is (%s)'
                    , $count
            ));
        }
    }
219480
def total_errors(self):
        

        child_errors = sum(len(tree) for _, tree in iteritems(self._contents))
        return len(self.errors) + child_errors
1193441
public static double[][] getMatrix(final double[][] m1, final int[] r, final int c0, final int c1) {
    assert c0 <= c1 : ERR_INVALID_RANGE;
    assert c1 <= m1[0].length : ERR_MATRIX_DIMENSIONS;
    final int rowdim = r.length, coldim = c1 - c0;
    final double[][] X = new double[rowdim][coldim];
    for(int i = 0; i < rowdim; i++) {
      System.arraycopy(m1[r[i]], c0, X[i], 0, coldim);
    }
    return X;
  }
110284
private double computeOutputError(double output, double[] gradient) {

        double error = 0.0;
        double out = outputLayer.output[0];
        double g = output - out;

        error += (0.5*g * g);


        gradient[0] = g;

        return error;
    }
67059
function dfFromMatrixHelper(matrix, startRow, colNames) {
  var nCol = colNames.size();
  var nRow = matrix.length - startRow;
  var columns = allocArray(nCol);
  var j;
  for (j = 0; j < nCol; j++) {
    columns[j] = allocArray(nRow);
  }
  for (var i = 0; i < nRow; i++) {
    var rowArray = matrix[i + startRow];
    if (rowArray.length !== nCol) {
      throw new Error('all row arrays must be of the same size');
    }
    for (j = 0; j < nCol; j++) {
      columns[j][i] = rowArray[j];
    }
  }
  return newDataFrame(columns, colNames);
}