/** {@inheritDoc} */
 public OpenMapRealVector append(double[] a) {
   OpenMapRealVector res = new OpenMapRealVector(this, a.length);
   for (int i = 0; i < a.length; i++) {
     res.setEntry(i + virtualSize, a[i]);
   }
   return res;
 }
 /** {@inheritDoc} */
 public OpenMapRealVector add(double[] v) throws IllegalArgumentException {
   checkVectorDimensions(v.length);
   OpenMapRealVector res = new OpenMapRealVector(getDimension());
   for (int i = 0; i < v.length; i++) {
     res.setEntry(i, v[i] + getEntry(i));
   }
   return res;
 }
 /**
  * Optimized method to append a OpenMapRealVector.
  *
  * @param v vector to append
  * @return The result of appending <code>v</code> to self
  */
 public OpenMapRealVector append(OpenMapRealVector v) {
   OpenMapRealVector res = new OpenMapRealVector(this, v.getDimension());
   Iterator iter = v.entries.iterator();
   while (iter.hasNext()) {
     iter.advance();
     res.setEntry(iter.key() + virtualSize, iter.value());
   }
   return res;
 }
 /** {@inheritDoc} */
 public OpenMapRealVector ebeDivide(RealVector v) throws IllegalArgumentException {
   checkVectorDimensions(v.getDimension());
   OpenMapRealVector res = new OpenMapRealVector(this);
   Iterator iter = res.entries.iterator();
   while (iter.hasNext()) {
     iter.advance();
     res.setEntry(iter.key(), iter.value() / v.getEntry(iter.key()));
   }
   return res;
 }
 /** {@inheritDoc} */
 public OpenMapRealVector ebeMultiply(double[] v) throws IllegalArgumentException {
   checkVectorDimensions(v.length);
   OpenMapRealVector res = new OpenMapRealVector(this);
   Iterator iter = res.entries.iterator();
   while (iter.hasNext()) {
     iter.advance();
     res.setEntry(iter.key(), iter.value() * v[iter.key()]);
   }
   return res;
 }
 /** {@inheritDoc} */
 public OpenMapRealVector subtract(double[] v) throws IllegalArgumentException {
   checkVectorDimensions(v.length);
   OpenMapRealVector res = new OpenMapRealVector(this);
   for (int i = 0; i < v.length; i++) {
     if (entries.containsKey(i)) {
       res.setEntry(i, entries.get(i) - v[i]);
     } else {
       res.setEntry(i, -v[i]);
     }
   }
   return res;
 }
 /**
  * Optimized method to compute the outer product.
  *
  * @param v The vector to comput the outer product on
  * @return The outer product of <code>this</code> and <code>v</code>
  * @throws IllegalArgumentException If the dimensions don't match
  */
 public OpenMapRealMatrix outerproduct(OpenMapRealVector v) throws IllegalArgumentException {
   checkVectorDimensions(v.getDimension());
   OpenMapRealMatrix res = new OpenMapRealMatrix(virtualSize, virtualSize);
   Iterator iter = entries.iterator();
   while (iter.hasNext()) {
     iter.advance();
     Iterator iter2 = v.getEntries().iterator();
     while (iter2.hasNext()) {
       iter2.advance();
       res.setEntry(iter.key(), iter2.key(), iter.value() * iter2.value());
     }
   }
   return res;
 }
 /** {@inheritDoc} */
 public OpenMapRealVector getSubVector(int index, int n) throws MatrixIndexException {
   checkIndex(index);
   checkIndex(index + n - 1);
   OpenMapRealVector res = new OpenMapRealVector(n);
   int end = index + n;
   Iterator iter = entries.iterator();
   while (iter.hasNext()) {
     iter.advance();
     int key = iter.key();
     if (key >= index && key < end) {
       res.setEntry(key - index, iter.value());
     }
   }
   return res;
 }
 /**
  * Optimized method to add two OpenMapRealVectors.
  *
  * @param v Vector to add with
  * @return The sum of <code>this</code> with <code>v</code>
  * @throws IllegalArgumentException If the dimensions don't match
  */
 public OpenMapRealVector add(OpenMapRealVector v) throws IllegalArgumentException {
   checkVectorDimensions(v.getDimension());
   OpenMapRealVector res = (OpenMapRealVector) copy();
   Iterator iter = v.getEntries().iterator();
   while (iter.hasNext()) {
     iter.advance();
     int key = iter.key();
     if (entries.containsKey(key)) {
       res.setEntry(key, entries.get(key) + iter.value());
     } else {
       res.setEntry(key, iter.value());
     }
   }
   return res;
 }
 /**
  * Distance between two vectors.
  *
  * <p>This method computes the distance consistent with L<sub>1</sub> norm, i.e. the sum of the
  * absolute values of elements differences.
  *
  * @param v vector to which distance is requested
  * @return distance between two vectors.
  */
 public double getL1Distance(OpenMapRealVector v) {
   double max = 0;
   Iterator iter = entries.iterator();
   while (iter.hasNext()) {
     iter.advance();
     double delta = Math.abs(iter.value() - v.getEntry(iter.key()));
     max += delta;
   }
   iter = v.getEntries().iterator();
   while (iter.hasNext()) {
     iter.advance();
     int key = iter.key();
     if (!entries.containsKey(key)) {
       double delta = Math.abs(iter.value());
       max += Math.abs(delta);
     }
   }
   return max;
 }
 /**
  * Optimized method to compute distance.
  *
  * @param v The vector to compute distance to
  * @return The distance from <code>this</code> and <code>v</code>
  * @throws IllegalArgumentException If the dimensions don't match
  */
 public double getDistance(OpenMapRealVector v) throws IllegalArgumentException {
   Iterator iter = entries.iterator();
   double res = 0;
   while (iter.hasNext()) {
     iter.advance();
     int key = iter.key();
     double delta;
     delta = iter.value() - v.getEntry(key);
     res += delta * delta;
   }
   iter = v.getEntries().iterator();
   while (iter.hasNext()) {
     iter.advance();
     int key = iter.key();
     if (!entries.containsKey(key)) {
       final double value = iter.value();
       res += value * value;
     }
   }
   return Math.sqrt(res);
 }
 /**
  * Implementation Note: This performs an exact comparison, and as a result it is possible for
  * {@code a.subtract(b}} to be the zero vector, while {@code a.equals(b) == false}. {@inheritDoc}
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (!(obj instanceof OpenMapRealVector)) {
     return false;
   }
   OpenMapRealVector other = (OpenMapRealVector) obj;
   if (virtualSize != other.virtualSize) {
     return false;
   }
   if (Double.doubleToLongBits(epsilon) != Double.doubleToLongBits(other.epsilon)) {
     return false;
   }
   Iterator iter = entries.iterator();
   while (iter.hasNext()) {
     iter.advance();
     double test = other.getEntry(iter.key());
     if (Double.doubleToLongBits(test) != Double.doubleToLongBits(iter.value())) {
       return false;
     }
   }
   iter = other.getEntries().iterator();
   while (iter.hasNext()) {
     iter.advance();
     double test = iter.value();
     if (Double.doubleToLongBits(test) != Double.doubleToLongBits(getEntry(iter.key()))) {
       return false;
     }
   }
   return true;
 }
  public void test11() throws Throwable {

    java.lang.Double var0 = new java.lang.Double((-1.0d));
    java.lang.Double var1 = new java.lang.Double(0.0d);
    java.lang.Double var2 = new java.lang.Double((-1.0d));
    double[] var3 = new double[] {var0, var1, var2};
    org.apache.commons.math.linear.ArrayRealVector var4 =
        new org.apache.commons.math.linear.ArrayRealVector(var3);
    java.lang.Double var5 = new java.lang.Double((-1.0d));
    java.lang.Double var6 = new java.lang.Double(0.0d);
    java.lang.Double var7 = new java.lang.Double((-1.0d));
    double[] var8 = new double[] {var5, var6, var7};
    org.apache.commons.math.linear.ArrayRealVector var9 =
        new org.apache.commons.math.linear.ArrayRealVector(var8);
    org.apache.commons.math.linear.RealVector var10 =
        var4.ebeDivide((org.apache.commons.math.linear.RealVector) var9);
    java.lang.Double var11 = new java.lang.Double((-1.0d));
    java.lang.Double var12 = new java.lang.Double(10.0d);
    java.lang.Double var13 = new java.lang.Double(100.0d);
    int var14 =
        org.apache.commons.math.util.MathUtils.compareTo(
            (double) var11, (double) var12, (double) var13);
    org.apache.commons.math.linear.RealVector var15 = var9.mapPowToSelf((double) var13);
    java.lang.Double[] var16 = new java.lang.Double[] {var13};
    org.apache.commons.math.linear.ArrayRealVector var17 =
        new org.apache.commons.math.linear.ArrayRealVector(var16);
    org.apache.commons.math.linear.RealVector var18 = var17.mapCbrtToSelf();
    org.apache.commons.math.linear.RealVector var19 = var17.mapFloorToSelf();
    org.apache.commons.math.linear.RealVector var20 = var17.mapCosh();
    org.apache.commons.math.linear.RealVector var21 = var17.mapAcos();
    java.lang.Double var22 = new java.lang.Double((-1.0d));
    double[] var23 = new double[] {var22};
    org.apache.commons.math.linear.OpenMapRealVector var24 =
        new org.apache.commons.math.linear.OpenMapRealVector(var23);
    java.lang.Double var25 = new java.lang.Double((-1.0d));
    double[] var26 = new double[] {var25};
    org.apache.commons.math.linear.OpenMapRealVector var27 =
        new org.apache.commons.math.linear.OpenMapRealVector(var26);
    org.apache.commons.math.linear.OpenMapRealVector var28 = var24.add(var27);
    org.apache.commons.math.linear.OpenMapRealVector var29 =
        new org.apache.commons.math.linear.OpenMapRealVector(var28);
    java.lang.Double var30 = new java.lang.Double((-1.0d));
    java.lang.Double var31 = new java.lang.Double(0.0d);
    java.lang.Double var32 = new java.lang.Double((-1.0d));
    double[] var33 = new double[] {var30, var31, var32};
    org.apache.commons.math.linear.ArrayRealVector var34 =
        new org.apache.commons.math.linear.ArrayRealVector(var33);
    java.lang.Double var35 = new java.lang.Double((-1.0d));
    java.lang.Double var36 = new java.lang.Double(0.0d);
    java.lang.Double var37 = new java.lang.Double((-1.0d));
    double[] var38 = new double[] {var35, var36, var37};
    org.apache.commons.math.linear.ArrayRealVector var39 =
        new org.apache.commons.math.linear.ArrayRealVector(var38);
    org.apache.commons.math.linear.RealVector var40 =
        var34.ebeDivide((org.apache.commons.math.linear.RealVector) var39);
    java.lang.Double var41 = new java.lang.Double(0.0d);
    java.lang.Double var42 = new java.lang.Double((-1.0d));
    java.lang.Double var43 = new java.lang.Double((-1.0d));
    int var44 =
        org.apache.commons.math.util.MathUtils.compareTo(
            (double) var41, (double) var42, (double) var43);
    org.apache.commons.math.linear.RealVector var45 = var34.mapDivide((double) var42);
    org.apache.commons.math.linear.RealVector var46 = var29.mapSubtractToSelf((double) var42);
    boolean var47 = var17.equals((java.lang.Object) var42);

    // Checks the contract:  equals-hashcode on var15 and var45
    assertTrue(
        "Contract failed: equals-hashcode on var15 and var45",
        var15.equals(var45) ? var15.hashCode() == var45.hashCode() : true);

    // Checks the contract:  equals-hashcode on var45 and var15
    assertTrue(
        "Contract failed: equals-hashcode on var45 and var15",
        var45.equals(var15) ? var45.hashCode() == var15.hashCode() : true);
  }
  public void test4() throws Throwable {

    java.lang.Double var0 = new java.lang.Double((-1.0d));
    double[] var1 = new double[] {var0};
    org.apache.commons.math.linear.OpenMapRealVector var2 =
        new org.apache.commons.math.linear.OpenMapRealVector(var1);
    int var3 = var2.getDimension();
    java.lang.Double var4 = new java.lang.Double((-1.0d));
    java.lang.Double var5 = new java.lang.Double(0.0d);
    java.lang.Double var6 = new java.lang.Double((-1.0d));
    double[] var7 = new double[] {var4, var5, var6};
    org.apache.commons.math.linear.ArrayRealVector var8 =
        new org.apache.commons.math.linear.ArrayRealVector(var7);
    java.lang.Double var9 = new java.lang.Double((-1.0d));
    java.lang.Double var10 = new java.lang.Double(0.0d);
    java.lang.Double var11 = new java.lang.Double((-1.0d));
    double[] var12 = new double[] {var9, var10, var11};
    org.apache.commons.math.linear.ArrayRealVector var13 =
        new org.apache.commons.math.linear.ArrayRealVector(var12);
    org.apache.commons.math.linear.RealVector var14 =
        var8.ebeDivide((org.apache.commons.math.linear.RealVector) var13);
    java.lang.Double var15 = new java.lang.Double((-1.0d));
    java.lang.Double var16 = new java.lang.Double(10.0d);
    java.lang.Double var17 = new java.lang.Double(100.0d);
    int var18 =
        org.apache.commons.math.util.MathUtils.compareTo(
            (double) var15, (double) var16, (double) var17);
    org.apache.commons.math.linear.RealVector var19 = var13.mapPowToSelf((double) var17);
    org.apache.commons.math.linear.ArrayRealVector var20 =
        new org.apache.commons.math.linear.ArrayRealVector(var3, var17);
    java.lang.Double var21 = new java.lang.Double((-1.0d));
    double[] var22 = new double[] {var21};
    org.apache.commons.math.linear.OpenMapRealVector var23 =
        new org.apache.commons.math.linear.OpenMapRealVector(var22);
    java.lang.Double var24 = new java.lang.Double((-1.0d));
    double[] var25 = new double[] {var24};
    org.apache.commons.math.linear.OpenMapRealVector var26 =
        new org.apache.commons.math.linear.OpenMapRealVector(var25);
    org.apache.commons.math.linear.OpenMapRealVector var27 = var23.add(var26);
    org.apache.commons.math.linear.OpenMapRealVector var28 =
        new org.apache.commons.math.linear.OpenMapRealVector(var27);
    java.lang.Double var29 = new java.lang.Double((-1.0d));
    java.lang.Double var30 = new java.lang.Double(0.0d);
    java.lang.Double var31 = new java.lang.Double((-1.0d));
    double[] var32 = new double[] {var29, var30, var31};
    org.apache.commons.math.linear.ArrayRealVector var33 =
        new org.apache.commons.math.linear.ArrayRealVector(var32);
    java.lang.Double var34 = new java.lang.Double((-1.0d));
    java.lang.Double var35 = new java.lang.Double(0.0d);
    java.lang.Double var36 = new java.lang.Double((-1.0d));
    double[] var37 = new double[] {var34, var35, var36};
    org.apache.commons.math.linear.ArrayRealVector var38 =
        new org.apache.commons.math.linear.ArrayRealVector(var37);
    org.apache.commons.math.linear.RealVector var39 =
        var33.ebeDivide((org.apache.commons.math.linear.RealVector) var38);
    java.lang.Double var40 = new java.lang.Double(0.0d);
    java.lang.Double var41 = new java.lang.Double((-1.0d));
    java.lang.Double var42 = new java.lang.Double((-1.0d));
    int var43 =
        org.apache.commons.math.util.MathUtils.compareTo(
            (double) var40, (double) var41, (double) var42);
    org.apache.commons.math.linear.RealVector var44 = var33.mapDivide((double) var41);
    org.apache.commons.math.linear.RealVector var45 = var28.mapSubtractToSelf((double) var41);
    org.apache.commons.math.linear.RealVector var46 = var20.projection(var45);

    // Checks the contract:  equals-hashcode on var19 and var44
    assertTrue(
        "Contract failed: equals-hashcode on var19 and var44",
        var19.equals(var44) ? var19.hashCode() == var44.hashCode() : true);

    // Checks the contract:  equals-hashcode on var44 and var19
    assertTrue(
        "Contract failed: equals-hashcode on var44 and var19",
        var44.equals(var19) ? var44.hashCode() == var19.hashCode() : true);
  }
  public void test13() throws Throwable {

    java.lang.Double var0 = new java.lang.Double((-1.0d));
    double[] var1 = new double[] {var0};
    org.apache.commons.math.linear.OpenMapRealVector var2 =
        new org.apache.commons.math.linear.OpenMapRealVector(var1);
    java.lang.Double var3 = new java.lang.Double((-1.0d));
    double[] var4 = new double[] {var3};
    org.apache.commons.math.linear.OpenMapRealVector var5 =
        new org.apache.commons.math.linear.OpenMapRealVector(var4);
    org.apache.commons.math.linear.OpenMapRealVector var6 = var2.add(var5);
    org.apache.commons.math.linear.OpenMapRealVector var7 =
        new org.apache.commons.math.linear.OpenMapRealVector(var6);
    java.lang.Double var8 = new java.lang.Double((-1.0d));
    java.lang.Double var9 = new java.lang.Double(0.0d);
    java.lang.Double var10 = new java.lang.Double((-1.0d));
    double[] var11 = new double[] {var8, var9, var10};
    org.apache.commons.math.linear.ArrayRealVector var12 =
        new org.apache.commons.math.linear.ArrayRealVector(var11);
    java.lang.Double var13 = new java.lang.Double((-1.0d));
    java.lang.Double var14 = new java.lang.Double(0.0d);
    java.lang.Double var15 = new java.lang.Double((-1.0d));
    double[] var16 = new double[] {var13, var14, var15};
    org.apache.commons.math.linear.ArrayRealVector var17 =
        new org.apache.commons.math.linear.ArrayRealVector(var16);
    org.apache.commons.math.linear.RealVector var18 =
        var12.ebeDivide((org.apache.commons.math.linear.RealVector) var17);
    java.lang.Double var19 = new java.lang.Double(0.0d);
    java.lang.Double var20 = new java.lang.Double((-1.0d));
    java.lang.Double var21 = new java.lang.Double((-1.0d));
    int var22 =
        org.apache.commons.math.util.MathUtils.compareTo(
            (double) var19, (double) var20, (double) var21);
    org.apache.commons.math.linear.RealVector var23 = var12.mapDivide((double) var20);
    org.apache.commons.math.linear.RealVector var24 = var7.mapSubtractToSelf((double) var20);
    double var25 = var7.getSparcity();
    java.lang.Double var26 = new java.lang.Double((-1.0d));
    double[] var27 = new double[] {var26};
    org.apache.commons.math.linear.OpenMapRealVector var28 =
        new org.apache.commons.math.linear.OpenMapRealVector(var27);
    int var29 = var28.getDimension();
    java.lang.Double var30 = new java.lang.Double((-1.0d));
    java.lang.Double var31 = new java.lang.Double(0.0d);
    java.lang.Double var32 = new java.lang.Double((-1.0d));
    double[] var33 = new double[] {var30, var31, var32};
    org.apache.commons.math.linear.ArrayRealVector var34 =
        new org.apache.commons.math.linear.ArrayRealVector(var33);
    java.lang.Double var35 = new java.lang.Double((-1.0d));
    java.lang.Double var36 = new java.lang.Double(0.0d);
    java.lang.Double var37 = new java.lang.Double((-1.0d));
    double[] var38 = new double[] {var35, var36, var37};
    org.apache.commons.math.linear.ArrayRealVector var39 =
        new org.apache.commons.math.linear.ArrayRealVector(var38);
    org.apache.commons.math.linear.RealVector var40 =
        var34.ebeDivide((org.apache.commons.math.linear.RealVector) var39);
    java.lang.Double var41 = new java.lang.Double((-1.0d));
    java.lang.Double var42 = new java.lang.Double(10.0d);
    java.lang.Double var43 = new java.lang.Double(100.0d);
    int var44 =
        org.apache.commons.math.util.MathUtils.compareTo(
            (double) var41, (double) var42, (double) var43);
    org.apache.commons.math.linear.RealVector var45 = var39.mapPowToSelf((double) var43);
    org.apache.commons.math.linear.ArrayRealVector var46 =
        new org.apache.commons.math.linear.ArrayRealVector(var29, var43);
    java.lang.Double var47 = new java.lang.Double((-1.0d));
    java.lang.Double var48 = new java.lang.Double(10.0d);
    java.lang.Double var49 = new java.lang.Double(1.0d);
    java.lang.Double var50 = new java.lang.Double(1.0d);
    boolean var51 = org.apache.commons.math.util.MathUtils.equals((double) var49, (double) var50);
    int var52 =
        org.apache.commons.math.util.MathUtils.compareTo(
            (double) var47, (double) var48, (double) var49);
    java.lang.Double var53 = new java.lang.Double((-1.0d));
    java.lang.Double var54 = new java.lang.Double(0.0d);
    java.lang.Double var55 = new java.lang.Double((-1.0d));
    double[] var56 = new double[] {var53, var54, var55};
    org.apache.commons.math.linear.ArrayRealVector var57 =
        new org.apache.commons.math.linear.ArrayRealVector(var56);
    java.lang.Double var58 = new java.lang.Double((-1.0d));
    java.lang.Double var59 = new java.lang.Double(0.0d);
    java.lang.Double var60 = new java.lang.Double((-1.0d));
    double[] var61 = new double[] {var58, var59, var60};
    org.apache.commons.math.linear.ArrayRealVector var62 =
        new org.apache.commons.math.linear.ArrayRealVector(var61);
    org.apache.commons.math.linear.RealVector var63 =
        var57.ebeDivide((org.apache.commons.math.linear.RealVector) var62);
    org.apache.commons.math.linear.RealVector var64 = var57.mapLog10ToSelf();
    java.lang.Double var65 = new java.lang.Double(1.0d);
    org.apache.commons.math.linear.RealVector var66 = var57.mapMultiplyToSelf((double) var65);
    double var67 = org.apache.commons.math.util.MathUtils.indicator((double) var65);
    java.lang.Double var68 = new java.lang.Double((-1.0d));
    java.lang.Double var69 = new java.lang.Double(10.0d);
    java.lang.Double var70 = new java.lang.Double(100.0d);
    int var71 =
        org.apache.commons.math.util.MathUtils.compareTo(
            (double) var68, (double) var69, (double) var70);
    double var72 =
        org.apache.commons.math.util.MathUtils.normalizeAngle((double) var65, (double) var69);
    java.lang.Integer var73 = new java.lang.Integer(10);
    java.lang.Integer var74 = new java.lang.Integer(10);
    double var75 =
        org.apache.commons.math.util.MathUtils.binomialCoefficientLog((int) var73, (int) var74);
    java.lang.Integer var76 = new java.lang.Integer(0);
    java.lang.Long var77 = new java.lang.Long(100L);
    int var78 = org.apache.commons.math.util.MathUtils.pow((int) var76, (long) var77);
    double var79 =
        org.apache.commons.math.util.MathUtils.binomialCoefficientLog((int) var74, (int) var76);
    boolean var80 =
        org.apache.commons.math.util.MathUtils.equalsIncludingNaN(
            (double) var49, (double) var69, (int) var76);
    org.apache.commons.math.linear.RealVector var81 = var46.mapMultiplyToSelf((double) var49);
    org.apache.commons.math.linear.RealVector var82 = var7.mapPow((double) var49);

    // Checks the contract:  equals-hashcode on var23 and var45
    assertTrue(
        "Contract failed: equals-hashcode on var23 and var45",
        var23.equals(var45) ? var23.hashCode() == var45.hashCode() : true);

    // Checks the contract:  equals-hashcode on var45 and var23
    assertTrue(
        "Contract failed: equals-hashcode on var45 and var23",
        var45.equals(var23) ? var45.hashCode() == var23.hashCode() : true);
  }
 /**
  * Build a resized vector, for use with append.
  *
  * @param v The original vector
  * @param resize The amount to resize it
  */
 protected OpenMapRealVector(OpenMapRealVector v, int resize) {
   virtualSize = v.getDimension() + resize;
   entries = new OpenIntToDoubleHashMap(v.entries);
   epsilon = v.getEpsilon();
 }
 /** {@inheritDoc} */
 public OpenMapRealVector unitVector() {
   OpenMapRealVector res = copy();
   res.unitize();
   return res;
 }
 /**
  * Copy constructor.
  *
  * @param v The instance to copy from
  */
 public OpenMapRealVector(OpenMapRealVector v) {
   virtualSize = v.getDimension();
   entries = new OpenIntToDoubleHashMap(v.getEntries());
   epsilon = v.getEpsilon();
 }
 /** {@inheritDoc} */
 public OpenMapRealVector append(double d) {
   OpenMapRealVector res = new OpenMapRealVector(this, 1);
   res.setEntry(virtualSize, d);
   return res;
 }