package nxm.sys.libm;

import nxm.sys.inc.Constants;

/**
   Performs the Cmplx operation on arrays. <br>
   See {@link Operator} for a description of the available I/O Modes.
   @author  Auto-Generated
   @see     Operator
*/
@SuppressWarnings("cast")
public final class Cmplx extends Operator implements Constants {

  /** Create a new instance. */
  public Cmplx() {
    super();
  }

  /** Create a new instance.
      @param flags The processing flags to use.
   */
  public Cmplx (int flags) {
    super(flags);
  }

  /** Create a new instance.
      @param scale The scale factor to use.
   */
  public Cmplx (double scale) {
    super(scale);
  }

  /** Create a new instance.
      @param flags The processing flags to use.
      @param scale The scale factor to use.
   */
  public Cmplx (int flags, double scale) {
    super(flags,scale);
  }

  public final int validate (char type, int n, int mode) {
    switch (mode) {
      case SC: return n;
      default: return NOSUPPORT;
    }
  }

  public final int process (double[][] v, int n, int mode) {
    switch (mode) {
      case SC: SC(v[0],v[1],n); return n;
      default:  return NOSUPPORT;
    }
  }

  public final int process (double[][] v, int n, int mode, double scale) {
    switch (mode) {
      case SC: SC(v[0],v[1],n); return n;
      default:  return NOSUPPORT;
    }
  }

  /** Apply this operator to mode {@link Operator#SC} data.
      @param a     The first  operand.
      @param b     The second  operand.
      @param n     The number of elements to operate on.
      @see #process(double[][],int,int)
   */
  public static final void SC (double[] a, double[] b, int n) {
      for (int i=n-1,j=i+i; i>=0; i--,j-=2) {
        b[j]=a[i]; b[j+1]=0;
      }
  }

  public final int process (float[][] v, int n, int mode) {
    switch (mode) {
      case SC: SC(v[0],v[1],n); return n;
      default:  return NOSUPPORT;
    }
  }

  public final int process (float[][] v, int n, int mode, double scale) {
    switch (mode) {
      case SC: SC(v[0],v[1],n); return n;
      default:  return NOSUPPORT;
    }
  }

  /** Apply this operator to mode {@link Operator#SC} data.
      @param a     The first  operand.
      @param b     The second  operand.
      @param n     The number of elements to operate on.
      @see #process(float[][],int,int)
   */
  public static final void SC (float[] a, float[] b, int n) {
      for (int i=n-1,j=i+i; i>=0; i--,j-=2) {
        b[j]=a[i]; b[j+1]=0;
      }
  }

  public final int process (int[][] v, int n, int mode) {
    switch (mode) {
      case SC: SC(v[0],v[1],n); return n;
      default:  return NOSUPPORT;
    }
  }

  public final int process (int[][] v, int n, int mode, double scale) {
    switch (mode) {
      case SC: SC(v[0],v[1],n); return n;
      default:  return NOSUPPORT;
    }
  }

  /** Apply this operator to mode {@link Operator#SC} data.
      @param a     The first  operand.
      @param b     The second  operand.
      @param n     The number of elements to operate on.
      @see #process(int[][],int,int)
   */
  public static final void SC (int[] a, int[] b, int n) {
      for (int i=n-1,j=i+i; i>=0; i--,j-=2) {
        b[j]=a[i]; b[j+1]=0;
      }
  }

  public int getInputs() { return 1; }
  public int getOutputs() { return 1; }
}
