Determinant and permanent: Difference between revisions
Content added Content deleted
m (correct a misspelling) |
(Add Factor example) |
||
Line 469: | Line 469: | ||
</lang> |
</lang> |
||
=={{header|Factor}}== |
|||
<lang factor>USING: fry kernel math.combinatorics math.matrices sequences ; |
|||
: permanent ( matrix -- x ) |
|||
dup square-matrix? [ "Matrix must be square." throw ] unless |
|||
[ dim first <iota> ] keep |
|||
'[ [ _ nth nth ] map-index product ] map-permutations sum ;</lang> |
|||
Example output: |
|||
<pre> |
|||
IN: scratchpad USE: math.matrices.laplace ! for determinant |
|||
{ { 2 9 4 } { 7 5 3 } { 6 1 8 } } |
|||
[ determinant ] [ permanent ] bi |
|||
--- Data stack: |
|||
-360 |
|||
900 |
|||
</pre> |
|||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
{{libheader|Forth Scientific Library}} |
{{libheader|Forth Scientific Library}} |