package jp.gr.java_conf.dyama.rink.ml.svm;

/**
 * Data structure for results of SVM estimations .
 * @author Hiroyasu Yamada
 *
 */
final class Estimation {

    /** array for inner products (integer) */
    private int[] ips_int_;

    /** array for inner products (double) */
    private double[] ips_double_;

    /** array for distances_ form hyperplanes */
    private double[] distances_;

    /** pairwise score */
    private Score.PairwiseScore score_;

    /**
     * Constructor:
     * @param classes the number of classes. it must be more than 0.
     * @param svs the number of support vectors. it must be 0 and over.
     */
    Estimation(int classes, int svs) {
        assert(classes > 0);
        assert(svs >=0 );
        ips_int_    = new int[svs];
        ips_double_ = new double[svs];
        distances_  = new double[ classes * (classes - 1) / 2 ];
        score_      = new Score.PairwiseScore(classes);
    }

    /**
     * setup
     * @param classes the number of classes. it must be more than 0.
     * @param svs svs the number of support vectors. it must be 0 and over.
     */
    void setup(int classes, int svs){
        assert(classes > 0);
        assert(svs >= 0);

        int m = classes * (classes - 1) / 2 ;

        if (distances_.length != m)
            distances_ = new double[m];

        for(int i = 0 ;  i < distances_.length; i++)
            distances_[i] = 0.0;

        if (ips_double_.length != svs)
            ips_double_ = new double[svs];

        for(int i = 0 ;  i < ips_double_.length; i++)
            ips_double_[i] = 0.0;

        if (ips_int_.length != svs)
            ips_int_ = new int[svs];

        for(int i = 0 ;  i < ips_int_.length; i++)
            ips_int_[i] = 0;

        if (score_.getNumberOfLabels() != classes)
            score_ = new Score.PairwiseScore(classes);

        score_.clear();
    }

    /**
     * get the array (int) for inner products.
     * @return array (int)
     */
    int[] getIntArrayForInnerProducts() {
        return ips_int_;
    }

    /**
     * get the array (double) for inner products.
     * @return array (double)
     */
    double[] getDoubleArrayForInnerProducts() {
        return ips_double_;
    }

    /**
     * get the array for distances from hyperplanes.
     * @return array
     */
    double[] getDistances() {
        return distances_;
    }

    Score.PairwiseScore getScore(){
        return score_ ;
    }
}

@@ -151,32 +151,36 @@
 ation %7B%0A%0A    /**
+ the
  array for inner
@@ -230,32 +230,36 @@
 s_int_;%0A%0A    /**
+ the
  array for inner
@@ -322,16 +322,20 @@
 %0A    /**
+ the
  array f
@@ -346,17 +346,16 @@
 istances
-_
  form hy
@@ -413,22 +413,46 @@
 /** 
-pairwise score
+the score for pairwise classifications
  */%0A
@@ -557,34 +557,53 @@
 ber of classes. 
-it
+The number of classes
  must be more th
@@ -649,34 +649,61 @@
 upport vectors. 
-it
+The number of support vectors
  must be 0 and o
@@ -1027,17 +1027,17 @@
 %0A     * 
-s
+S
 etup%0A   
@@ -1078,18 +1078,37 @@
 lasses. 
-it
+The number of classes
  must be
@@ -1178,10 +1178,37 @@
 rs. 
-it
+The number of support vectors
  mus
@@ -2021,27 +2021,33 @@
   * 
-g
+R
 et
+urns
  the 
-array (int)
+integer array
  for
@@ -2082,19 +2082,17 @@
 urn 
+the 
 array
- (int)
 %0A   
@@ -2189,30 +2189,32 @@
   * 
-g
+R
 et
+urns
  the 
-array (double)
+double array
  for
@@ -2249,22 +2249,17 @@
 urn 
+the 
 array
- (double)
 %0A   
@@ -2361,19 +2361,23 @@
 %0A     * 
-g
+R
 et
+urns
  the arr

revise API docs.