all!
all!(r, A)
Test whether all values in A
along the singleton dimensions of r
are true
, and write results to r
.
Examples
-
Check if all elements of an array are true:
julia> arr = [true, true, true]; julia> result = trues(3); julia> all!(result, arr) true
This example checks if all elements in the array
arr
aretrue
and writes the result to theresult
array. -
Check if all columns of a matrix are true:
julia> matrix = [true false true; true true true]; julia> result = trues(2); julia> all!(result, matrix, dims=1) 2-element Array{Bool,1}: true false
It checks if all elements of each column in the matrix
matrix
aretrue
and writes the results to theresult
array along the singleton dimension. - Check if all rows of a matrix are true:
julia> matrix = [true false true; true true true]; julia> result = trues(3); julia> all!(result, matrix, dims=2) 3-element Array{Bool,1}: false true true
This example checks if all elements of each row in the matrix
matrix
aretrue
and writes the results to theresult
array along the singleton dimension.
Common mistake example:
julia> arr = [true, false, true];
julia> result = falses(3);
julia> all!(result, arr)
ERROR: DimensionMismatch("output array has the wrong dimensions for broadcasting")
In this example, the size of the output array result
does not match the input array arr
. It's important to ensure that the dimensions of the output array are compatible with the dimensions of the input array.
See Also
all, all!, angle, any, any!, falses, ifelse, is, isinf, isinteger, isnan, isperm, ispow2, isreal, trues,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.