Matrix-exponentiation operator: Difference between revisions
Content deleted Content added
→{{header|Ruby}}: removed bit about Ruby pre 1.9.3 |
Added Wren |
||
Line 3,440: | Line 3,440: | ||
15661 116209 35543 |
15661 116209 35543 |
||
4221 31322 9580 </pre> |
4221 31322 9580 </pre> |
||
=={{header|Wren}}== |
|||
{{libheader|Wren-fmt}} |
|||
{{libheader|Wren-matrix}} |
|||
Wren's Num class uses a method (pow) rather than an operator for exponentiation. |
|||
The Matrix class in the above module also has a 'pow' method but, as an alternative, overloads the otherwise unused '^' operator to provide the same functionality. |
|||
<lang ecmascript>import "/matrix" for Matrix |
|||
import "/fmt" for Fmt |
|||
var m = Matrix.new([[0, 1], [1, 1]]) |
|||
System.print("Original:\n") |
|||
Fmt.mprint(m, 2, 0) |
|||
System.print("\nRaised to power of 10:\n") |
|||
Fmt.mprint(m ^ 10, 3, 0)</lang> |
|||
{{out}} |
|||
<pre> |
|||
Original: |
|||
| 0 1| |
|||
| 1 1| |
|||
Raised to power of 10: |
|||
| 34 55| |
|||
| 55 89| |
|||
</pre> |
|||
{{omit from|Icon|no operator overloading}} |
{{omit from|Icon|no operator overloading}} |