Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get minimal value of Array in Julia?

Tags:

julia

How to get the minimal value of Array/Vector/Matrix in Julia?

This code min([1, 2, 3]) doesn't works...

like image 646
Alexey Petrushin Avatar asked Mar 30 '16 09:03

Alexey Petrushin


People also ask

How do you find the minimum value in an array in Matlab?

M = min( A ) returns the minimum elements of an array. If A is a vector, then min(A) returns the minimum of A . If A is a matrix, then min(A) is a row vector containing the minimum value of each column of A .

Are arrays mutable in Julia?

Arrays are mutable type collections in Julia, hence, their values can be modified with the use of certain pre-defined keywords. Julia allows adding new elements in an array with the use of push!


1 Answers

The Julia manual: https://docs.julialang.org/en/v1/base/math/#Base.min

https://docs.julialang.org/en/v1/base/collections/#Base.minimum

min(x, y, ...)

Return the minimum of the arguments. Operates elementwise over arrays.

julia> min([1, 2, 3]...)
1

julia> min(2,3)
2

minimum(A, dims)

Compute the minimum value of an array over the given dimensions.

minimum!(r, A)

Compute the minimum value of A over the singleton dimensions of r, and write results to r.

julia> minimum([1, 2, 3])
1
like image 69
python必须死 Avatar answered Sep 28 '22 06:09

python必须死