AIMA.Core.Util.Math.Vector.indexHavingMaxValue C# (CSharp) Méthode

indexHavingMaxValue() public méthode

public indexHavingMaxValue ( ) : int
Résultat int
        public int indexHavingMaxValue()
        {
            if (size() <= 0)
            {
                throw new InvalidOperationException("can't perform this op on empty vector");
            }
            int res = 0;
            for (int i = 0; i < size(); i++)
            {
                if (getValue(i) > getValue(res))
                {
                    res = i;
                }
            }
            return res;
        }
    }

Usage Example

Exemple #1
0
 public bool isCorrect(Vector prediction)
 {
     /*
      * compares the index having greatest value in target to indec having
      * greatest value in prediction. Ifidentical, correct
      */
     return getTarget().indexHavingMaxValue() == prediction
             .indexHavingMaxValue();
 }