Maximum: Difference between revisions

Jump to navigation Jump to search
227 bytes added ,  21:28, 10 September 2022
m
Text replacement - "</source>" to "</syntaxhighlight>"
m (Text replacement - "</source>" to "</syntaxhighlight>")
Tags: Mobile edit Mobile web edit
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
:''This page is about the primitive function. For system limits, see [[LIMIT ERROR]] and [[Maximum rank]].''
:''This page is about the primitive function. For system limits, see [[LIMIT ERROR]] and [[Maximum rank]].''


{{Built-in|Maximum|⌈}}, '''Max''', '''Greater of''', or '''Larger of''' is a [[dyadic]] [[scalar function]] which returns the [[Greater than|larger]] of its two [[argument]]s. The name "Maximum" is sometimes also used for the Maximum [[Reduce]] <source lang=apl inline>⌈/</source>, which returns the largest element of a [[vector]] (this usage is related to the [[wikipedia:maximum|maximum]] of a function). Maximum is paired with [[Minimum]], and shares the glyph <source lang=apl inline>⌈</source> with the [[Ceiling]] function. It is not subject to [[comparison tolerance]], since the result will be exactly equal to one argument, and there is no reason to choose a smaller argument even if the two arguments are [[tolerant comparison|tolerantly]] equal. As a [[Boolean function]], Maximum is identical to [[Or]].
{{Built-in|Maximum|⌈}}, '''Max''', '''Greater of''', or '''Larger of''' is a [[dyadic]] [[scalar function]] which returns the [[Greater than|larger]] of its two [[argument]]s. The name "Maximum" is sometimes also used for the Maximum [[Reduce]] <syntaxhighlight lang=apl inline>⌈/</syntaxhighlight>, which returns the largest element of a [[vector]] (this usage is related to the [[wikipedia:maximum|maximum]] of a function). Maximum is paired with [[Minimum]], and shares the glyph <syntaxhighlight lang=apl inline>⌈</syntaxhighlight> with the [[Ceiling]] function. It is not subject to [[comparison tolerance]], since the result will be exactly equal to one argument, and there is no reason to choose a smaller argument even if the two arguments are [[tolerant comparison|tolerantly]] equal. As a [[Boolean function]], Maximum is identical to [[Or]].


== Examples ==
== Examples ==
Line 7: Line 7:


Maximum finds the larger of two numbers:
Maximum finds the larger of two numbers:
<source lang=apl>
<syntaxhighlight lang=apl>
       2.4 ⌈ 1.9
       2.4 ⌈ 1.9
2.4
2.4
</source>
</syntaxhighlight>
Maximum [[Reduce]] finds the largest [[element]] in a [[vector]]:
Maximum [[Reduce]] finds the largest [[element]] in a [[vector]]:
<source lang=apl>
<syntaxhighlight lang=apl>
       ⌈/ 4 3 2 7 5 1 3
       ⌈/ 4 3 2 7 5 1 3
7
7
</source>
</syntaxhighlight>
The [[index]] of this element can be found with [[Index Of]], but is also the [[First]] element of the [[Grade Down]] of the vector.
The [[index]] of this element can be found with [[Index Of]], but is also the [[First]] element of the [[Grade Down]] of the vector.
<source lang=apl>
<syntaxhighlight lang=apl>
       {⍵⍳⌈/⍵} 4 3 2 7 5 1 3
       {⍵⍳⌈/⍵} 4 3 2 7 5 1 3
4
4
       ⊃⍒ 4 3 2 7 5 1 3
       ⊃⍒ 4 3 2 7 5 1 3
4
4
</source>
</syntaxhighlight>


Reducing over an empty axis yields the smallest representable number, as that is the identity element for Maximum. This value is usually <source lang=apl inline>¯∞</source> (for dialects that support [[infinity|infinities]]) or <source lang=apl inline>¯1.797693135E308</source> (with 64-bit [[float]]s) or <source lang=apl inline>¯1E6145</source> (with 128-bit [[decimal float]]s).
Reducing over an empty axis yields the smallest representable number, as that is the identity element for Maximum. This value is usually <syntaxhighlight lang=apl inline>¯∞</syntaxhighlight> (for dialects that support [[infinity|infinities]]) or <syntaxhighlight lang=apl inline>¯1.797693135E308</syntaxhighlight> (with 64-bit [[float]]s) or <syntaxhighlight lang=apl inline>¯1E6145</syntaxhighlight> (with 128-bit [[decimal float]]s).


== External links ==
== External links ==
Line 30: Line 30:
=== Documentation ===
=== Documentation ===


* [http://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Maximum.htm Dyalog]
* [https://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Maximum.htm Dyalog]
* [http://microapl.com/apl_help/ch_020_020_100.htm APLX]
* [http://microapl.com/apl_help/ch_020_020_100.htm APLX]
* J [http://www.jsoftware.com/help/dictionary/d021.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/gtdot#dyadic NuVoc]
* J [http://www.jsoftware.com/help/dictionary/d021.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/gtdot#dyadic NuVoc]
* [https://mlochbaum.github.io/BQN/doc/arithmetic.html#additional-arithmetic BQN]


{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]]
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]]

Navigation menu