Adds a factor elementwise to this one.
@param other The addend.
@throws IllegalArgumentException If the two tensors have different sizes.
357786
public void elemAdd(Tensor other) {
        checkEqualSize(this, other);
        for (int c = 0; c < this.values.length; c++) {
            addValue(c, other.values[c]);
        }
    }
753494
@Override
    public void elemAdd(MVec addend) {
        if (addend instanceof Tensor) {
            elemAdd((Tensor)addend);
        } else {
            throw new IllegalArgumentException("Addend must be of type " + this.getClass());
        }
    }
1311609
private void repmatIncrement(TensorBase other, double multiplier) {
    // Maps a key of other into a partial key of this.
    int[] dimensionMapping = getDimensionMapping(other.getDimensionNumbers());
    int[] partialKey = ArrayUtils.copyOf(getDimensionSizes(), getDimensionSizes().length);
    for (int i = 0; i < dimensionMapping.length; i++) {
      partialKey[dimensionMapping[i]] = 1;
    }

    int numValues = 1;
    for (int i = 0; i < partialKey.length; i++) {
      numValues *= partialKey[i];
    }
    int[] keyOffsets = new int[numValues];
    Iterator<int[]> myKeyIterator = new IntegerArrayIterator(partialKey, new int[0]);
    int ind = 0;
    while (myKeyIterator.hasNext()) {
      keyOffsets[ind] = dimKeyToIndex(myKeyIterator.next());
      ind++;
    }
    Preconditions.checkState(ind == keyOffsets.length);

    Iterator<KeyValue> otherKeyValues = other.keyValueIterator();
    while (otherKeyValues.hasNext()) {
      KeyValue otherKeyValue = otherKeyValues.next();
      int baseOffset = 0;
      for (int i = 0; i < otherKeyValue.getKey().length; i++) {
        baseOffset += otherKeyValue.getKey()[i] * indexOffsets[dimensionMapping[i]];
      }

      for (int i = 0; i < keyOffsets.length; i++) {
        values[baseOffset + keyOffsets[i]] += otherKeyValue.getValue() * multiplier;
      }
    }
  }
1327214
public void add(LongDoubleVector other) {
        if (other instanceof LongDoubleUnsortedVector) {
            LongDoubleUnsortedVector vec = (LongDoubleUnsortedVector) other;
            for (int i=0; i<vec.top; i++) {
                this.add(vec.idx[i], vec.vals[i]);
            }
        } else {
            //  TODO: Add special case for LongDoubleDenseVector.
            other.iterate(new SparseBinaryOpApplier(this, new Lambda.DoubleAdd()));
        }
    }
237815
public SDVariable add(SDVariable other) {
        return add(sameDiff.generateNewVarName(AddOp.OP_NAME,0),other);
    }
815111
private void simpleIncrement(TensorBase other, double multiplier) {
    Preconditions.checkArgument(Arrays.equals(other.getDimensionNumbers(), getDimensionNumbers()));
    if (other instanceof DenseTensorBase) {
      double[] otherTensorValues = ((DenseTensorBase) other).values;
      Preconditions.checkArgument(otherTensorValues.length == values.length);
      int length = values.length;
      for (int i = 0; i < length; i++) {
        values[i] += otherTensorValues[i] * multiplier;
      }
    } else {
      int otherSize = other.size();
      for (int i = 0; i < otherSize; i++) {
        long keyNum = other.indexToKeyNum(i);
        double value = other.getByIndex(i);
        values[keyNumToIndex(keyNum)] += value * multiplier;
      }
    }
  }
1188993
@Override
	public RandomVariable addProduct(final RandomVariable factor1, final double factor2) {
		return apply(new DoubleBinaryOperator() {
			@Override
			public double applyAsDouble(double x, double y) {
				return x + y * factor2;
			}
		}, factor1);
	}
263728
@Override
  public void put(Mean other) {
    if(!(other instanceof StatisticalMoments)) {
      throw new IllegalArgumentException("I cannot combine Mean or MeanVariance into to a StatisticalMoments class.");
    }
    if(other.n == 0.) {
      return;
    }
    StatisticalMoments othe = (StatisticalMoments) other;
    if(this.n == 0.) {
      this.n = othe.n;
      this.sum = othe.sum;
      this.m2 = othe.m2;
      this.m3 = othe.m3;
      this.m4 = othe.m4;
      return;
    }
    final double nn = othe.n + this.n;
    final double delta = othe.sum / othe.n - this.sum / this.n;

    // Some factors used below:
    final double delta_nn = delta / nn;
    final double delta_nn2 = delta_nn * delta_nn;
    final double delta_nn3 = delta_nn2 * delta_nn;
    final double na2 = this.n * this.n;
    final double nb2 = othe.n * othe.n;
    final double ntn = this.n * othe.n;

    this.m4 += othe.m4 + delta * delta_nn3 * ntn * (na2 - ntn + nb2) + 6. * (na2 * othe.m2 + nb2 * this.m2) * delta_nn2 + 4. * (this.n * othe.m3 - othe.n * this.m3) * delta_nn;
    this.m3 += othe.m3 + delta * delta_nn2 * ntn * (this.n - othe.n) + 3. * (this.n * othe.m2 - othe.n * this.m2) * delta_nn;
    this.m2 += othe.m2 + delta * delta_nn * this.n * othe.n;
    this.sum += othe.sum;
    this.n = nn;

    min = Math.min(min, othe.min);
    max = Math.max(max, othe.max);
  }
653691
public void add(MultidimensionalReward other) {
        for (Map.Entry<Integer, Float> entry : other.map.entrySet()) {
            Integer dimension = entry.getKey();
            Float reward_value = entry.getValue();
            this.add(dimension.intValue(), reward_value.floatValue());
        }
    }
615067
public void add(LongIntVector other) {
        if (other instanceof LongIntUnsortedVector) {
            LongIntUnsortedVector vec = (LongIntUnsortedVector) other;
            for (int i=0; i<vec.top; i++) {
                this.add(vec.idx[i], vec.vals[i]);
            }
        } else {
            //  TODO: Add special case for LongIntDenseVector.
            other.iterate(new SparseBinaryOpApplier(this, new Lambda.IntAdd()));
        }
    }
503942
public void set(Tensor other) {
        checkEqualSize(this, other);
        this.dims = IntArrays.copyOf(other.dims);
        DoubleArrays.copy(other.values, this.values);
    }
530079
public void combine(@NonNull EnhancedDoubleStatistics other) {
      count += other.count;
      sum += other.sum;
      sumOfSq += other.sumOfSq;
      min = Math.min(min, other.min);
      max = Math.max(max, other.max);
   }
480619
public AABBd union(AABBd other, AABBd dest) {
        dest.minX = this.minX < other.minX ? this.minX : other.minX;
        dest.minY = this.minY < other.minY ? this.minY : other.minY;
        dest.minZ = this.minZ < other.minZ ? this.minZ : other.minZ;
        dest.maxX = this.maxX > other.maxX ? this.maxX : other.maxX;
        dest.maxY = this.maxY > other.maxY ? this.maxY : other.maxY;
        dest.maxZ = this.maxZ > other.maxZ ? this.maxZ : other.maxZ;
        return dest;
    }
374699
public void setTo(Permutation other) {

        if (this.values.length != other.values.length)
            throw new IllegalArgumentException("permutations are different size");

        for (int i = 0; i < this.values.length; i++) {
            this.values[i] = other.values[i];
        }
    }
744107
public void merge(CandidateCluster other) {
        indices.addAll(other.indices);
        VectorMath.add(sumVector, other.sumVector);
        centroid = null;
    }
498361
public Matrix4d add(Matrix4dc other, Matrix4d dest) {
        dest.m00 = m00 + other.m00();
        dest.m01 = m01 + other.m01();
        dest.m02 = m02 + other.m02();
        dest.m03 = m03 + other.m03();
        dest.m10 = m10 + other.m10();
        dest.m11 = m11 + other.m11();
        dest.m12 = m12 + other.m12();
        dest.m13 = m13 + other.m13();
        dest.m20 = m20 + other.m20();
        dest.m21 = m21 + other.m21();
        dest.m22 = m22 + other.m22();
        dest.m23 = m23 + other.m23();
        dest.m30 = m30 + other.m30();
        dest.m31 = m31 + other.m31();
        dest.m32 = m32 + other.m32();
        dest.m33 = m33 + other.m33();
        dest.properties = 0;
        return dest;
    }
382638
@SuppressWarnings("unchecked")
  public void replaceInplace(final LNGVector<? extends T> other) {
    if (this == other)
      throw new IllegalArgumentException("cannot replace a vector in-place with itself");
    this.elements = (T[]) new Object[other.size()];
    for (int i = 0; i < other.size(); i++)
      this.elements[i] = other.get(i);
    this.size = other.size;
  }