matrix.all()

matrix.all(axis=None, out=None) [source]

Test whether all matrix elements along a given axis evaluate to True.

Parameters: See `numpy.all` for complete descriptions

See also

numpy.all

Notes

This is the same as ndarray.all, but it returns a matrix object.

Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
>>> x = np.matrix(np.arange(12).reshape((3,4))); x
matrix([[ 0123],
        [ 4567],
        [ 89, 10, 11]])
>>> y = x[0]; y
matrix([[0, 1, 2, 3]])
>>> (x == y)
matrix([[ TrueTrueTrueTrue],
        [False, False, False, False],
        [False, False, False, False]], dtype=bool)
>>> (x == y).all()
False
>>> (x == y).all(0)
matrix([[False, False, False, False]], dtype=bool)
>>> (x == y).all(1)
matrix([[ True],
        [False],
        [False]], dtype=bool)
doc_NumPy
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.