Exemple #1
0
  public void testDeepEqualsWhenDeltaAreNotEquals() throws Exception {
    Amendment a1 =
        Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
    Amendment a2 =
        Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
    Epoch epoch1 = new Epoch();
    epoch1.setName("Epoch");
    epoch1.setGridId("GridId1");
    Delta<Epoch> delta1 = Delta.createDeltaFor(epoch1);
    delta1.setGridId("delta1");
    delta1.addChanges(PropertyChange.create("name", "A", "C"), Add.create(new StudySegment()));
    a1.addDelta(delta1);
    Epoch epoch2 = new Epoch();
    epoch2.setName("Epoch");
    epoch2.setGridId("GridId1");
    Delta<Epoch> delta2 = Delta.createDeltaFor(epoch2);
    delta2.setGridId("delta1");
    delta2.addChanges(PropertyChange.create("name", "A", "B"), Add.create(new StudySegment()));
    a2.addDelta(delta2);
    Differences differences = a1.deepEquals(a2);
    assertFalse(differences.getChildDifferences().isEmpty());

    assertChildDifferences(
        differences,
        new String[] {"delta for epoch GridId1", "property change for name"},
        "new value \"C\" does not match \"B\"");
  }
 @Override
 public CompoundInterval visit(
     Add<CompoundInterval> pAdd,
     Map<? extends String, ? extends InvariantsFormula<CompoundInterval>> pEnvironment) {
   return weakAdd(
       pAdd.getSummand1().accept(EVALUATION_VISITOR, pEnvironment),
       pAdd.getSummand2().accept(EVALUATION_VISITOR, pEnvironment));
 }
  private List<Add> appendAddConfiguration(Operation operation) throws WindowsOperationException {

    List<Add> addList = new ArrayList<Add>();
    Gson gson = new Gson();

    if (SyncmlCommandType.WIFI.getValue().equals(operation.getCode())) {

      Add add = new Add();

      String operationCode = operation.getCode();

      Wifi wifiObject = gson.fromJson((String) operation.getPayLoad(), Wifi.class);

      String data =
          "&lt;?xml version=&quot;1.0&quot;?&gt;&lt;WLANProfile"
              + "xmlns=&quot;http://www.microsoft.com/networking/WLAN/profile/v1&quot;&gt;&lt;name&gt;"
              + wifiObject.getNetworkName()
              + "&lt;/name&gt;&lt;SSIDConfig&gt;&lt;SSID&gt;&lt;name&gt;"
              + wifiObject.getSsid()
              + "&lt;/name&gt;&lt;/SSID&gt;&lt;/SSIDConfig&gt;&lt;connectionType&gt;"
              + wifiObject.getConnectionType()
              + "&lt;/connectionType&gt;&lt;connectionMode&gt;"
              + wifiObject.getConnectionMode()
              + "&lt;/connectionMode&gt;&lt;MSM&gt;&lt;security&gt;&lt;"
              + "authEncryption&gt;&lt;authentication&gt;"
              + wifiObject.getAuthentication()
              + "&lt;/authentication&gt;&lt;encryption&gt;"
              + wifiObject.getEncryption()
              + "&lt;/encryption&gt;&lt;/authEncryption&gt;&lt;sharedKey&gt;&lt;keyType&gt;"
              + wifiObject.getKeyType()
              + "&lt;/keyType&gt;&lt;protected&gt;"
              + wifiObject.getProtection()
              + "&lt;/protected&gt;&lt;keyMaterial&gt;"
              + wifiObject.getKeyMaterial()
              + "&lt;/keyMaterial&gt;&lt;/sharedKey&gt;&lt;/security&gt;&lt;/MSM&gt;&lt;/WLANProfile&gt;";

      Meta meta = new Meta();
      meta.setFormat("chr");
      List<Item> items = new ArrayList<Item>();

      for (Configure configure : Configure.values()) {
        if (operationCode != null && operationCode.equals(configure.name())) {
          Target target = new Target();
          target.setLocURI(configure.getCode());
          items.get(0).setTarget(target);
        }
      }
      items.get(0).setMeta(meta);
      items.get(0).setData(data);

      add.setCommandId(301);
      add.setItems(items);
      addList.add(add);
      return addList;
    }
    return null;
  }
Exemple #4
0
  private void STEP2(int A, int B, int MAC, int MIC, short[] LAR, int index) {

    short temp = 0;

    temp = Add.GSM_MULT((short) A, LAR[index]);
    temp = Add.GSM_ADD(temp, (short) B);
    temp = Add.GSM_ADD(temp, (short) 256);
    temp = Add.SASR(temp, 9);
    LAR[index] = (short) (temp > MAC ? MAC - MIC : (temp < MIC ? 0 : temp - MIC));
  }
Exemple #5
0
  public void checkAutoDisable(LinearRamp ramp, UnitGate envelope) throws InterruptedException {
    double tolerance = 0.01;
    Add adder = new Add();
    synthesisEngine.add(adder);

    envelope.output.connect(adder.inputA);
    if (ramp.getCircuit() != null) {
      ramp.output.connect(adder.inputB);
    }

    envelope.input.setAutoDisableEnabled(true);
    envelope.setEnabled(false);

    // set up so ramp value should equal time
    ramp.current.set(0.0);
    ramp.input.set(1.0);
    ramp.time.set(1.0);

    synthesisEngine.start();
    // pull from final adder
    adder.start();

    time = synthesisEngine.getCurrentTime();
    time += 0.1;
    synthesisEngine.sleepUntil(time);
    assertEquals("still idling", 0.0, envelope.output.getValue());
    assertEquals("ramp frozen at beginning", 0.0, ramp.output.getValue(), tolerance);

    // run multiple times to make sure we can retrigger the envelope.
    for (int i = 0; i < 3; i++) {
      double level = ramp.output.getValue();
      // Trigger the envelope using trigger()
      envelope.input.on();
      time += 0.1;
      level += 0.1;
      synthesisEngine.sleepUntil(time);
      assertEquals("ramp going up " + i, level, ramp.output.getValue(), tolerance);
      assertTrue("enabled at peak", envelope.isEnabled());

      envelope.input.off();
      time += 0.1;
      level += 0.1;
      synthesisEngine.sleepUntil(time);
      assertEquals("ramp going up more " + i, level, ramp.output.getValue(), tolerance);
      assertEquals("at bottom", 0.0, envelope.output.getValue(), 0.1);

      time += 0.2;
      synthesisEngine.sleepUntil(time);
      assertEquals("ramp frozen " + i, level, ramp.output.getValue(), tolerance);
    }
  }
Exemple #6
0
  public void testMergeWithEquivalentAddPresent() throws Exception {
    delta.addChange(Add.create(ssc, 2));

    remove.setChild(ssc);
    remove.mergeInto(delta, NOW);

    assertEquals("Remove should have canceled add", 0, delta.getChanges().size());
  }
Exemple #7
0
  public void testMergeWithAddFollowedByReorderCancelsBoth() throws Exception {
    delta.addChange(Add.create(ssc, 2));
    Reorder.create(ssc, 2, 1).mergeInto(delta, NOW);

    remove.setChild(ssc);
    remove.mergeInto(delta, NOW);

    assertEquals("Remove should have canceled add and reorder", 0, delta.getChanges().size());
  }
Exemple #8
0
 public static void init() {
   Add.init();
   Address.init();
   Align.init();
   Alloc.init();
   Anchor.init();
   And.init();
   Bad.init();
   Bitcast.init();
   Block.init();
   Builtin.init();
   Call.init();
   Cmp.init();
   Cond.init();
   Confirm.init();
   Const.init();
   Conv.init();
   CopyB.init();
   Deleted.init();
   Div.init();
   Dummy.init();
   End.init();
   Eor.init();
   Free.init();
   IJmp.init();
   Id.init();
   Jmp.init();
   Load.init();
   Member.init();
   Minus.init();
   Mod.init();
   Mul.init();
   Mulh.init();
   Mux.init();
   NoMem.init();
   Not.init();
   Offset.init();
   Or.init();
   Phi.init();
   Pin.init();
   Proj.init();
   Raise.init();
   Return.init();
   Sel.init();
   Shl.init();
   Shr.init();
   Shrs.init();
   Size.init();
   Start.init();
   Store.init();
   Sub.init();
   Switch.init();
   Sync.init();
   Tuple.init();
   Unknown.init();
 }
  @Override
  public Boolean visit(Add ast) {
    boolean checkLhs = ast.getLhs().accept(this);
    boolean checkRhs = ast.getRhs().accept(this);

    if (!(checkLhs && checkRhs)) return false;
    Type lhsType = ast.getLhs().typeOf(env);
    Type rhsType = ast.getRhs().typeOf(env);

    if (!(lhsType.isCompatibleToNumeric() && rhsType.isCompatibleToNumeric())) {
      addToErrorList(
          ast,
          "the operator + can not be applied to instances of type "
              + lhsType.getClass()
              + " and type "
              + rhsType.getClass());
      return false;
    }
    return true;
  }
Exemple #10
0
  public void testUpdatedDateWhenOneChangeHasAnUpdatedDate() throws Exception {
    a3.addDelta(
        Delta.createDeltaFor(
            new Epoch(), PropertyChange.create("name", "A", "B"), Add.create(new StudySegment())));
    a3.getDeltas()
        .get(0)
        .getChanges()
        .get(0)
        .setUpdatedDate(DateTools.createDate(2005, Calendar.MAY, 3));

    assertDayOfDate(2005, Calendar.MAY, 3, a3.getUpdatedDate());
  }
Exemple #11
0
 public void testDeepEqualsWhenNoOfDeltaAreDifferent() throws Exception {
   Amendment a1 =
       Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
   Amendment a2 =
       Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
   a1.addDelta(
       Delta.createDeltaFor(
           new Epoch(), PropertyChange.create("name", "A", "B"), Add.create(new StudySegment())));
   a2.addDelta(
       Delta.createDeltaFor(
           new Epoch(), PropertyChange.create("name", "A", "B"), Add.create(new StudySegment())));
   a2.addDelta(
       Delta.createDeltaFor(
           new Epoch(), PropertyChange.create("name", "A", "B"), Add.create(new StudySegment())));
   Differences differences = a1.deepEquals(a2);
   assertFalse(differences.getMessages().isEmpty());
   assertEquals(
       "Amendment are Equals",
       "number of deltas does not match: 1 != 2",
       differences.getMessages().get(0));
 }
Exemple #12
0
  public Object dot(Vector<Object> v1, Vector<Object> v2) throws ParseException {
    if (v1.size() != v2.size())
      throw new ParseException("Dot: both sides of dot must be same length");
    int len = v1.size();
    if (len < 1) throw new ParseException("Dot: empty vectors parsed");

    Object res = mul.mul(v1.elementAt(0), v2.elementAt(0));
    for (int i = 1; i < len; ++i) {
      res = add.add(res, mul.mul(v1.elementAt(i), v2.elementAt(i)));
    }
    return res;
  }
Exemple #13
0
  public static void main(String[] args) {

    Add add1 = new Add();
    Product mult1 = new Product();
    Add add2 = new Add();

    Map<String, Integer> vars1 = new HashMap<>();
    vars1.put("x", 6);
    vars1.put("y", 4);

    Variable x = new Variable("x");
    Variable y = new Variable("y");
    Number two = new Number(10);
    Number three = new Number(5);

    mult1.addArg(x, y);
    add1.addArg(two, three);
    add2.addArg(mult1, add1);

    System.out.println("Test Case 1:");
    System.out.println(add2.toString(vars1));
    System.out.println(add2.evaluate(vars1));
    System.out.println();

    System.out.println("External Iteration:");
    externalIterationExample(add2, vars1);
    System.out.println();

    System.out.println("Internal Iteration:");
    ArithmeticExpression.traverse(add2);
    System.out.println();

    Add add3 = new Add();
    Map<String, Integer> vars2 = new HashMap<>();
    System.out.println("Test Case 2: Add with no children");
    System.out.println(add3.toString(vars2));
    System.out.println(add3.evaluate(vars2));
    System.out.println();

    Product mult2 = new Product();
    Map<String, Integer> vars3 = new HashMap<>();
    System.out.println("Test Case 3: Multiply with no children");
    System.out.println(mult2.toString(vars3));
    System.out.println(mult2.evaluate(vars3));
  }
Exemple #14
0
  public void testMergeTwoIntoDeltaWithIndexesThenRemoveOne() throws Exception {
    StudySegment retained0 = setId(17, new StudySegment());
    StudySegment retained1 = setId(18, new StudySegment());
    StudySegment retained2 = setId(19, new StudySegment());
    delta.addChange(Add.create(retained0, 2));
    delta.addChange(Add.create(ssc, 3));
    delta.addChange(Add.create(retained1, 4));
    delta.addChange(Add.create(retained2, 5));

    remove.setChild(ssc);
    remove.mergeInto(delta, NOW);
    assertEquals("Wrong number of changes in delta", 3, delta.getChanges().size());
    Add add0 = (Add) delta.getChanges().get(0);
    Add add1 = (Add) delta.getChanges().get(1);
    Add add2 = (Add) delta.getChanges().get(2);
    assertAdd("Index for earlier retained add updated", retained0, 2, add0);
    assertChangeTime("Unchanged add time incorrectly updated", null, add0);
    assertAdd("Index for later retained add not updated", retained1, 3, add1);
    assertChangeTime("Updated add time not updated", NOW, add1);
    assertAdd("Index for later retained add not updated", retained2, 4, add2);
    assertChangeTime("Updated add time not updated", NOW, add2);
  }
Exemple #15
0
  /*
   *  The following scaling for r[..] and LAR[..] has been used:
   *
   *  r[..]   = integer( real_r[..]*32768. ); -1 <= real_r < 1.
   *  LAR[..] = integer( real_LAR[..] * 16384 );
   *  with -1.625 <= real_LAR <= 1.625
   */
  private void Transformation_to_Log_Area_Ratios(short[] r /* 0..7 IN/OUT */)
      throws IllegalArgumentException {

    short temp;

    /* Computation of the LAR[0..7] from the r[0..7]
     */
    for (int i = 0; i < 8; i++) {

      temp = r[i];
      temp = Add.GSM_ABS(temp);

      if (!(temp >= 0)) {
        throw new IllegalArgumentException(
            "Transformation_to_Log_Area_Ratios: temp = " + temp + " should be >= 0 ");
      }

      if (temp < 22118) {
        temp >>= 1;
      } else if (temp < 31130) {

        if (!(temp >= 11059)) {
          throw new IllegalArgumentException(
              "Transformation_to_Log_Area_Ratios: temp = " + temp + " should be >= 11059 ");
        }

        temp -= 11059;
      } else {
        if (!(temp >= 26112)) {
          throw new IllegalArgumentException(
              "Transformation_to_Log_Area_Ratios: temp = " + temp + " should be >= 26112 ");
        }

        temp -= 26112;
        temp <<= 2;
      }

      r[i] = (short) (r[i] < 0 ? -temp : temp);

      if (r[i] == Gsm_Def.MIN_WORD) {
        throw new IllegalArgumentException(
            "Transformation_to_Log_Area_Ratios: r["
                + i
                + "] = "
                + r[i]
                + " should not be = "
                + Gsm_Def.MIN_WORD);
      }
    }
  }
Exemple #16
0
 public void testDeepEqualsWhenNoDeltaFoundInAmendment() throws Exception {
   Amendment a1 =
       Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
   Amendment a2 =
       Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
   Epoch epoch1 = new Epoch();
   epoch1.setGridId("epoch1");
   Delta<Epoch> delta1 = Delta.createDeltaFor(epoch1);
   delta1.setGridId("delta1");
   delta1.addChanges(PropertyChange.create("name", "A", "B"), Add.create(new StudySegment()));
   a1.addDelta(delta1);
   StudySegment segment1 = new StudySegment();
   segment1.setGridId("segment1");
   Delta<StudySegment> delta2 = Delta.createDeltaFor(segment1);
   delta2.setGridId("delta1");
   delta2.addChanges(PropertyChange.create("name", "A", "B"), Add.create(new StudySegment()));
   a2.addDelta(delta2);
   Differences differences = a1.deepEquals(a2);
   assertFalse(differences.getMessages().isEmpty());
   assertEquals(
       "Amendments are equals",
       "no delta for epoch epoch1 found",
       differences.getMessages().get(0));
 }
Exemple #17
0
  public void testDeepEqualsWithMismatchedChanges() throws Exception {
    Amendment a = new Amendment();
    a.getDeltas()
        .add(
            setGridId(
                "D1",
                Delta.createDeltaFor(
                    setGridId("PC1", new PlannedCalendar()),
                    Add.create(setGridId("E1", new Epoch())))));
    Amendment b = new Amendment();
    b.getDeltas()
        .add(
            setGridId(
                "D1",
                Delta.createDeltaFor(
                    setGridId("PC1", new PlannedCalendar()),
                    Remove.create(setGridId("E1", new Epoch())))));

    assertChildDifferences(
        a.deepEquals(b),
        new String[] {"delta for planned calendar PC1"},
        "add of epoch:E1 replaced by remove of epoch:E1");
  }
Exemple #18
0
  private void Autocorrelation(short[] so) /* [0..159]  IN/OUT  */ throws IllegalArgumentException {

    int i = 0, sp_index = 0;
    short temp = 0, smax = 0, scalauto = 0;
    int L_temp = 0;
    int L_temp2 = 0;

    /*  Dynamic scaling of the array  s[0..159]
     */

    /*  Search for the maximum.
     */
    for (int k = 0; k <= 159; k++) {
      temp = Add.GSM_ADD(so[k], (short) 0);
      if (temp > smax) {
        smax = temp;
      }
    }

    /*  Computation of the scaling factor.
     */
    if (smax == 0) {
      scalauto = 0;
    } else {
      if (!(smax > 0)) {
        throw new IllegalArgumentException("Autocorrelation: smax = " + smax + " should be > 0.");
      }
      scalauto = (short) (4 - Add.gsm_norm((int) (smax << 16))); /* sub(4,..) */
    }

    /*  Scaling of the array s[0...159]
     */

    if (scalauto > 0) {
      if (!(scalauto <= 4)) {
        throw new IllegalArgumentException(
            "Autocorrelation: scalauto = " + scalauto + " should be <= 4.");
      }
      switch (scalauto) {
        case 1:
          for (int k = 0; k <= 159; k++) {
            so[k] = Add.GSM_MULT_R(so[k], (short) 16384);
          }
          break;
        case 2:
          for (int k = 0; k <= 159; k++) {
            so[k] = Add.GSM_MULT_R(so[k], (short) (16384 >> 1));
          }
          break;
        case 3:
          for (int k = 0; k <= 159; k++) {
            so[k] = Add.GSM_MULT_R(so[k], (short) (16384 >> 2));
          }
          break;
        case 4:
          for (int k = 0; k <= 159; k++) {
            so[k] = Add.GSM_MULT_R(so[k], (short) (16384 >> 3));
          }
          break;
      }
    }

    /*  CoreCompute the L_ACF[..].
     */
    short[] sp = so;
    short sl = sp[sp_index];

    // Zero out L_ACF
    int[] temp_arr = {0, 0, 0, 0, 0, 0, 0, 0, 0};
    System.arraycopy(temp_arr, 0, L_ACF, 0, L_ACF.length);

    L_ACF[0] += (int) (sl * sp[(sp_index - 0)]);

    sl = sp[++sp_index];
    L_ACF[0] += (int) (sl * sp[(sp_index - 0)]);
    L_ACF[1] += (int) (sl * sp[(sp_index - 1)]);

    sl = sp[++sp_index];
    L_ACF[0] += (int) (sl * sp[(sp_index - 0)]);
    L_ACF[1] += (int) (sl * sp[(sp_index - 1)]);
    L_ACF[2] += (int) (sl * sp[(sp_index - 2)]);

    sl = sp[++sp_index];
    L_ACF[0] += (int) (sl * sp[(sp_index - 0)]);
    L_ACF[1] += (int) (sl * sp[(sp_index - 1)]);
    L_ACF[2] += (int) (sl * sp[(sp_index - 2)]);
    L_ACF[3] += (int) (sl * sp[(sp_index - 3)]);

    sl = sp[++sp_index];
    L_ACF[0] += (int) (sl * sp[(sp_index - 0)]);
    L_ACF[1] += (int) (sl * sp[(sp_index - 1)]);
    L_ACF[2] += (int) (sl * sp[(sp_index - 2)]);
    L_ACF[3] += (int) (sl * sp[(sp_index - 3)]);
    L_ACF[4] += (int) (sl * sp[(sp_index - 4)]);

    sl = sp[++sp_index];
    L_ACF[0] += (int) (sl * sp[(sp_index - 0)]);
    L_ACF[1] += (int) (sl * sp[(sp_index - 1)]);
    L_ACF[2] += (int) (sl * sp[(sp_index - 2)]);
    L_ACF[3] += (int) (sl * sp[(sp_index - 3)]);
    L_ACF[4] += (int) (sl * sp[(sp_index - 4)]);
    L_ACF[5] += (int) (sl * sp[(sp_index - 5)]);

    sl = sp[++sp_index];
    L_ACF[0] += (int) (sl * sp[(sp_index - 0)]);
    L_ACF[1] += (int) (sl * sp[(sp_index - 1)]);
    L_ACF[2] += (int) (sl * sp[(sp_index - 2)]);
    L_ACF[3] += (int) (sl * sp[(sp_index - 3)]);
    L_ACF[4] += (int) (sl * sp[(sp_index - 4)]);
    L_ACF[5] += (int) (sl * sp[(sp_index - 5)]);
    L_ACF[6] += (int) (sl * sp[(sp_index - 6)]);

    sl = sp[++sp_index];
    L_ACF[0] += (int) (sl * sp[(sp_index - 0)]);
    L_ACF[1] += (int) (sl * sp[(sp_index - 1)]);
    L_ACF[2] += (int) (sl * sp[(sp_index - 2)]);
    L_ACF[3] += (int) (sl * sp[(sp_index - 3)]);
    L_ACF[4] += (int) (sl * sp[(sp_index - 4)]);
    L_ACF[5] += (int) (sl * sp[(sp_index - 5)]);
    L_ACF[6] += (int) (sl * sp[(sp_index - 6)]);
    L_ACF[7] += (int) (sl * sp[(sp_index - 7)]);

    sl = sp[++sp_index];

    for (i = sp_index; i < 160; ++i) {

      sl = sp[i];

      L_ACF[0] += (int) (sl * sp[(i - 0)]);
      L_ACF[1] += (int) (sl * sp[(i - 1)]);
      L_ACF[2] += (int) (sl * sp[(i - 2)]);
      L_ACF[3] += (int) (sl * sp[(i - 3)]);
      L_ACF[4] += (int) (sl * sp[(i - 4)]);
      L_ACF[5] += (int) (sl * sp[(i - 5)]);
      L_ACF[6] += (int) (sl * sp[(i - 6)]);
      L_ACF[7] += (int) (sl * sp[(i - 7)]);
      L_ACF[8] += (int) (sl * sp[(i - 8)]);
    }

    for (int k = 0; k < 9; k++) {
      L_ACF[k] <<= 1;
    }

    /*   Rescaling of the array s[0..159]
     */
    if (scalauto > 0) {
      if (!(scalauto <= 4)) {
        throw new IllegalArgumentException(
            "Autocorrelation: scalauto = " + scalauto + " should be <= 4.");
      }

      for (int k = 0; k < 160; k++) {
        so[k] <<= scalauto;
      }
    }
  }
Exemple #19
0
 public double add(double n1, double n2) throws RemoteException {
   return (addService.add(n1, n2));
 }
Exemple #20
0
 public static void main(String args[]) {
   Add p = new Add();
   p.seta(300);
   p.setb(200);
   System.out.println("a=" + p.geta() + " b=" + p.getb() + " a+b==" + p.getadd());
 }
 @Override
 public Boolean visit(Add<T> pAdd, MemoryLocation pVarName) {
   return pAdd.getSummand1().accept(this, pVarName) || pAdd.getSummand2().accept(this, pVarName);
 }
Exemple #22
0
  private void Reflection_coefficients(short[] r /* 0...7   OUT */)
      throws IllegalArgumentException {

    short temp = 0;
    int ltmp = 0;
    int r_index = 0;

    short[] ACF = new short[9]; /* 0..8 */
    short[] P = new short[9]; /* 0..8 */
    short[] K = new short[9]; /* 2..8 */

    /*  Schur recursion with 16 bits arithmetic.
     */

    if (L_ACF[0] == 0) {
      /* everything is the same. */
      for (int i = 0; i < 8; i++) {
        r[i] = 0;
      }
      return;
    }

    if (L_ACF[0] == 0) {
      throw new IllegalArgumentException(
          "Reflection_coefficients: L_ACF[0] = " + L_ACF[0] + " should not = 0.");
    }

    temp = Add.gsm_norm(L_ACF[0]);

    if (!(temp >= 0 && temp < 32)) {
      throw new IllegalArgumentException(
          "Reflection_coefficients: temp = " + temp + " should be >= 0 and < 32.");
    }

    /* ? overflow ? */
    for (int i = 0; i <= 8; i++) {
      ACF[i] = Add.SASR(L_ACF[i] << temp, 16);
    }

    /*   Initialize array P[..] and K[..] for the recursion.
     */

    System.arraycopy(ACF, 0, K, 0, 7);

    System.arraycopy(ACF, 0, P, 0, 8);

    /*   CoreCompute reflection coefficients
     */
    for (int n = 1; n <= 8; n++, r_index++) {

      temp = P[1];
      temp = Add.GSM_ABS(temp);
      if (P[0] < temp) {
        for (int i = n; i < 8; i++) {
          r[i] = 0;
        }
        return;
      }

      r[r_index] = Add.gsm_div(temp, P[0]);

      if (!(r[r_index] >= 0)) {
        throw new IllegalArgumentException(
            "Reflection_coefficients: r[" + r_index + "] = " + r[r_index] + " should be >= 0");
      }

      if (P[1] > 0) {
        /* r[n] = sub(0, r[n]) */
        r[r_index] = (short) (-(r[r_index]));
      }

      if (r[r_index] == Gsm_Def.MIN_WORD) {
        throw new IllegalArgumentException(
            "Reflection_coefficients: r["
                + r_index
                + "] = "
                + r[r_index]
                + " should not be "
                + Gsm_Def.MIN_WORD);
      }
      if (n == 8) {
        return;
      }

      /*  Schur recursion
       */
      temp = Add.GSM_MULT_R(P[1], r[r_index]);
      P[0] = Add.GSM_ADD(P[0], temp);

      for (int m = 1; m <= 8 - n; m++) {
        temp = Add.GSM_MULT_R(K[m], r[r_index]);
        P[m] = Add.GSM_ADD(P[m + 1], temp);

        temp = Add.GSM_MULT_R(P[m + 1], r[r_index]);
        K[m] = Add.GSM_ADD(K[m], temp);
      }
    }
  }