cummax
cummax(A, [dim])
Cumulative maximum along a dimension. The dimension defaults to 1.
Examples
-
Calculate cumulative maximum along the default dimension:
julia> A = [3, 2, 6, 1, 5]; julia> cummax(A) 5-element Array{Int64,1}: 3 3 6 6 6
This example calculates the cumulative maximum along the default dimension (dimension 1) of the array
A
. -
Calculate cumulative maximum along a specific dimension:
julia> B = [2 5 3; 1 4 6; 7 2 9]; julia> cummax(B, 2) 3×3 Array{Int64,2}: 2 5 5 1 4 6 7 7 9
It calculates the cumulative maximum along dimension 2 of the matrix
B
. - Handle edge cases with empty arrays:
julia> C = Int[] julia> cummax(C) 0-element Array{Int64,1}
It handles the case of an empty array by returning an empty array as the result.
Common mistake example:
julia> D = [1 2 3; 4 5 6; 7 8 9];
julia> cummax(D, 3)
ERROR: DimensionMismatch("matrix is not square: dimensions are (3, 3) but dimension is 3")
In this example, the provided dimension is out of bounds for the matrix. It's important to ensure that the dimension is within the valid range of the array dimensions to avoid such errors. Always check that the dimension is valid before using cummax
.
See Also
cummax, eigmax, findmax, hist, hist!, hist2d, hist2d!, histrange, indmax, maxabs, maxabs!, maximum!, mean, mean!, median, median!, minabs, minabs!, minimum!, minmax, quantile!, realmax, std, stdm,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.