Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CategorizedData"/> class.  Allocates memory for pages, rows, and columns of <see cref="X"/>.
 /// </summary>
 /// <param name="Neach"><see cref="Neach"/></param>
 /// <param name="Ndims"><see cref="Ndims"/></param>
 public CategorizedData(int[] Neach, int Ndims)
 {
     this.Neach  = Neach;
     this.Ndims  = Ndims;
     this.Ncats  = this.Neach.Length;
     this.Ntotal = Static.Sum(this.Neach);
     this.X      = new float[this.Ncats][][];
     for (int iCat = 0; iCat < this.Ncats; iCat++)
     {
         this.X[iCat] = new float[this.Neach[iCat]][];
         int n = this.Neach[iCat];
         for (int i = 0; i < n; i++)
         {
             this.X[iCat][i] = new float[this.Ndims];
         }
     }
 }
Ejemplo n.º 2
0
        protected CategorizedData(CategorizedData dualViewable, int targetCat)
        {
            this.Neach  = new int[] { dualViewable.Neach[targetCat], dualViewable.Ntotal - dualViewable.Neach[targetCat] };
            this.Ndims  = dualViewable.Ndims;
            this.Ncats  = this.Neach.Length;
            this.Ntotal = Static.Sum(this.Neach);

            //	Allocate page holders
            this.X = new float[this.Ncats][][];

            //	Allocate row holders
            for (int iCat = 0; iCat < this.Ncats; iCat++)
            {
                this.X[iCat] = new float[this.Neach[iCat]][];
            }

            //	Fill rows of category 0 with targetCat
            int n = this.Neach[0];

            for (int i = 0; i < n; i++)
            {
                this.X[0][i] = dualViewable.X[targetCat][i];
            }

            //	Fill rows of category 1 with remaining data.
            int iDatum = 0;

            for (int iCat = 0; iCat < dualViewable.Ncats; iCat++)
            {
                if (iCat != targetCat)
                {
                    n = dualViewable.Neach[iCat];
                    for (int iSamp = 0; iSamp < n; iSamp++)
                    {
                        this.X[1][iDatum++] = dualViewable.X[iCat][iSamp];
                    }
                }
            }
        }