📌  相关文章
📜  在 Julia 中获取最小元素 – minimum() 和 minimum!() 方法

📅  最后修改于: 2022-05-13 01:54:51.134000             🧑  作者: Mango

在 Julia 中获取最小元素 – minimum() 和 minimum!() 方法

minimum()是 julia 中的内置函数,用于返回不同场景中的最小元素。

例子:

Julia
# Julia program to illustrate
# the use of minimum() method
 
# Getting minimum elements in different scenarios
 
# In the below scenario, length function
# and a list of elements are used as
# parameter. Here the length of string with
# minimum alphabets will be returned
println(minimum(length, ["GFG", "Geeks", "GeeksforGeeks"]))
 
# In the below scenario, a list of
# elements are shown and minimum elements are
# returned as output
println(minimum([5, 10, 15, 20]))
 
# Getting the minimum value of an array
# over the given dimensions
A = [5 10; 15 20];
println(minimum(A, dims = 1))
println(minimum(A, dims = 2))


Julia
# Julia program to illustrate
# the use of minimum !() method
 
# Getting the minimum value of the
# specified array over the specified
# singleton dimensions.
A = [5 10; 15 20];
println(minimum !([1; 1], A))
println(minimum !([1 1], A))


输出:

最低限度!()

minimum!()是 julia 中的内置函数,用于计算指定数组在指定单例维度上的最小值。

例子:

朱莉娅

# Julia program to illustrate
# the use of minimum !() method
 
# Getting the minimum value of the
# specified array over the specified
# singleton dimensions.
A = [5 10; 15 20];
println(minimum !([1; 1], A))
println(minimum !([1 1], A))

输出:

[5, 15]
[5 10]