/// <summary> /// This reverses the effects of <see cref="Expand"/>. Expanded terms are removed if they exist. /// </summary> /// <param name="poly">The defiinition of the polynomial expansion.</param> public void Contract() { for (int iCat = 0; iCat < this.Ncats; iCat++) { int nSamp = this.Neach[iCat]; for (int iSamp = 0; iSamp < nSamp; iSamp++) { float[] x = this.X[iCat][iSamp]; if (x.Length > this.Ndims) { this.X[iCat][iSamp] = Static.GetSubarray(x, 0, this.Ndims - 1); } } } }
/// <summary> /// Computes the polynomial expansion in place. You can undo the expansion by calling <see cref="Contract"/> /// </summary> /// <param name="poly">The defiinition of the polynomial expansion.</param> public void Expand(Poly poly) { for (int iCat = 0; iCat < this.Ncats; iCat++) { int nSamp = this.Neach[iCat]; for (int iSamp = 0; iSamp < nSamp; iSamp++) { float[] x = this.X[iCat][iSamp]; if (x.Length > this.Ndims) { this.X[iCat][iSamp] = poly.Expand(Static.GetSubarray(x, 0, this.Ndims - 1)); } else { this.X[iCat][iSamp] = poly.Expand(x); } } } }