Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
347 stars 231 forks source link

LieTypes tensor product bug #2730

Closed pzinn closed 1 year ago

pzinn commented 1 year ago

Note the error last line. Seems the ** routine assumes the modules are irreducible. @dswinarski

i2 :  needsPackage "LieTypes"

o2 = LieTypes

o2 : Package

i4 : g=simpleLieAlgebra("A",2)

o4 = g

o4 : LieAlgebra

i5 : U=irreducibleLieAlgebraModule({4,2},g)

o5 = U

o5 : g module

i6 : V=irreducibleLieAlgebraModule({3,1},g)

o6 = V

o6 : g module

i7 : U**V

o7 = {LieAlgebra => g                                        }
      isIrreducible => false
      DecompositionIntoIrreducibles => HashTable{{0, 5} => 1}
                                                 {1, 3} => 1
                                                 {1, 6} => 1
                                                 {2, 1} => 1
                                                 {2, 4} => 2
                                                 {3, 2} => 2
                                                 {3, 5} => 1
                                                 {4, 0} => 1
                                                 {4, 3} => 2
                                                 {5, 1} => 2
                                                 {5, 4} => 1
                                                 {6, 2} => 2
                                                 {7, 0} => 1
                                                 {7, 3} => 1
                                                 {8, 1} => 1

o7 : g module

i8 : oo**V
stdio:9:3:(3): error: key not found in hash table
pzinn commented 1 year ago

I see this package is in need of a bit of dusting. I'm happy to do that myself (if the authors don't object) since I find the package potentially useful.

dswinarski commented 1 year ago

Hi Paul,

Thanks for catching this bug. And please, dust away! I don't know what issues you have in mind, but I have been told that there are faster algorithms for computing multiplicities than what I implemented here.

Best,

Dave ___

David Swinarski, Ph.D. Associate Professor and Chair, Department of Mathematics Fordham University 718.817.2478

@.***

(he/him/his) ___

On Mon, Jan 2, 2023 at 5:37 PM Paul Zinn-Justin @.***> wrote:

I see this package is in need of a bit of dusting. I'm happy to do that myself (if the authors don't object) since I find the package potentially useful.

— Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Macaulay2_M2_issues_2730-23issuecomment-2D1369251030&d=DwMCaQ&c=aqMfXOEvEJQh2iQMCb7Wy8l0sPnURkcqADc2guUW8IM&r=99bd43s7BJCcaPw30g8QNVpRpg2Zr5a8ej40_KYfRsA&m=IDPSlV3tf6yFGfGorIayjOB1NkQCjymxJtWW70wETp_8zXlkMMeHtTHivlSmLOqk&s=_t4dP-8-tNVLiOAGttkbmXVbMFKHO4x5pGn8PAhbNSo&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ABQIW4R3SMS62XHWIDTKIBLWQNKBJANCNFSM6AAAAAATOWLOHM&d=DwMCaQ&c=aqMfXOEvEJQh2iQMCb7Wy8l0sPnURkcqADc2guUW8IM&r=99bd43s7BJCcaPw30g8QNVpRpg2Zr5a8ej40_KYfRsA&m=IDPSlV3tf6yFGfGorIayjOB1NkQCjymxJtWW70wETp_8zXlkMMeHtTHivlSmLOqk&s=494mq1pBVcu-G5wQIZqkgP-UilVCA3R0xRh767I6fy4&e= . You are receiving this because you were mentioned.Message ID: @.***>

pzinn commented 1 year ago

Hi Dave and thanks for getting back to me so quickly. I wouldn't touch any of your algorithms, just improve a bit the output (especially in WebApp mode), fix the ** bug, and fix (and export) LieAlgebraModuleFromWeights which I think is useful too.

pzinn commented 1 year ago

in fact, here's what I had in mind: (I've uploaded the modified version to the cloud so one can play with it) https://www.unimelb-macaulay2.cloud.edu.au/?user=LieTypes#editor:/usr/share/Macaulay2/LieTypes.m2 I've introduced a shorthand LL because irreducibleLieAlgebraModule is just too long to type; it advantageously allows for a nice expression. One could consider alternatives (VV comes to mind, for a calligraphic V in TeX)

mikestillman commented 1 year ago

@pzinn That looks very nice!

pzinn commented 1 year ago

actually I did take a quick look at the tensor product algorithm and one line puzzled me: https://github.com/Macaulay2/M2/blob/048c777dc703365e44c3865b2c1faed698b82b3a/M2/Macaulay2/packages/LieTypes.m2#L715 im is a list of weights, and found a set of weights. so im can never be a member of found. perhaps you meant subset? or is the algorithm supposed to test each element of im one by one?

pzinn commented 1 year ago

I think I understand. I might work a bit on improving the algorithm too.

pzinn commented 1 year ago

Before:

i1 : needsPackage "LieTypes";

i2 : g=simpleLieAlgebra("A",4); M=irreducibleLieAlgebraModule({1,0,0,1},g);

i4 : L=apply(20,i->time(M^**i));
     -- used 0.00005411 seconds
     -- used 7.624e-6 seconds
     -- used 0.0886696 seconds
     -- used 7.74786 seconds
     -- used 302.532 seconds

(then runs out of memory) After:

i1 : needsPackage "LieTypes";

i2 : g=simpleLieAlgebra("A",4); M=irreducibleLieAlgebraModule({1,0,0,1},g);

i4 : L=apply(20,i->time(M^**i));
     -- used 0.000054507 seconds
     -- used 7.124e-6 seconds
     -- used 0.0272024 seconds
     -- used 0.00275282 seconds
     -- used 0.00545102 seconds
     -- used 0.00950493 seconds
     -- used 0.0169458 seconds
     -- used 0.0381436 seconds
     -- used 0.0427784 seconds
     -- used 0.0932112 seconds
     -- used 0.132135 seconds
     -- used 0.206884 seconds
     -- used 0.323412 seconds
     -- used 0.457683 seconds
     -- used 0.697891 seconds
     -- used 0.935569 seconds
     -- used 1.28723 seconds
     -- used 1.75323 seconds
     -- used 2.40269 seconds
     -- used 3.40034 seconds

optimized ;-)

dswinarski commented 1 year ago

Very cool!

On Thu, Jan 5, 2023 at 7:40 PM Paul Zinn-Justin @.***> wrote:

Before:

i1 : needsPackage "LieTypes";

i2 : g=simpleLieAlgebra("A",4); M=irreducibleLieAlgebraModule({1,0,0,1},g);

i4 : L=apply(20,i->time(M^**i)); -- used 0.00005411 seconds -- used 7.624e-6 seconds -- used 0.0886696 seconds -- used 7.74786 seconds -- used 302.532 seconds

(then runs out of memory) After:

i1 : needsPackage "LieTypes";

i2 : g=simpleLieAlgebra("A",4); M=irreducibleLieAlgebraModule({1,0,0,1},g);

i4 : L=apply(20,i->time(M^**i)); -- used 0.000054507 seconds -- used 7.124e-6 seconds -- used 0.0272024 seconds -- used 0.00275282 seconds -- used 0.00545102 seconds -- used 0.00950493 seconds -- used 0.0169458 seconds -- used 0.0381436 seconds -- used 0.0427784 seconds -- used 0.0932112 seconds -- used 0.132135 seconds -- used 0.206884 seconds -- used 0.323412 seconds -- used 0.457683 seconds -- used 0.697891 seconds -- used 0.935569 seconds -- used 1.28723 seconds -- used 1.75323 seconds -- used 2.40269 seconds -- used 3.40034 seconds

optimized ;-)

— Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Macaulay2_M2_issues_2730-23issuecomment-2D1372981433&d=DwMCaQ&c=aqMfXOEvEJQh2iQMCb7Wy8l0sPnURkcqADc2guUW8IM&r=99bd43s7BJCcaPw30g8QNVpRpg2Zr5a8ej40_KYfRsA&m=4U1IaRDMaVB-4eLOyJrtuL08tC6vUSsbl-NNommW3S63y7-gC3i8ZXSBmdTlzpO6&s=4WlryTtw5pEFxZXL0FyYA1eESDLjCHfw1FRe-Yv_Lf4&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ABQIW4XRKO4B2UL62T4I3TDWQ5SWVANCNFSM6AAAAAATOWLOHM&d=DwMCaQ&c=aqMfXOEvEJQh2iQMCb7Wy8l0sPnURkcqADc2guUW8IM&r=99bd43s7BJCcaPw30g8QNVpRpg2Zr5a8ej40_KYfRsA&m=4U1IaRDMaVB-4eLOyJrtuL08tC6vUSsbl-NNommW3S63y7-gC3i8ZXSBmdTlzpO6&s=CVzHXSwy0pe70WmhW29aNHdGbUdIfVd1lYBJ44A5B8U&e= . You are receiving this because you were mentioned.Message ID: @.***>

-- ___

David Swinarski, Ph.D. Associate Professor and Chair, Department of Mathematics Fordham University 718.817.2478

@.***

(he/him/his) ___