package nxm.sys.libm;

import nxm.sys.inc.Constants;

/**
   Operator class resolver. <br>
   @author  Auto-Generated
   @see OpId
*/
public class Operators implements OpId,Constants {

  /** This constructor was automatically provided by Java,
   *  but it is unneeded as all the methods are static methods.
   *  @deprecated now that Javadocs are required, it is temporarily
   *              being explicitely provided but deprecated
   */
  @Deprecated
  public Operators () {}

  /** Get an operator based on its identifier symbol.
      @param id The identifier symbol for the operator.
                (See {@link OpId} for the set of operator symbol definitions.)
      @return A new instance of the operator identified by the identifier symbol provided,
              or <code>null</code> if the identifier provided does not match one of the valid operators.
   */
  public static Operator get (int id) {
    Operator op=null;
    if (id==0) op=null;
    else if (id==NOOP) op = new Noop();
    else if (id==FILL) op = new Fill();
    else if (id==SCALE) op = new Scale();
    else if (id==ADD) op = new Add();
    else if (id==SUB) op = new Subtract();
    else if (id==MUL) op = new Multiply();
    else if (id==DIV) op = new Divide();
    else if (id==SUM) op = new Summation();
    else if (id==POW) op = new Power();
    else if (id==MIN) op = new Minimum();
    else if (id==MINIMUM) op = new Minimum();
    else if (id==MAX) op = new Maximum();
    else if (id==MAXIMUM) op = new Maximum();
    else if (id==CLIP) op = new Clip();
    else if (id==MUX) op = new Mux();
    else if (id==VMUX) op = new VMux();
    else if (id==DEMUX) op = new Demux();
    else if (id==VDEMUX) op = new VDemux();
    else if (id==REAL) op = new Real();
    else if (id==IMAG) op = new Imag();
    else if (id==CMPLX) op = new Cmplx();
    else if (id==CONJ) op = new Conjugate();
    else if (id==MOD) op = new Modulo();
    else if (id==MODULO) op = new Modulo();
    else if (id==MODULOT) op = new Modulo();
    else if (id==MODULOF) op = new ModuloFloor();
    else if (id==MODULOE) op = new ModuloEuclid();
    else if (id==DOT) op = new DotProduct();
    else if (id==ROUND) op = new Round();
    else if (id==CEIL) op = new Ceil();
    else if (id==FLOOR) op = new Floor();
    else if (id==FIX) op = new Fix();
    else if (id==MAG) op = new Magnitude();
    else if (id==MAG2) op = new MagSquared();
    else if (id==PHASE) op = new Phase();
    else if (id==WRAP) op = new Wrap();
    else if (id==POLAR) op = new Polar();
    else if (id==RECT) op = new Rectangular();
    else if (id==LN) op = new Logarithm();
    else if (id==LNB) op = new LogarithmBounded();
    else if (id==EXP) op = new Exponent();
    else if (id==SQUARE) op = new Square();
    else if (id==SQRT) op = new SquareRoot();
    else if (id==SIN) op = new Sine();
    else if (id==COS) op = new Cosine();
    else if (id==TAN) op = new Tangent();
    else if (id==ASIN) op = new ArcSine();
    else if (id==ACOS) op = new ArcCosine();
    else if (id==ATAN) op = new ArcTan();
    else if (id==ATAN2) op = new ArcTan2();
    else if (id==BOR) op = new BitOr();
    else if (id==BXOR) op = new BitXOr();
    else if (id==BAND) op = new BitAnd();
    else if (id==BNOT) op = new BitNot();
    else if (id==BREV) op = new BitReverse();
    else if (id==LT) op = new CompareLT();
    else if (id==GT) op = new CompareGT();
    else if (id==LE) op = new CompareLE();
    else if (id==GE) op = new CompareGE();
    else if (id==EQ) op = new CompareEQ();
    else if (id==SEL) op = new Select();
    else if (id==POWER2) op = new Power2GE();
    else if (id==FFT) op = new Fft();
    else if (id==RANDOM) op = new Random();
    else if (id==RANDOMP) op = new RandomPseudo();
    else if (id==RANDOMS) op = new RandomSecure();
    else if (id==DBF) op = new Dbf();
    else if (id==FACTORIAL) op = new Factorial();
    return op;
  }


  /** Get an operator based on its identifier symbol.
      @param id The identifier for the operator.
                (See <code>Operators.cnf</code> for the definitions of the identifiers.)
      @return A new instance of the operator identified by the identifier symbol provided,
              or <code>null</code> if the identifier provided does not match one of the valid operators.
   */
  public static Operator get (String id) {
    Operator op=null;
    if (id==null||id.length()==0) op=null;
    else if (id.equals("NOOP")) op = new Noop();
    else if (id.equals("ADD") || id.equals("+")) op = new Add();
    else if (id.equals("SUB") || id.equals("-")) op = new Subtract();
    else if (id.equals("MUL") || id.equals("*")) op = new Multiply();
    else if (id.equals("DIV") || id.equals("/")) op = new Divide();
    else if (id.equals("ADDC") || id.equals("~+")) op = new Add(Operator.CNJB);
    else if (id.equals("SUBC") || id.equals("~-")) op = new Subtract(Operator.CNJB);
    else if (id.equals("MULC") || id.equals("~*")) op = new Multiply(Operator.CNJB);
    else if (id.equals("DIVC") || id.equals("~/")) op = new Divide(Operator.CNJB);
    else if (id.equals("POW") || id.equals("**")) op = new Power();
    else if (id.equals("MIN")) op = new Minimum();
    else if (id.equals("MINIMUM")) op = new Minimum();
    else if (id.equals("MAX")) op = new Maximum();
    else if (id.equals("MAXIMUM")) op = new Maximum();
    else if (id.equals("CLIP")) op = new Clip();
    else if (id.equals("MUX")) op = new Mux();
    else if (id.equals("VMUX")) op = new VMux();
    else if (id.equals("DEMUX")) op = new Demux();
    else if (id.equals("VDEMUX")) op = new VDemux();
    else if (id.equals("REAL")) op = new Real();
    else if (id.equals("IMAG")) op = new Imag();
    else if (id.equals("CMPLX")) op = new Cmplx();
    else if (id.equals("CONJ") || id.equals("~")) op = new Conjugate();
    else if (id.equals("MOD")) op = new Modulo();
    else if (id.equals("MODULO")) op = new Modulo();
    else if (id.equals("MODULOT")) op = new Modulo();
    else if (id.equals("MOD/T")) op = new Modulo();
    else if (id.equals("MODULOF")) op = new ModuloFloor();
    else if (id.equals("MOD/F")) op = new ModuloFloor();
    else if (id.equals("MODULOE")) op = new ModuloEuclid();
    else if (id.equals("MOD/E")) op = new ModuloEuclid();
    else if (id.equals("DOT")) op = new DotProduct();
    else if (id.equals("ROUND")) op = new Round();
    else if (id.equals("CEIL")) op = new Ceil();
    else if (id.equals("FLOOR")) op = new Floor();
    else if (id.equals("FIX")) op = new Fix();
    else if (id.equals("MAG")) op = new Magnitude();
    else if (id.equals("ABS")) op = new Magnitude();
    else if (id.equals("MAG2")) op = new MagSquared();
    else if (id.equals("PHASE")) op = new Phase();
    else if (id.equals("PHASED")) op = new Phase(0,RAD2DEG);
    else if (id.equals("PHASEC")) op = new Phase(0,RAD2CYC);
    else if (id.equals("WRAP")) op = new Wrap();
    else if (id.equals("UNWRAP")) op = new Wrap(1,PI);
    else if (id.equals("UNWRAPD")) op = new Wrap(1,180.0);
    else if (id.equals("UNWRAPC")) op = new Wrap(1,0.5);
    else if (id.equals("POLAR")) op = new Polar();
    else if (id.equals("POLARD")) op = new Polar(0,RAD2DEG);
    else if (id.equals("POLARC")) op = new Polar(0,RAD2CYC);
    else if (id.equals("RECT")) op = new Rectangular();
    else if (id.equals("RECTD")) op = new Rectangular(0,DEG2RAD);
    else if (id.equals("RECTC")) op = new Rectangular(0,CYC2RAD);
    else if (id.equals("LN")) op = new Logarithm();
    else if (id.equals("LOG")) op = new Logarithm(0,LN2LOG);
    else if (id.equals("DB")) op = new Logarithm(0,LN2DB);
    else if (id.equals("LNB")) op = new LogarithmBounded();
    else if (id.equals("LN/B")) op = new LogarithmBounded();
    else if (id.equals("LOG/B")) op = new LogarithmBounded(0,LN2LOG);
    else if (id.equals("DB/B")) op = new LogarithmBounded(0,LN2DB);
    else if (id.equals("EXP")) op = new Exponent();
    else if (id.equals("SQUARE")) op = new Square();
    else if (id.equals("SQRT")) op = new SquareRoot();
    else if (id.equals("SIN")) op = new Sine();
    else if (id.equals("SIND")) op = new Sine(0,DEG2RAD);
    else if (id.equals("SINC")) op = new Sine(0,CYC2RAD);
    else if (id.equals("COS")) op = new Cosine();
    else if (id.equals("COSD")) op = new Cosine(0,DEG2RAD);
    else if (id.equals("COSC")) op = new Cosine(0,CYC2RAD);
    else if (id.equals("TAN")) op = new Tangent();
    else if (id.equals("TAND")) op = new Tangent(0,DEG2RAD);
    else if (id.equals("TANC")) op = new Tangent(0,CYC2RAD);
    else if (id.equals("ASIN")) op = new ArcSine();
    else if (id.equals("ASIND")) op = new ArcSine(0,RAD2DEG);
    else if (id.equals("ASINC")) op = new ArcSine(0,RAD2CYC);
    else if (id.equals("ACOS")) op = new ArcCosine();
    else if (id.equals("ACOSD")) op = new ArcCosine(0,RAD2DEG);
    else if (id.equals("ACOSC")) op = new ArcCosine(0,RAD2CYC);
    else if (id.equals("ATAN")) op = new ArcTan();
    else if (id.equals("ATAND")) op = new ArcTan(0,RAD2DEG);
    else if (id.equals("ATANC")) op = new ArcTan(0,RAD2CYC);
    else if (id.equals("ATAN2")) op = new ArcTan2();
    else if (id.equals("ATAN2D")) op = new ArcTan2(0,RAD2DEG);
    else if (id.equals("ATAN2C")) op = new ArcTan2(0,RAD2CYC);
    else if (id.equals("BOR")) op = new BitOr();
    else if (id.equals("BXOR")) op = new BitXOr();
    else if (id.equals("BAND")) op = new BitAnd();
    else if (id.equals("BNOT")) op = new BitNot();
    else if (id.equals("BREV")) op = new BitReverse();
    else if (id.equals("LT")) op = new CompareLT();
    else if (id.equals("GT")) op = new CompareGT();
    else if (id.equals("LE")) op = new CompareLE();
    else if (id.equals("GE")) op = new CompareGE();
    else if (id.equals("EQ")) op = new CompareEQ();
    else if (id.equals("SEL") || id.equals("?:")) op = new Select();
    else if (id.equals("POWER2")) op = new Power2GE();
    else if (id.equals("FFT")) op = new Fft();
    else if (id.equals("RANDOM")) op = new Random();
    else if (id.equals("RANDOMP")) op = new RandomPseudo();
    else if (id.equals("RANDOM/P")) op = new RandomPseudo();
    else if (id.equals("RANDOMS")) op = new RandomSecure();
    else if (id.equals("RANDOM/S")) op = new RandomSecure();
    else if (id.equals("DBF")) op = new Dbf();
    else if (id.equals("FACTORIAL") || id.equals("N!")) op = new Factorial();
    return op;
  }
}
