Talk:Permutations by swapping: Difference between revisions

→‎Alternative Perl6 version: I remove this: it does not work properly
(→‎Does "Python: recursive" fit this task?: successive items by a swap between two items plus give the sign.)
(→‎Alternative Perl6 version: I remove this: it does not work properly)
 
(9 intermediate revisions by 3 users not shown)
Line 30:
 
: It can be used directly in the formula there for calculating a determinant using the sign and the permutations. (But, from the talk page, you don't have to use any particular algorithm) --[[User:Paddy3118|Paddy3118]] 15:56, 30 July 2012 (UTC)
 
== Python code issues ==
 
Several of them:
# The whole thing makes no sense. You don't want a O(n!) algorithm for determinant when there's a polynomial one, so it's odd one should bear matrices in mind, especally when dealing with a slow language like Python. Try a say, 12x12 matrix, and watch yourself die of old age before it finishes.
# Saving code here as spermutations.py and run the code in [[Matrix arithmetic]], it will say "TypeError: 'int' object is not iterable" (python 2) or "if DEBUG: print ' #', p SyntaxError" (python 3). Disregarding the latter, probably line 19 in code over there should have said <code>s = list(spermutations(r))</code>?
# Change that, and now code blows up on line 35 in spermutations.py. The 'n' here should be 'n1', maybe?
# Change ''that'', now <code>det([ range(5) for _ in range(5) ])</code> doesn't seem to return, ever. Maybe it's just Python being slow? (no not really).
# Replace the main section of spermutations.py with <code>for x in spermutations(range(3)): print(x)</code>, and run it. How many lines should it produce?
--[[User:Ledrug|Ledrug]] 19:27, 4 August 2012 (UTC)
 
:Hi Ledrug,
:# Its straight forward to see how that particular equation for a determinant is derived. That way of defining what a determinant ''is'' is still in use. Just like people are told about efficiency issues with the recursive method of calculating a factorial, but the recursive method of calculating a factorial has other legit uses. Computational efficiency has its place but is not all, and yes I do know that that particular method of calculating a determinant is inefficient. I did not say otherwise.
:# And the others: My original versions of both programs worked together (Python 2.7). There have been edits since, I'll check (probably within the next day) - Thanks.
:--[[User:Paddy3118|Paddy3118]] 21:08, 4 August 2012 (UTC)
:: No it's not about making this method the most efficient for matrices, it's about why mentioning matrix -- or anything -- at all. You have four things in this task: generate all permutations; list parity for each; use swap only; apply to matrices. The first two are interesting enough, but there's no reason they can't be just included in the existing [[Permutations]] task, with or without the swapping requirement; the determinant thing is a nobrainer given the first two, particularly since it's not even a good method. To make it worse, it's questionable if the code under "recursive" heading can even be called a swapping method. Basically, I don't see why this task merits being a, well, task, instead of just a subheading under [[Permutations]]. --[[User:Ledrug|Ledrug]]
 
::We differ. That can be good. Try looking a little deeper and seeing if the author might not be trying to pull a fast one on you and cut them some slack. Or not. --[[User:Paddy3118|Paddy3118]] 03:17, 5 August 2012 (UTC)
 
:Yep Ledrug, although its use in the other task is mentioned, somone made a well-meaning change to the functions interfacethat broke things. I have removed that change as it was quickest, but I should probably update the Matrix task in the future. --[[User:Paddy3118|Paddy3118]] 21:45, 4 August 2012 (UTC)
1,934

edits