# Difference between revisions of "Conformability"

m (1 revision imported) |
(Leading axis agreement and the Rank operator) |
||

Line 1: | Line 1: | ||

− | '''Conformability''' describes the conditions that must be satisfied by [[argument]]s to [[dyadic]] [[scalar function]]s. The arguments must match in [[shape]], taking into account [[scalar extension]] and, when | + | '''Conformability''' describes the conditions that must be satisfied by [[argument]]s to [[dyadic]] [[scalar function]]s. 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 | + | 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: |

− | + | * [[Scalar extension]]: one argument is a [[scalar]] (this is used in all APLs). | |

− | + | * [[Singleton extension]]: at least one argument is a [[singleton]]. | |

+ | * [[Leading axis agreement]]: one argument's shape is a [[prefix]] of the other's. This is a superset of scalar extension. | ||

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

Line 10: | Line 11: | ||

* Otherwise, it is the shape of the argument with the largest rank (this condition is only possible with [[singleton extension]]). | * Otherwise, it is the shape of the argument with the largest rank (this condition is only possible with [[singleton extension]]). | ||

+ | == 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 the function's result rank is known, then the result shape can be found by appending it to the shape obtained from conformability on the frames. Rather than copying [[elements]] of the extended argument to match the other one, [[cell]]s are copied. | ||

+ | |||

+ | 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. | ||

{{APL features}} | {{APL features}} |

## Latest revision as of 16:49, 20 March 2020

**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:

- Scalar extension: one argument is a scalar (this is used in all APLs).
- Singleton extension: at least one argument is a singleton.
- Leading axis agreement: one argument's shape is a prefix of the other's. This is a superset of scalar extension.

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

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 the function's result rank is known, then the result shape can be found by appending it to the shape obtained from conformability on the frames. Rather than copying elements of the extended argument to match the other one, cells are copied.

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.

APL features [edit]
| |
---|---|

Built-ins | Primitive function ∙ Primitive operator ∙ Quad name |

Array model | Shape ∙ Rank ∙ Depth ∙ Bound ∙ Index ∙ Axis ∙ Ravel ∙ Ravel order ∙ Element ∙ Scalar ∙ Vector ∙ Matrix ∙ Simple scalar ∙ Simple array ∙ Nested array ∙ Box ∙ Cell ∙ Major cell ∙ Subarray ∙ Empty array ∙ Prototype |

Concepts and paradigms | Leading axis theory ∙ Scalar extension ∙ Conformability ∙ Scalar function ∙ Glyph ∙ Identity element ∙ Total array ordering |

Errors | LIMIT ERROR ∙ RANK ERROR ∙ SYNTAX ERROR |