Maximum

From APL Wiki
Revision as of 21:15, 10 September 2022 by Adám Brudzewsky (talk | contribs) (Text replacement - "<source" to "<syntaxhighlight")
Jump to navigation Jump to search
This page is about the primitive function. For system limits, see LIMIT ERROR and Maximum rank.

Maximum (), Max, Greater of, or Larger of is a dyadic scalar function which returns the larger of its two arguments. The name "Maximum" is sometimes also used for the Maximum Reduce <syntaxhighlight lang=apl inline>⌈/</source>, which returns the largest element of a vector (this usage is related to the maximum of a function). Maximum is paired with Minimum, and shares the glyph <syntaxhighlight 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 tolerantly equal. As a Boolean function, Maximum is identical to Or.

Examples

See also Minimum#examples.

Maximum finds the larger of two numbers: <syntaxhighlight lang=apl>

     2.4 ⌈ 1.9

2.4 </source> Maximum Reduce finds the largest element in a vector: <syntaxhighlight lang=apl>

     ⌈/ 4 3 2 7 5 1 3

7 </source> The index of this element can be found with Index Of, but is also the First element of the Grade Down of the vector. <syntaxhighlight lang=apl>

     {⍵⍳⌈/⍵} 4 3 2 7 5 1 3

4

     ⊃⍒ 4 3 2 7 5 1 3

4 </source>

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>¯∞</source> (for dialects that support infinities) or <syntaxhighlight lang=apl inline>¯1.797693135E308</source> (with 64-bit floats) or <syntaxhighlight lang=apl inline>¯1E6145</source> (with 128-bit decimal floats).

External links

Documentation


APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare RootRound
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axisIdentity (Null, Ident)
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)Identity (Lev, Dex)
Quad names Index originComparison toleranceMigration levelAtomic vector