Conformability: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (→‎Frame conformability: -- link to Rank (operator) page)
(→‎Frame conformability: NARS2000 has singleton extension for frame conformability)
 
(4 intermediate revisions by 2 users not shown)
Line 13: Line 13:
== Frame conformability ==
== Frame conformability ==


The [[Rank operator]] and [[function rank]] check for conformability not on the entire [[shape]]s of arguments, but only on their [[frame]]s. The same procedure applies to determine whether two frames conform, and if <syntaxhighlight lang=apl inline>f</syntaxhighlight>'s result shape is known, then the result shape of <syntaxhighlight lang=apl inline>f⍤l r</syntaxhighlight> can be found by appending it to the shape obtained from conformability on the frames computed from [https://aplwiki.com/wiki/Rank_(operator) ranks] <syntaxhighlight lang=apl inline>l</syntaxhighlight> and <syntaxhighlight lang=apl inline>r</syntaxhighlight>. Rather than copying [[elements]] of the extended argument to match the other one, [[cell]]s are copied.
{{main|Frame agreement}}


No language uses [[singleton extension]] for frame conformability: [[SHARP APL]] and [[J]] do not implement singleton extension, and [[Dyalog APL]] and [[A+]] have singleton extension for scalar dyadics but not for Rank. Of these, [[J]] and [[A+]] use [[leading axis agreement]] while SHARP and Dyalog use only empty-frame extension, the equivalent of scalar extension.
The [[Rank operator]] and [[function rank]] check for conformability not on the entire [[shape]]s of arguments, but only on their [[frame]]s. The same procedure applies to determine whether two frames conform, and if function <syntaxhighlight lang=apl inline>f</syntaxhighlight>'s result shape is known, then the result shape of <syntaxhighlight lang=apl inline>f⍤l r</syntaxhighlight> can be found by appending it to the shape obtained from conformability on the frames computed from [[Rank (operator)|ranks]] <syntaxhighlight lang=apl inline>l</syntaxhighlight> and <syntaxhighlight lang=apl inline>r</syntaxhighlight>. Rather than copying [[element]]s of the extended argument to match the other one, [[cell]]s are copied.
 
Frame conformability may not allow [[singleton extension]] even when ordinary conformability supports it: [[Dyalog APL]], [[SHARP APL]], and [[A+]] have singleton extension for scalar dyadics but not for Rank (and [[J]] doesn't implement singleton extension). Of these, [[J]] and [[A+]] use [[leading axis agreement]] while SHARP and Dyalog use only empty-frame extension, the equivalent of scalar extension. However, [[NARS2000]] implements Rank with singleton extension for frames.


== External links ==
== External links ==

Latest revision as of 03:17, 20 February 2024

Conformability describes the conditions that must be satisfied by arguments to dyadic scalar functions. The arguments must match in shape, taking into account scalar extension and, when supported, singleton extension or leading axis agreement. The criteria which determine the result shape are often considered part of conformability as well. The Each operator also checks conformability when called dyadically, and some functionality, such as multiple assignment, might use modified conformability rules.

Two arguments are said to conform when they have matching shapes, or one of them is extendible to match the other's shape. Possible rules for extensibility are:

The result shape associated with such arguments can then be determined:

  • If the shapes matched, it is that shape
  • If exactly one argument was extended, it is the other argument's shape
  • Otherwise, it is the shape of the argument with the largest rank (this condition is only possible with singleton extension).

Frame conformability

Main article: Frame agreement

The Rank operator and function rank check for conformability not on the entire shapes of arguments, but only on their frames. The same procedure applies to determine whether two frames conform, and if function f's result shape is known, then the result shape of f⍤l r can be found by appending it to the shape obtained from conformability on the frames computed from ranks l and r. Rather than copying elements of the extended argument to match the other one, cells are copied.

Frame conformability may not allow singleton extension even when ordinary conformability supports it: Dyalog APL, SHARP APL, and A+ have singleton extension for scalar dyadics but not for Rank (and J doesn't implement singleton extension). Of these, J and A+ use leading axis agreement while SHARP and Dyalog use only empty-frame extension, the equivalent of scalar extension. However, NARS2000 implements Rank with singleton extension for frames.

External links

APL features [edit]
Built-ins Primitives (functions, operators) ∙ Quad name
Array model ShapeRankDepthBoundIndex (Indexing) ∙ AxisRavelRavel orderElementScalarVectorMatrixSimple scalarSimple arrayNested arrayCellMajor cellSubarrayEmpty arrayPrototype
Data types Number (Boolean, Complex number) ∙ Character (String) ∙ BoxNamespaceFunction array
Concepts and paradigms Conformability (Scalar extension, Leading axis agreement) ∙ Scalar function (Pervasion) ∙ Identity elementComplex floorArray ordering (Total) ∙ Tacit programming (Function composition, Close composition) ∙ GlyphLeading axis theoryMajor cell searchFirst-class function
Errors LIMIT ERRORRANK ERRORSYNTAX ERRORDOMAIN ERRORLENGTH ERRORINDEX ERRORVALUE ERROREVOLUTION ERROR