Linear Algebra¶
Matrix and vector products¶

cupy.
dot
(a, b, out=None)[source]¶ Returns a dot product of two arrays.
For arrays with more than one axis, it computes the dot product along the last axis of
a
and the secondtolast axis ofb
. This is just a matrix product if the both arrays are 2D. For 1D arrays, it uses their unique axis as an axis to take dot product over.Parameters:  a (cupy.ndarray) – The left argument.
 b (cupy.ndarray) – The right argument.
 out (cupy.ndarray) – Output array.
Returns: The dot product of
a
andb
.Return type: See also

cupy.
vdot
(a, b)[source]¶ Returns the dot product of two vectors.
The input arrays are flattened into 1D vectors and then it performs inner product of these vectors.
Parameters:  a (cupy.ndarray) – The first argument.
 b (cupy.ndarray) – The second argument.
Returns: Zerodimensional array of the dot product result.
Return type: See also

cupy.
inner
(a, b)[source]¶ Returns the inner product of two arrays.
It uses the last axis of each argument to take sum product.
Parameters:  a (cupy.ndarray) – The first argument.
 b (cupy.ndarray) – The second argument.
Returns: The inner product of
a
andb
.Return type: See also

cupy.
outer
(a, b, out=None)[source]¶ Returns the outer product of two vectors.
The input arrays are flattened into 1D vectors and then it performs outer product of these vectors.
Parameters:  a (cupy.ndarray) – The first argument.
 b (cupy.ndarray) – The second argument.
 out (cupy.ndarray) – Output array.
Returns: 2D array of the outer product of
a
andb
.Return type: See also

cupy.
tensordot
(a, b, axes=2)[source]¶ Returns the tensor dot product of two arrays along specified axes.
This is equivalent to compute dot product along the specified axes which are treated as one axis by reshaping.
Parameters:  a (cupy.ndarray) – The first argument.
 b (cupy.ndarray) – The second argument.
 axes –
 If it is an integer, then
axes
axes at the last ofa
and the first ofb
are used.  If it is a pair of sequences of integers, then these two
sequences specify the list of axes for
a
andb
. The corresponding axes are paired for sumproduct.
 If it is an integer, then
 out (cupy.ndarray) – Output array.
Returns: The tensor dot product of
a
andb
along the axes specified byaxes
.Return type: See also
Norms etc.¶

cupy.
trace
(a, offset=0, axis1=0, axis2=1, dtype=None, out=None)[source]¶ Returns the sum along the diagonals of an array.
It computes the sum along the diagonals at
axis1
andaxis2
.Parameters:  a (cupy.ndarray) – Array to take trace.
 offset (int) – Index of diagonals. Zero indicates the main diagonal, a positive value an upper diagonal, and a negative value a lower diagonal.
 axis1 (int) – The first axis along which the trace is taken.
 axis2 (int) – The second axis along which the trace is taken.
 dtype – Data type specifier of the output.
 out (cupy.ndarray) – Output array.
Returns: The trace of
a
along axes(axis1, axis2)
.Return type: See also