Gets the entrywise difference of the two vectors.
324774
public IntLongSortedVector getDiff(IntLongVector other) {
        IntLongSortedVector diff = new IntLongSortedVector(this);
        diff.subtract(other);
        return diff;
    }
157439
def numdiff(fun, args):
    """"""

    # vectorized version

    epsilon = 1e-8
    args = list(args)
    v0 = fun(*args)
    N = v0.shape[0]
    l_v = len(v0)
    dvs = []
    for i, a in enumerate(args):
        l_a = (a).shape[1]
        dv = numpy.zeros((N, l_v, l_a))
        nargs = list(args)  #.copy()
        for j in range(l_a):
            xx = args[i].copy()
            xx[:, j] += epsilon
            nargs[i] = xx
            dv[:, :, j] = (fun(*nargs) - v0) / epsilon
        dvs.append(dv)
    return [v0] + dvs
1179209
function(lDigits, rDigits) {
    var difference = [];

    // assert: lDigits.length >= rDigits.length
    
    var carry = 0, i;

    for (i = 0; i < rDigits.length; i += 1) {
        difference[i] = lDigits[i] - rDigits[i] + carry;

        if (difference[i] < 0) {
            difference[i] += 2;
            carry = -1;
        }
        else {
            carry = 0;
        }
    }

    for (; i < lDigits.length; i += 1) {
        difference[i] = lDigits[i] + carry;

        if (difference[i] < 0) {
            difference[i] += 2;
            carry = -1;
        }
        else {
            carry = 0;
        }
    }

    if (carry !== 0) {
        throw new Error('never goes here');
    }

    return difference;
}
162340
def difference(cls, first, second):
        """"""

        # so we always get a Rank instance even if string were passed in
        first, second = cls(first), cls(second)
        rank_list = list(cls)
        return abs(rank_list.index(first) - rank_list.index(second))
528426
public LongIntSortedVector getSum(LongIntVector other) {
        LongIntSortedVector sum = new LongIntSortedVector(this);
        sum.add(other);
        return sum;
    }
1116573
def difference(self,other):
        
        res = IntervalSet.everything()
        for j in other.ints:
            tmp = []
            for i in self.ints:
                tmp.extend(i._difference(j))
            res = res.intersection(IntervalSet(tmp))
        return res
377837
def _diff_internal(d1,d2):
    '''
        
    '''
    same =[]
    kdiff =[]
    vdiff = []
    for key in d1:
        value = d1[key]
        if(key in d2):
            if(value == d2[key]):
                same.append(key)
            else:
                vdiff.append(key)
        else:
            kdiff.append(key)
    return({'same':same,'kdiff':kdiff,'vdiff':vdiff})
1330578
def pairwise_diff(values):
    ""
    return numpy.array([x - y for x, y in pairwise(values)])
935929
def vector_distance(a, b):
    """"""
    a = np.array(a)
    b = np.array(b)
    return np.linalg.norm(a - b)
1197179
public IntIntSortedVector getProd(IntIntVector other) {
        IntIntSortedVector prod = new IntIntSortedVector(this);
        prod.product(other);
        return prod;
    }
1231173
def get_diff_coeff(hvec, n=1):
    
    hvec = np.array(hvec, dtype=np.float)
    acc = len(hvec)
    exp = np.column_stack([np.arange(acc)]*acc)
    a = np.vstack([hvec] * acc) ** exp
    b = np.zeros(acc)
    b[n] = factorial(n)
    return np.linalg.solve(a, b)
1272472
def dot(vec1, vec2):
    """"""
    if isinstance(vec1, Vector3) and isinstance(vec2, Vector3):
        return (vec1.x * vec2.x) + (vec1.y * vec2.y) + (vec1.z * vec2.z)
    elif isinstance(vec1, Vector4) and isinstance(vec2, Vector4):
        return (vec1.x * vec2.x) + (vec1.y * vec2.y) + (vec1.z * vec2.z) + (vec1.w * vec2.w)
    else:
        raise TypeError("vec1 and vec2 must a Vector type")
1048504
def distance(self, other):
        """"""
        return math.acos(self._pos3d.dot(other.vector))
724921
def dot_v2(vec1, vec2):
    """"""

    return vec1.x * vec2.x + vec1.y * vec2.y
235005
private static void subtractTernaryValues(Vector destination,
                                              TernaryVector source) {
        for (int p : source.positiveDimensions())
            destination.set(p, destination.getValue(p).doubleValue() - 1);
        for (int n : source.negativeDimensions())
            destination.set(n, destination.getValue(n).doubleValue() + 1);
    }
1004731
public boolean eq(IntFloatSortedVector other, float delta) {
        // This is slow, but correct.
        IntFloatSortedVector v1 = IntFloatSortedVector.getWithNoZeroValues(this, delta);
        IntFloatSortedVector v2 = IntFloatSortedVector.getWithNoZeroValues(other, delta);
                
        if (v2.size() != v1.size()) {
            return false;
        }

        for (IntFloatEntry ve : v1) {
            if (!Primitives.equals(ve.get(), v2.get(ve.index()), delta)) {
                return false;
            }
        }
        for (IntFloatEntry ve : v2) {
            if (!Primitives.equals(ve.get(), v1.get(ve.index()), delta)) {
                return false;
            }
        }
        return true;
    }
1290631
public IntIntSortedVector getDiff(IntIntVector other) {
        IntIntSortedVector diff = new IntIntSortedVector(this);
        diff.subtract(other);
        return diff;
    }