if ((!weightByDistance) && (m_stored[k] > 0))
if ((!m_weightByDistance) && (m_stored[k] > 0))
  private void updateWeightsDiscreteClass(int instNum)  {    int i,j,k;    int cl;    double cc = m_numInstances;    double temp, temp_diff, w_norm=1.0;    double [] tempDistClass;    int [] tempSortedClass = null;    double distNormClass = 1.0;    double [] tempDistAtt;    int [][] tempSortedAtt = null;    double [] distNormAtt = null;    // get the class of this instance    cl = (int)m_trainInstances.instance(instNum).value(m_classIndex);    // sort nearest neighbours and set up normalization variables    if (weightByDistance)      {	// do class (hits) first	// sort the distances	tempDistClass = new double[m_stored[cl]];	for (j=0, distNormClass = 0;j<m_stored[cl];j++) 	  {	    // copy the distances	    tempDistClass[j] = m_karray[cl][j][0];	    // sum normalizer	    distNormClass += weightsByRank[j];	  }	tempSortedClass = Utils.sort(tempDistClass);	// do misses (other classes)	tempSortedAtt = new int[m_numClasses][1];	distNormAtt = new double[m_numClasses];	for (k=0;k<m_numClasses;k++)	  {	    if (k != cl) // already done cl	      {		// sort the distances		tempDistAtt = new double[m_stored[k]];		for (j=0, distNormAtt[k] = 0;j<m_stored[k];j++) 		  {		    // copy the distances		    tempDistAtt[j] = m_karray[k][j][0];		    // sum normalizer		    distNormAtt[k] += weightsByRank[j];		  }		tempSortedAtt[k] = Utils.sort(tempDistAtt);	      }	  }      }    if (m_numClasses > 2)      {	// the amount of probability space left after removing the	// probability of this instances class value	w_norm = (1.0 - m_classProbs[cl]);      }    for (i=0;i<m_numAttribs;i++)      {	if (i != m_classIndex)	  {	    // first do k nearest hits	    for (j=0, temp_diff = 0.0;j < m_stored[cl]; j++)	      {		if (weightByDistance)		  {		    temp_diff += 		      attributeDiff(i, instNum, 				    (int)m_karray[cl][tempSortedClass[j]][1]) *		      (weightsByRank[j] / distNormClass);		  }		else		  {		    temp_diff += 		      attributeDiff(i, instNum, (int)m_karray[cl][j][1]);		  }	      }		    // average	    if ((!weightByDistance) && (m_stored[cl] > 0))	      {		temp_diff /= (double)m_stored[cl];	      }	    	    m_weights[i] -= temp_diff;	    	    // now do k nearest misses from each of the other classes	    temp_diff = 0.0;	    for (k=0;k<m_numClasses;k++)	      if (k != cl) // already done cl		{		  for (j=0,temp=0.0;j<m_stored[k];j++)		    {		      if (weightByDistance)			{			  temp_diff += 			    attributeDiff(i, instNum, 				(int)m_karray[k][tempSortedAtt[k][j]][1]) * 			    (weightsByRank[j] / distNormAtt[k]);			}		      else			{			  temp += attributeDiff(i, instNum, 						(int)m_karray[k][j][1]);			}		    }		  		  if ((!weightByDistance) && (m_stored[k] > 0))		    {		      temp /= (double)m_stored[k];		    }		  		  // now add temp to temp_diff weighted by the prob of this 		  // class		  if (m_numClasses > 2)		    {		      temp_diff += (m_classProbs[k] / w_norm) * temp;		    }		  else		    {		      temp_diff += temp;		    }		}	    m_weights[i] += temp_diff;	  }      }  }