double denom=1;
	protected double[] evaluateGradient(double[] x){	    double[] grad = new double[x.length];	    int dim = m_NumPredictors+1; // Number of variables per class	    	    for(int i=0; i<cls.length; i++){ // ith instance		double denom=1; // Denominator of [-log(1+sum(exp))]'		double[] num=new double[m_NumClasses-1]; // numerator of [-log(1+sum(exp))]'		for(int offset=0; offset<m_NumClasses-1; offset++){ // Which part of x		    double exp=0.0;		    		    for(int j=0; j<dim; j++)			exp += m_Data[i][j]*x[offset*dim+j];		    denom += Math.exp(exp);		    num[offset] = Math.exp(exp);		}				// Update denominator of the gradient of -log(Posterior)		for(int offset=0; offset<m_NumClasses-1; offset++){ // Which part of x		    for(int q=0; q<dim; q++){			grad[offset*dim+q] += weights[i]*num[offset]*m_Data[i][q]/denom;		    }		}				if(cls[i] != m_NumClasses-1){ // Not the last class		    for(int p=0; p<dim; p++){			grad[cls[i]*dim+p] -= weights[i]*m_Data[i][p]; 		    }		}	    }	    	    // Ridge: note that intercepts NOT included	    for(int offset=0; offset<m_NumClasses-1; offset++){		for(int r=1; r<dim; r++)		    grad[offset*dim+r] += 2*m_Ridge*x[offset*dim+r];	    }	    	    return grad;	}