Inner Product: Difference between revisions

Jump to navigation Jump to search
425 bytes added ,  20:05, 26 January 2022
m
changed a 2 to a 4
m (changed a 2 to a 4)
(5 intermediate revisions by one other user not shown)
Line 51: Line 51:
\begin{align}
\begin{align}
\text{For example, if}\\
\text{For example, if}\\
\bf{A}&=\begin{pmatrix}
\boldsymbol{A}&=\begin{pmatrix}
1&3&2&0\\
1&3&2&0\\
2&1&0&1\\
2&1&0&1\\
2&0&0&2\\
4&0&0&2\\
\end{pmatrix}
\end{pmatrix}
\qquad\text{and}\qquad
\qquad\text{and}\qquad
\bf{B}=\begin{pmatrix}
\boldsymbol{B}=\begin{pmatrix}
4&1\\
4&1\\
0&3\\
0&3\\
Line 63: Line 63:
2&0\\
2&0\\
\end{pmatrix}\\
\end{pmatrix}\\
\text{then}\qquad\bf{A}\;^+_\times\,\bf{B}&=\begin{pmatrix}
\text{then}\qquad\boldsymbol{A}\;^+_\times\,\boldsymbol{B}&=\begin{pmatrix}
4&14\\
4&14\\
10&5\\
10&5\\
20&4\\
20&4\\
\end{pmatrix},
\end{pmatrix},
\quad\bf{A}\;^\and_=\,\bf{B}=\begin{pmatrix}
\quad\boldsymbol{A}\;^\and_=\,\boldsymbol{B}=\begin{pmatrix}
0&1\\
0&1\\
0&0\\
0&0\\
1&0\\
1&0\\
\end{pmatrix}\text{,}\\
\end{pmatrix}\text{,}\\
\bf{A}\;^\or_\neq\;\bf{B}&=\begin{pmatrix}
\boldsymbol{A}\;^\or_\neq\;\boldsymbol{B}&=\begin{pmatrix}
1&0\\
1&0\\
1&1\\
1&1\\
0&1\\
0&1\\
\end{pmatrix},
\end{pmatrix},
\qquad\text{and}\qquad(\bf{A}\neq0)\;^+_{\,/}\,\bf{B}=\begin{pmatrix}
\qquad\text{and}\qquad(\boldsymbol{A}\neq0)\;^+_{\,/}\,\boldsymbol{B}=\begin{pmatrix}
4&6\\
4&6\\
6&4\\
6&4\\
Line 116: Line 116:


== Differences between dialects ==
== Differences between dialects ==
Implementations differ on the exact behaviour of inner product when the right operand is not a [[scalar function]]. It follows from page 121 of the ISO/IEC 13751:2001(E) [[standard]] specifies that <source lang=apl inline>X f.g Y</source> is equivalent to <source lang=apl inline>⊃⍤0 f/¨ (⊂[⍴⍴x]x)∘.g ⊂[1]y</source>. This is indeed what [[APL2]], [[APLX]], and [[ngn/apl]] follow, while [[Dyalog APL]] and [[GNU APL]] use <source lang=apl inline>⊃⍤0 f/¨ (⊂[⍴⍴x]x)∘.(g¨) ⊂[1]y</source>.
Implementations differ on the exact behaviour of inner product when the right operand is not a [[scalar function]]. It follows from page 121 of the ISO/IEC 13751:2001(E) [[standard]] specifies that <source lang=apl inline>X f.g Y</source> is equivalent to <source lang=apl inline>f/¨ (⊂[⍴⍴x]x)∘.g ⊂[1]y</source>. This is indeed what [[APL2]], [[APLX]], [[APL+Win]], and [[ngn/apl]] follow, while [[Dyalog APL]], [[NARS2000]] and [[GNU APL]] differ as described by [[Roger Hui]]:<ref>[[Roger Hui]]. ''inner product''. Internal Dyalog email. 24 July 2020.</ref>
 
as [[Roger Hui]] writes:<ref>[[Roger Hui]]. ''inner product''. Internal Dyalog email. 24 July 2020.</ref>
<blockquote>
<blockquote>
The following dop models inner product in Dyalog APL, with caveats.  If you find a case where <source lang=apl inline>f.g</source> differs from <source lang=apl inline>f IP g</source>, not covered by the caveats, I'd be interested.
The following dop models inner product in Dyalog APL, with caveats.  If you find a case where <source lang=apl inline>f.g</source> differs from <source lang=apl inline>f IP g</source>, not covered by the caveats, I'd be interested.
Line 150: Line 148:
* [https://microapl.com/apl_help/ch_020_020_880.htm APLX]
* [https://microapl.com/apl_help/ch_020_020_880.htm APLX]
* J [https://www.jsoftware.com/help/dictionary/d300.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/dot#dyadic NuVoc]
* J [https://www.jsoftware.com/help/dictionary/d300.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/dot#dyadic NuVoc]
=== Discussion of differences between dialects ===
* [https://groups.google.com/g/comp.lang.apl/c/23LrwRZKmPs Dyalog / APL2000 discrepancy] (Google Groups)
* [https://lists.gnu.org/archive/html/bug-apl/2016-07/msg00020.html multiple inner product] (GNU APL mailing list)
* [https://lists.gnu.org/archive/html/bug-apl/2018-05/msg00003.html  an other inner product ,., bug] (GNU APL mailing list)
== References ==
== References ==
<references/>
<references/>
{{APL built-ins}}[[Category:Primitive operators]]
{{APL built-ins}}[[Category:Primitive operators]]

Navigation menu