Matrix: Difference between revisions
From NARS2000
Jump to navigationJump to search
(Created page with "<table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> <tr> <td><apll>Z←f⌻R</apll></td> <td></td> <td></td> <td>applies the monadic function <a...") |
mNo edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> | <table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> | ||
<tr> | <tr> | ||
<td><apll> | <td valign="top"><apll>Z←<i>f</i>⌻R</apll></td> | ||
<td></td> | <td></td> | ||
<td></td> | <td></td> | ||
<td>applies the monadic function <apll>f</apll> to the (square) diagonalizable matrix <apll>R</apll> as a whole and returns the resulting matrix. The shape of the result is <apll>⍴R</apll>.</td> | <td>applies the monadic function <apll><i>f</i></apll> to the (square) diagonalizable matrix <apll>R</apll> as a whole and returns the resulting matrix. The shape of the result is <apll>⍴R</apll>.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><apll> | <td valign="top"><apll>Z←L <i>f</i>⌻R</apll></td> | ||
<td></td> | <td></td> | ||
<td></td> | <td></td> | ||
<td>applies the monadic derived function <apll> | <td>applies the monadic derived function <apll>L∘<i>f</i></apll> to the (square) diagonalizable matrix <apll>R</apll> as a whole and returns the resulting matrix. <apll>L</apll> is a scalar. The shape of the result is <apll>⍴R</apll>.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><apll>Z←∘⌻R</apll></td> | <td valign="top"><apll>Z←∘⌻R</apll></td> | ||
<td></td> | <td></td> | ||
<td></td> | <td></td> | ||
<td>for scalar R, returns a (square) matrix representation of | <td>for Hypercomplex scalar R, returns a (square) matrix representation of <apll>R</apll>. The shape of the result is <apll>2⍴=R</apll>.</td> | ||
</tr> | </tr> | ||
Line 25: | Line 25: | ||
<td></td> | <td></td> | ||
<td></td> | <td></td> | ||
<td>for vector R, returns a (square) diagonal matrix with the items in <apll>R</apll> inserted into the diagonal. | <td>for a simple or nested vector R, returns a (square) diagonal matrix with the items in <apll>R</apll> inserted into the diagonal. For a nested vector <apll>R</apll>, its items must be simple numeric scalars, vectors, or matrices. The shape of the result is <apll>2⍴+/≢¨R</apll>.</td> | ||
</tr> | |||
<tr> | |||
<td colspan="4">The symbol QuadJot (<apll>⌻</apll>, U+233B) may be entered from the keyboard with Alt-'F' or Ctrl-'F' depending upon your keyboard layout.</td> | |||
</tr> | </tr> | ||
</table> | </table> | ||
When applying a scalar function to a matrix, the matrix is viewed as a container of its scalar elements and the scalar function is applied to the individual elements. Another way to look at this is as applying the [https://en.wikipedia.org/wiki/Matrix_function scalar function to the matrix as a whole], that is treating it as a new datatype. This concept is identical to the [[Multisets]] operator which treats its arguments as a new datatype: Multisets, i.e., sets with repeated elements. | |||
For example, | |||
<apll><pre> | |||
⍝ The Factorial of a matrix | |||
!⌻2 2⍴1 3 2 1 | |||
3.6274 8.8423 | |||
5.8949 3.6274 | |||
m←0.01×3 3⍴⍳9 | |||
m | |||
0.01 0.02 0.03 | |||
0.04 0.05 0.06 | |||
0.07 0.08 0.09 | |||
⍝ The Sine of a matrix | |||
1○⌻m | |||
0.0099221 0.019904 0.029886 | |||
0.039823 0.049783 0.059742 | |||
0.069724 0.079661 0.089599 | |||
⍝ Arcsin of Sine returns the argument | |||
¯1○⌻1○⌻m | |||
0.01 0.02 0.03 | |||
0.04 0.05 0.06 | |||
0.07 0.08 0.09 | |||
⍝ A matrix representation of a Quaternion | |||
∘⌻<⍳4 | |||
1 ¯2 ¯3 ¯4 | |||
2 1 ¯4 3 | |||
3 4 1 ¯2 | |||
4 ¯3 2 1 | |||
⍝ A diagonal matrix | |||
∘⌻⍳4 | |||
1 0 0 0 | |||
0 2 0 0 | |||
0 0 3 0 | |||
0 0 0 4 | |||
⍝ A block diagonal matrix | |||
∘⌻(2 2⍴⍳4)⍬(3 3⍴⍳9)(10 20) 30 | |||
1 2 0 0 0 0 0 0 | |||
3 4 0 0 0 0 0 0 | |||
0 0 1 2 3 0 0 0 | |||
0 0 4 5 6 0 0 0 | |||
0 0 7 8 9 0 0 0 | |||
0 0 0 0 0 10 0 0 | |||
0 0 0 0 0 0 20 0 | |||
0 0 0 0 0 0 0 30 | |||
⍝ Factorial of a Complex number | |||
c←<⍳2 | |||
∘⌻c ⍝ Matrix representation of a Complex number | |||
1 ¯2 | |||
2 1 | |||
!⌻∘⌻c ⍝ Matrix Factorial of ... | |||
0.11229 ¯0.32361 | |||
0.32361 0.11229 | |||
1⌷[2]!⌻∘⌻c ⍝ First column of ... | |||
0.11229 0.32361 | |||
9○1⌷[2]!⌻∘⌻c ⍝ Real parts of ... | |||
0.11229 0.32361 | |||
<9○1⌷[2]!⌻∘⌻c ⍝ Complex number whose coefficients are ... | |||
0.11229<_J/>0.32361 | |||
!c ⍝ Using a different algorithm (GSL Complex factorial) | |||
0.11229<_J/>0.32361 | |||
⍝ Factorial of a Quaternion | |||
q←<⍳4 | |||
∘⌻q ⍝ Matrix representation of a Quaternion number | |||
1 ¯2 ¯3 ¯4 | |||
2 1 ¯4 3 | |||
3 4 1 ¯2 | |||
4 ¯3 2 1 | |||
!⌻∘⌻q ⍝ Matrix Factorial of ... | |||
0.0060975 0.0010787 0.001618 0.0021573 | |||
¯0.0010787 0.0060975 0.0021573 ¯0.001618 | |||
¯0.001618 ¯0.0021573 0.0060975 0.0010787 | |||
¯0.0021573 0.001618 ¯0.0010787 0.0060975 | |||
1⌷[2]!⌻∘⌻q ⍝ First column of ... | |||
0.0060975 ¯0.0010787 ¯0.001618 ¯0.0021573 | |||
9○1⌷[2]!⌻∘⌻q ⍝ Real parts of ... | |||
0.0060975 ¯0.0010787 ¯0.001618 ¯0.0021573 | |||
<9○1⌷[2]!⌻∘⌻q ⍝ Quaternion number whose coefficients are ... | |||
0.0060975<_i/>¯0.0010787<_j/>¯0.001618<_k/>¯0.0021573 | |||
!q | |||
0.0060975<_i/>¯0.0010787<_j/>¯0.001618<_k/>¯0.0021573 | |||
</pre></apll> |
Latest revision as of 23:27, 2 June 2022
Z←f⌻R | applies the monadic function f to the (square) diagonalizable matrix R as a whole and returns the resulting matrix. The shape of the result is ⍴R. | ||
Z←L f⌻R | applies the monadic derived function L∘f to the (square) diagonalizable matrix R as a whole and returns the resulting matrix. L is a scalar. The shape of the result is ⍴R. | ||
Z←∘⌻R | for Hypercomplex scalar R, returns a (square) matrix representation of R. The shape of the result is 2⍴=R. | ||
Z←∘⌻R | for a simple or nested vector R, returns a (square) diagonal matrix with the items in R inserted into the diagonal. For a nested vector R, its items must be simple numeric scalars, vectors, or matrices. The shape of the result is 2⍴+/≢¨R. | ||
The symbol QuadJot (⌻, U+233B) may be entered from the keyboard with Alt-'F' or Ctrl-'F' depending upon your keyboard layout. |
When applying a scalar function to a matrix, the matrix is viewed as a container of its scalar elements and the scalar function is applied to the individual elements. Another way to look at this is as applying the scalar function to the matrix as a whole, that is treating it as a new datatype. This concept is identical to the Multisets operator which treats its arguments as a new datatype: Multisets, i.e., sets with repeated elements.
For example,
⍝ The Factorial of a matrix !⌻2 2⍴1 3 2 1 3.6274 8.8423 5.8949 3.6274 m←0.01×3 3⍴⍳9 m 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 ⍝ The Sine of a matrix 1○⌻m 0.0099221 0.019904 0.029886 0.039823 0.049783 0.059742 0.069724 0.079661 0.089599 ⍝ Arcsin of Sine returns the argument ¯1○⌻1○⌻m 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 ⍝ A matrix representation of a Quaternion ∘⌻<⍳4 1 ¯2 ¯3 ¯4 2 1 ¯4 3 3 4 1 ¯2 4 ¯3 2 1 ⍝ A diagonal matrix ∘⌻⍳4 1 0 0 0 0 2 0 0 0 0 3 0 0 0 0 4 ⍝ A block diagonal matrix ∘⌻(2 2⍴⍳4)⍬(3 3⍴⍳9)(10 20) 30 1 2 0 0 0 0 0 0 3 4 0 0 0 0 0 0 0 0 1 2 3 0 0 0 0 0 4 5 6 0 0 0 0 0 7 8 9 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 20 0 0 0 0 0 0 0 0 30 ⍝ Factorial of a Complex number c←<⍳2 ∘⌻c ⍝ Matrix representation of a Complex number 1 ¯2 2 1 !⌻∘⌻c ⍝ Matrix Factorial of ... 0.11229 ¯0.32361 0.32361 0.11229 1⌷[2]!⌻∘⌻c ⍝ First column of ... 0.11229 0.32361 9○1⌷[2]!⌻∘⌻c ⍝ Real parts of ... 0.11229 0.32361 <9○1⌷[2]!⌻∘⌻c ⍝ Complex number whose coefficients are ... 0.11229J0.32361 !c ⍝ Using a different algorithm (GSL Complex factorial) 0.11229J0.32361 ⍝ Factorial of a Quaternion q←<⍳4 ∘⌻q ⍝ Matrix representation of a Quaternion number 1 ¯2 ¯3 ¯4 2 1 ¯4 3 3 4 1 ¯2 4 ¯3 2 1 !⌻∘⌻q ⍝ Matrix Factorial of ... 0.0060975 0.0010787 0.001618 0.0021573 ¯0.0010787 0.0060975 0.0021573 ¯0.001618 ¯0.001618 ¯0.0021573 0.0060975 0.0010787 ¯0.0021573 0.001618 ¯0.0010787 0.0060975 1⌷[2]!⌻∘⌻q ⍝ First column of ... 0.0060975 ¯0.0010787 ¯0.001618 ¯0.0021573 9○1⌷[2]!⌻∘⌻q ⍝ Real parts of ... 0.0060975 ¯0.0010787 ¯0.001618 ¯0.0021573 <9○1⌷[2]!⌻∘⌻q ⍝ Quaternion number whose coefficients are ... 0.0060975i¯0.0010787j¯0.001618k¯0.0021573 !q 0.0060975i¯0.0010787j¯0.001618k¯0.0021573