Ask Your Question

Symbol 1's profile - activity

2020-08-31 11:22:41 -0500 commented answer Combinations(range(100), 100).list() takes forever

Thank you; that will work.

2020-08-30 21:57:17 -0500 received badge  Commentator
2020-08-30 21:57:17 -0500 commented question Combinations(range(100), 100).list() takes forever

PS. I am using itertools.combinations as an alternative.

2020-08-30 21:32:28 -0500 received badge  Editor (source)
2020-08-30 21:28:20 -0500 asked a question Combinations(range(100), 100).list() takes forever

As title suggests, Combinations( range(100), 100 ).list() takes forever.

On the other hand, Combinations( range(100), 0 ).list() is pretty fast.

Is there anything I can do to improve the performance?

2020-05-02 16:11:29 -0500 received badge  Notable Question (source)
2020-02-13 19:29:17 -0500 received badge  Popular Question (source)
2020-02-08 13:37:31 -0500 received badge  Supporter (source)
2020-02-08 13:37:29 -0500 received badge  Scholar (source)
2019-05-22 04:07:54 -0500 received badge  Notable Question (source)
2019-03-13 07:13:27 -0500 received badge  Popular Question (source)
2018-09-15 15:36:56 -0500 commented question Sage does not see Imagemagick

@Iguananaut I feel like there are two PATHs. The PATH in my terminal does contains /usr/local/bin/ as I can see it if I do echo $PATH. But then the python coming with sage assumes a different PATH, which does not contain /usr/local/, as shown by os.environ["PATH"]. I am not sure which .profile should I fix in this case.

2018-09-11 19:49:38 -0500 commented question Sage does not see Imagemagick

I temporarily solve this by os.environ["PATH"]+=":/usr/local/bin". Looking for a permanent solution.

2018-09-11 19:27:11 -0500 commented question Sage does not see Imagemagick

Update: have_program('convert',path="/usr/local/bin") returns true.

2018-09-11 19:18:14 -0500 asked a question Sage does not see Imagemagick

I am trying out the animation thing in http://doc.sagemath.org/html/en/refer....

But Sage keep saying

Error: Neither ImageMagick nor ffmpeg appears to be installed.

And indeed

from sage.misc.sage_ostools import have_program
have_program('convert')

returns false.

But I do have ImageMagick installed by homwbrew. i.e. it works perfectly in Terminal.

What Could Possibly Go Wrong?

(macOS 10.13; Sage 8.3; Imagemagick 7.0.8.)

2018-02-06 18:14:04 -0500 commented question It takes so long to generate dictionary of GL elements.

@slelievre before 8.0 now 8.1 and everything is good now. @dan_fulea: I am implementing a group action that is quite tedious. GL(4,2) acts on [0..15] by left-multiplying its binary expression as a column vector in GF(2)^4. And then act on Subsets([0..15]). I would like to cache the action as there are only 20160·16 possibilities. Moreover, if there is a (fast) way to turn g into 16-bit int then I need an array of size 65536·16, which is still affordable. What would make it triumph is that looking up array entry takes ~100ns.

2018-02-06 18:05:00 -0500 commented answer It takes so long to generate dictionary of GL elements.

Thank you. I did update from 8.0 to 8.1. I was not aware of the version-issue because I thought I was quite new. Now everything works fine. hash(g) gives crazy numbers such as -32759827368972486.

2018-02-05 19:36:48 -0500 commented question It takes so long to generate dictionary of GL elements.

Found this https://trac.sagemath.org/ticket/10950. Maybe I should update my Sage.

2018-02-05 19:21:25 -0500 commented question It takes so long to generate dictionary of GL elements.

It seems hash(g) lies between 0 and 15 for all g. It does not make any sense to me.

2018-02-05 19:03:25 -0500 asked a question It takes so long to generate dictionary of GL elements.

The following command

GL4dicthash={hash(g):None for g in GL(4,2)}

takes 9 seconds to execute. On the other hand

GL4dict={g:None for g in GL(4,2)}

takes minutes and does not seem to terminate.

If I understand python dictionary correctly, they should take about the same time. So what happened?

2018-01-23 18:32:17 -0500 asked a question Making a dictionary of matrices, and save the session

Some time ago I made a dictionary of matrices with your help.

Now I like to save the session by save_session() but somehow I fail. The terminal goes as follows

sage: A=matrix(GF(2),[[1,0],[0,1]])
sage: A.set_immutable()
sage: dictA={A:1}
sage: save_session(verbose=true)
Saving A
Not saving dictA: mutable matrices are unhashable

On the other hand

sage: A=matrix([[1,0],[0,1]])
sage: A.set_immutable()
sage: dictA={A:1}
sage: save_session(verbose=true)
Saving A
Saving dictA

I have no idea why specifying GF(2) fails save_session(). Does anyone know a fix?

2017-12-26 15:00:33 -0500 received badge  Student (source)
2017-12-19 20:14:36 -0500 commented answer Making a dictionary of matrices

I guess my bottleneck is that I expect set_mutable to return the object itself (like sorted()). By the way what is the best way to lookup the type of methods?

2017-12-19 20:10:14 -0500 commented question Making a dictionary of matrices

@dan_fulea Well I expect the dictionary to record not only entries but also the width and height. If I come up with a method that turns a matrix into a hashable matrix then I am reinventing .set_immutable(). So maybe the real question is why don't sage/python automatically make a hashable copy and then hash it.

2017-12-19 16:16:31 -0500 asked a question Making a dictionary of matrices

I am trying to make a dictionary of matrices. Ideally

MatDic={ 
    matrix(GF(2),2,[1,0,0,1]):'a',
    matrix(GF(2),2,[1,1,0,1]):'b'
    # etc
}

But Sage refuses to hash (mutable) matrices. I then tried

MatDic={ 
    matrix(GF(2),2,[1,0,0,1]).set_immutable():'a',
    matrix(GF(2),2,[1,1,0,1]).set_immutable():'b'
}
MatDic

which gives

{None: 'b'}

I also tried making a dictionary of tuples

MatDic={ 
    (1,0,0,1):'a',
    (1,1,0,1):'b'
}

which raises no errors; However

MatDic[tuple(matrix(GF(2),2,[1,0,0,1]))]

gives

TypeError: mutable vectors are unhashable

What is the best, if possible, way to make a dictionary and lookup matrices?