|
From: Andrii S. <and...@gm...> - 2023-05-09 16:45:56
|
> You might like to insert local(arr) as the first line in your code. A bit off-topic, but: I always wondered, why Maxima does not save the properties of an argument, just like it saves its value? See also the bug #3251 at https://sourceforge.net/p/maxima/bugs/3251/. Andrii > 7 трав. 2023 р. о 14:35 Barton Willis via Maxima-discuss <max...@li...> написав(ла): > > You might like to insert local(arr) as the first line in your code. Without it, we have > > (%i2) permsign([1,2,3]); > (%o2) 1 > > (%i3) arr[2] : 1; > (%o3) 1 > > (%i4) permsign([1,2,3]); > (%o4) -1 > > Also, you might like to either quote nil or change it to false—otherwise, we have > > OK > (%i2) permsign([1,2,3]); > (%o2) 1 > > Set nil to zero > (%i3) nil : 0; > (%o3) 0 > > Not OK > (%i4) permsign([1,2,3]); > (%o4) 0 > > --Barton > > > > From: Dimiter Prodanov <mailto:dim...@gm...> > Sent: Saturday, May 6, 2023 4:07 PM > To: Daniel Volinski <mailto:dan...@ya...> > Cc: max...@li... <mailto:max...@li...> > Subject: Re: [Maxima-discuss] sign of permutation > > Non-NU Email > <E73FF49F87D646DAA6E7B7B891733959.png> > Here is what I wrote for the clifford packages > > permsign(arr):=block([k:0, len, ret:0 ] , > mode_declare([k, len], fixnum), > if not listp(arr) then return (false), > len:length(arr), > for i:1 thru len do ( > if not mapatom(arr[i]) then ret:nil, > for j:i+1 thru len do > if ordergreatp(arr[i], arr[j]) then k:k+1 > ), > if ret#nil then > if evenp(k) then 1 else -1 > else 0 > ); > > best regards, > > Dimiter > > On Sat, May 6, 2023 at 10:00 AM Daniel Volinski via Maxima-discuss <max...@li... <mailto:max...@li...>> wrote: > Hi Jaime, > > Thank you for the input. > However, this is not what I need. > > My original intention was to symmetrize or anti-symmetrize tensors with abstract indices. > For the symmetrization there is no problem because you sum all the permutations. > But for the anti-symmetrization you need to sum all the permutations but each one > should be multiplied by the sign (or parity) of the permutation. > > perm_parity([λ,σ,μ]) issues an error: "argument should be a permutation". > > Thanks, > > Daniel Volinski > > > En viernes, 5 de mayo de 2023, 21:23:23 GMT+3, Jaime Villate <vi...@fe... <mailto:vi...@fe...>> escribió: > > > On 05/05/23 18:24, Daniel Volinski via Maxima-discuss wrote: > > Is there a command in Maxima the calculates the sign of a permutation? > > > > Given a base permutation (a list) and a test permutation (a list) of > > the same elements, > > I would l like a command to calculate the number of switches needed to > > go from one > > to the other or (alternatively) whether this number is odd or even. > > > Hello Daniel, > > Function perm_parity, from additional package combinatorics, will give 0 > if the permutation is even or 1 if it is odd. > > Regards, > > Jaime > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... <mailto:Max...@li...> > https://lists.sourceforge.net/lists/listinfo/maxima-discuss <https://urldefense.com/v3/__https:/lists.sourceforge.net/lists/listinfo/maxima-discuss__;!!PvXuogZ4sRB2p-tU!HM996JbkxFmrzmxNP9-cYShG7BYXZiBtkv2qlzvyH_B8pJYETnYBaQkSNd21knCFh16-Id9OPVJNs-z7$> > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss |