📌  相关文章
📜  在 Julia 中获取最大元素——maximum() 和 maximum!() 方法

📅  最后修改于: 2021-11-25 04:45:31             🧑  作者: Mango

maximum()是 julia 中的一个内置函数,用于返回不同场景中的最大元素。

例子:

Julia
# Julia program to illustrate
# the use of maximum() method
 
# Getting maximum 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
# maximum alphabets will be returned
println(maximum(length, ["GFG", "Geeks", "GeeksforGeeks"]))
 
# In the below scenario, a list of
# elements are shown and maximum elements are
# returned as output
println(maximum([5, 10, 15, 20]))
 
# Getting the maximum value of an array
# over the given dimensions
A = [5 10; 15 20];
println(maximum(A, dims = 1))
println(maximum(A, dims = 2))


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


输出:

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

例子:

朱莉娅

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

输出:

[10, 20]
[15 20]