export { Pointwise };
export { PointwisePool };

import * as FloatValue from "../../Unpacker/FloatValue.js";
import * as ValueDesc from "../../Unpacker/ValueDesc.js";
import * as Weights from "../../Unpacker/Weights.js";
import { ConvBiasActivation } from "./BoundsArraySet_ConvBiasActivation.js";
import { ChannelPartInfo, FiltersBiasesPartInfo } from  "../Pointwise/Pointwise_ChannelPartInfo.js";

/**
 * The element value bounds for pointwise convolution-bias-activation.
 *
 *   - Only input0 is used. The input1 is always undefined.
 *   - Only outputChannelCount0 is used. The outputChannelCount1 is always zero.
 *
 * @see ConvBiasActivation
 */
class Pointwise extends ConvBiasActivation {

  /**
   *   - The .input0 will be set as input0.
   *   - The .afterUndoPreviousActivationEscaping will be set according to  input0 and input0.scaleArraySet.undo.scales.
   */
  constructor( input0, outputChannelCount0 ) {
    super( input0, outputChannelCount0 );
  }

  /**
   * After calling this method, this object should be viewed as disposed and should not be operated again.
   */
  disposeResources_and_recycleToPool() {
    this.disposeResources();
    PointwisePool.Singleton.recycle( this );
  }

  /**
   * Set this.bPassThrough[] according to inChannelPartInfoArray.
   *
   * @param {Pointwise.FiltersBiasesPartInfo[]} aFiltersBiasesPartInfoArray
   *   The input channel range array which describe lower/higher half channels index range.
   *
   * @return {BoundsArraySet.Pointwise}
   *   Return the this object.
   */
  set_bPassThrough_all_byChannelPartInfoArray( aFiltersBiasesPartInfoArray ) {

    let outChannelBegin = 0, outChannelEnd = 0; // [ outChannelBegin, outChannelEnd ) are output channels of the current FiltersBiasesPart.

    FiltersBiasesPartIndexLoop:
    for ( let aFiltersBiasesPartIndex = 0; aFiltersBiasesPartIndex < aFiltersBiasesPartInfoArray.length; ++aFiltersBiasesPartIndex ) {
      let aFiltersBiasesPartInfo = aFiltersBiasesPartInfoArray[ aFiltersBiasesPartIndex ];
      let inChannelPartInfoArray = aFiltersBiasesPartInfo.aChannelPartInfoArray;

      outChannelBegin = outChannelEnd; // Begin from the ending of the previous FiltersBiasesPart.

      {
        let outChannel = outChannelBegin;

        InChannelPartIndexLoop:
        for ( let inChannelPartIndex = 0; inChannelPartIndex < inChannelPartInfoArray.length; ++inChannelPartIndex ) {
          let inChannelPartInfo = inChannelPartInfoArray[ inChannelPartIndex ];

          for ( let outChannelSub = 0; outChannelSub < inChannelPartInfo.outputChannelCount; ++outChannelSub, ++outChannel ) {
            if ( outChannel >= this.outputChannelCount0 )
              break InChannelPartIndexLoop; // Never exceeds the total output channel count.

              this.bPassThrough[ outChannel ] = inChannelPartInfo.bPassThrough;

          } // outChannelSub, outChannel
        } // inChannelPartIndex

        outChannelEnd = outChannel; // Record the ending output channel index of the current FiltersBiasesPart.
      }

    } // aFiltersBiasesPartIndex

    return this;
  }

}


/**
 * Providing BoundsArraySet.Pointwise
 *
 */
class PointwisePool extends Pool.Root {

  constructor() {
    super( "BoundsArraySet.PointwisePool", Pointwise, PointwisePool.setAsConstructor );
  }

  /**
   * @param {Depthwise} this
   *   The Depthwise object to be initialized.
   *
   * @return {Depthwise}
   *   Return the this object.
   */
  static setAsConstructor( input0, outputChannelCount0 ) {
    this.set_input0_outputChannelCount0( input0, outputChannelCount0 );
    return this;
  }

}

/**
 * Used as default BoundsArraySet.Pointwise provider.
 */
PointwisePool.Singleton = new PointwisePool();

@@ -19,34 +19,52 @@
  %7D;%0A
-ex
+%0Aim
 port 
-%7B PointwisePool %7D;%0A
+* as Pool from %22../../util/Pool.js%22;
 %0Aimp
@@ -710,16 +710,228 @@
 tion %7B%0A%0A
+  /**%0A   * Used as default BoundsArraySet.Pointwise provider for conforming to Recyclable interface.%0A   */%0A  static Pool = new Pool.Root( %22BoundsArraySet.PointwisePool%22, Pointwise, Pointwise.setAsConstructor );%0A%0A
   /**%0A  
@@ -1197,247 +1197,8 @@
  %7D%0A%0A
-  /**%0A   * After calling this method, this object should be viewed as disposed and should not be operated again.%0A   */%0A  disposeResources_and_recycleToPool() %7B%0A    this.disposeResources();%0A    PointwisePool.Singleton.recycle( this );%0A  %7D%0A%0A
   /*
@@ -3082,620 +3082,4 @@
 %0A%7D%0A%0A
-%0A/**%0A * Providing BoundsArraySet.Pointwise%0A *%0A */%0Aclass PointwisePool extends Pool.Root %7B%0A%0A  constructor() %7B%0A    super( %22BoundsArraySet.PointwisePool%22, Pointwise, PointwisePool.setAsConstructor );%0A  %7D%0A%0A  /**%0A   * @param %7BDepthwise%7D this%0A   *   The Depthwise object to be initialized.%0A   *%0A   * @return %7BDepthwise%7D%0A   *   Return the this object.%0A   */%0A  static setAsConstructor( input0, outputChannelCount0 ) %7B%0A    this.set_input0_outputChannelCount0( input0, outputChannelCount0 );%0A    return this;%0A  %7D%0A%0A%7D%0A%0A/**%0A * Used as default BoundsArraySet.Pointwise provider.%0A */%0APointwisePool.Singleton = new PointwisePool();%0A

Update BoundsArraySet_Pointwise.js