Ejemplo n.º 1
0
def vdot(a, b):
    """Returns the dot product of 2 vectors (or anything that can be made into
       a vector). NB: this is not the same as `dot`, as it takes the conjugate
       of its first argument if complex and always returns a scalar."""
    try:
	return _dotblas.vdot(Numeric.ravel(a), Numeric.ravel(b))
    # in case we get an integer Value
    except TypeError:
        return multiarray.matrixproduct(multiarray.array(a).flat,
                                        multiarray.array(b).flat)
Ejemplo n.º 2
0
def dot(a, b):
    """dot(a,b) returns matrix-multiplication between a and b.  The product-sum
    is over the last dimension of a and the second-to-last dimension of b.
    """
    try:
        return multiarray.matrixproduct(a, b)
    except TypeError, detail:
        if array(a).shape == () or array(b).shape == ():
            return a * b
        else:
            raise TypeError, detail or "invalid types for dot"
Ejemplo n.º 3
0
def dot(a, b):
    """dot(a,b) returns matrix-multiplication between a and b.  The product-sum
    is over the last dimension of a and the second-to-last dimension of b.
    """
    try:
        return multiarray.matrixproduct(a, b)
    except TypeError,detail:
        if array(a).shape == () or array(b).shape == ():
            return a*b
        else:
            raise TypeError, detail or "invalid types for dot"
Ejemplo n.º 4
0
def dot(a, b):
    """returns matrix-multiplication between a and b.
    The product-sum is over the last dimension of a and the
    second-to-last dimension of b.

    NB: No conjugation of complex arguments is performed.

    This version uses the BLAS optimized routines where possible.
    """
    try:
        return _dotblas.matrixproduct(a, b) 
    except:
        try:
            return multiarray.matrixproduct(a, b)
        except TypeError,detail:
            if multiarray.array(a).shape == () or multiarray.array(b).shape == ():
                return a*b
            else:
                raise TypeError, detail or "invalid types for matrixproduct"
Ejemplo n.º 5
0
def vdot(a, b):
    """Returns the dot product of 2 vectors (or anything that can be made into
       a vector). NB: this is not the same as `dot`, as it takes the conjugate
       of its first argument if complex and always returns a scalar."""
    return multiarray.matrixproduct(conjugate(ravel(a)), ravel(b))
Ejemplo n.º 6
0
"""Numeric module defining a multi-dimensional array and useful procedures for
Ejemplo n.º 7
0
def vdot(a, b):
    """Returns the dot product of 2 vectors (or anything that can be made into
       a vector). NB: this is not the same as `dot`, as it takes the conjugate
       of its first argument if complex and always returns a scalar."""
    return multiarray.matrixproduct(conjugate(ravel(a)),
                                    ravel(b))
Ejemplo n.º 8
0
"""Numeric module defining a multi-dimensional array and useful procedures for