}
// transpose the gradient and negate it, because we transposed theta at the
// top and our gradient descent subtracts instead of addition.
return new CostGradientTuple(j,
DenseMatrixFolder.foldMatrices((DenseDoubleMatrix) thetaGradient
.multiply(-1).transpose()));
}
private DoubleMatrix multiply(DoubleMatrix a1, DoubleMatrix a2,
boolean a1Transpose, boolean a2Transpose) {