Exemple #1
0
 public virtual bool isEqual(GMMDiag g)
 {
     if (this.getNgauss() != g.getNgauss())
     {
         return(false);
     }
     if (this.getNgauss() != g.getNcoefs())
     {
         return(false);
     }
     for (int i = 0; i < this.getNgauss(); i++)
     {
         if (this.isDiff(this.getWeight(i), g.getWeight(i)))
         {
             return(false);
         }
         for (int j = 0; j < this.getNcoefs(); j++)
         {
             if (this.isDiff(this.getMean(i, j), g.getMean(i, j)))
             {
                 return(false);
             }
             if (this.isDiff(this.getVar(i, j), g.getVar(i, j)))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemple #2
0
        public virtual GMMDiag merge(GMMDiag g, float w1)
        {
            GMMDiag gmmdiag = new GMMDiag(this.getNgauss() + g.getNgauss(), this.getNcoefs());

            for (int i = 0; i < this.getNgauss(); i++)
            {
                ByteCodeHelper.arraycopy_primitive_4(this.means[i], 0, gmmdiag.means[i], 0, this.getNcoefs());
                ByteCodeHelper.arraycopy_primitive_4(this.covar[i], 0, gmmdiag.covar[i], 0, this.getNcoefs());
                gmmdiag.setWeight(i, this.getWeight(i) * w1);
            }
            for (int i = 0; i < g.getNgauss(); i++)
            {
                ByteCodeHelper.arraycopy_primitive_4(g.means[i], 0, gmmdiag.means[this.ngauss + i], 0, this.getNcoefs());
                ByteCodeHelper.arraycopy_primitive_4(g.covar[i], 0, gmmdiag.covar[this.ngauss + i], 0, this.getNcoefs());
                gmmdiag.setWeight(this.ngauss + i, g.getWeight(i) * (1f - w1));
            }
            gmmdiag.precomputeDistance();
            return(gmmdiag);
        }