# Max of a vector

**URL:** <https://discourse.julialang.org/t/max-of-a-vector/108294>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [January 3, 2024, 11:02am UTC](https://discourse.julialang.org/t/max-of-a-vector/108294 "2024-01-03T11:02:10Z")\
**Posts on this page:** 1\
**Showing post:** 29

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [January 21, 2024, 8:38pm UTC](https://discourse.julialang.org/t/max-of-a-vector/108294/29 "2024-01-21T20:38:46Z")

</div>

“Maximum argument” makes me think you mean `argmax` which would be `maxloc` in Fortran.

GNU Fortran documentation:

- [`max`](https://gcc.gnu.org/onlinedocs/gfortran/MAX.html) - maximum value of argument list
- [`maxval`](https://gcc.gnu.org/onlinedocs/gfortran/MAXVAL.html) - maximum value of an array
- [`maxloc`](https://gcc.gnu.org/onlinedocs/gfortran/MAXLOC.html) - Location of the maximum value within an array

In Julia, the corresponding functions are,

- [`max`](https://docs.julialang.org/en/v1/base/math/#Base.max) - Return the maximum of the arguments (with respect to isless)
- [`maximum`](https://docs.julialang.org/en/v1/base/collections/#Base.maximum) - Return the largest element in a collection, iterator, or array
- [`argmax`](https://docs.julialang.org/en/v1/base/collections/#Base.argmax) - Return the index or key of the maximal element in a collection.

That said we are about 10 years too late on this conversation:

> <https://github.com/JuliaLang/julia/issues/4235>
>
> The generic \`max(itr)\` calls \`max\` on pairs of values, while \`max(Array)\` calls …\`\>\` on pairs of values. This is a problem because \`max(A::Array,B::Array)\` is elementwise, while all other definitions of \`max(A,B)\` return either \`A\` or \`B\` depending which is "larger".
> 
> At the very least, all 1-argument \`max\` definitions should be consistent on whether they do \`reduce(max, ...)\` or call \`\>\`.
> 
> Then we are just left with the elementwise behavior, which may be a fight for another day.

This is not going to change in `Base` Julia. [Julia is not at that stage of development where we can change this kind of surface naming.](https://discourse.julialang.org/t/psa-julia-is-not-at-that-stage-of-development-anymore/44872)

I can tell you how to create your own aliases or even not load `Base` symbols into your current namespace if you would like.

```julia-repl
julia> const maxval = Base.maximum

```

Or

```julia
baremodule Foo
    using Base: max, argmax
    const maxval = Base.maximum
end

```

---

_[View the full topic](https://discourse.julialang.org/t/max-of-a-vector/108294)._
