public InvariantStatus add_modified(double[] a, int count) { // System.out.println ("common: " + ArraysMDE.toString (a)); if (a == null) { return InvariantStatus.FALSIFIED; } else if (intersect == null) { intersect = a; return InvariantStatus.NO_CHANGE; } else { double[] tmp = new double[intersect.length]; int size = 0; for (int i = 0; i < a.length; i++) { // if (a[i] in intersect) && !(a[i] in tmp), add a[i] to tmp int ii = Global.fuzzy.indexOf(intersect, a[i]); if ((ii != -1) && (Global.fuzzy.indexOf(ArraysMDE.subarray(tmp, 0, size), a[i]) == -1)) { // System.out.println ("adding " + intersect[ii] + " at " + size); // Carefully add the existing intersect value and not a[i]. These // are not necessarily the same when fuzzy floating point // comparisons are active. tmp[size++] = intersect[ii]; } } if (size == 0) { return InvariantStatus.FALSIFIED; } intersect = ArraysMDE.subarray(tmp, 0, size); } intersect = Intern.intern(intersect); elts++; return InvariantStatus.NO_CHANGE; }
public ValueAndModified computeValueAndModifiedImpl(ValueTuple vt) { int source_mod = base.getModified(vt); if (source_mod == ValueTuple.MISSING_NONSENSICAL) return ValueAndModified.MISSING_NONSENSICAL; Object val = base.getValue(vt); if (val == null) return ValueAndModified.MISSING_NONSENSICAL; if (base.rep_type == ProglangType.DOUBLE_ARRAY) { double[] val_array = (double[]) val; if (val_array.length < minLength) return ValueAndModified.MISSING_NONSENSICAL; int real_index = (index < 0 ? val_array.length + index : index); return new ValueAndModified(Intern.internedDouble(val_array[real_index]), source_mod); } else { Object[] val_array = (Object[]) val; if (val_array.length < minLength) return ValueAndModified.MISSING_NONSENSICAL; int real_index = (index < 0 ? val_array.length + index : index); return new ValueAndModified(val_array[real_index], source_mod); } }