Ask Your Question

imnvsh's profile - activity

2019-02-13 01:44:34 -0600 commented question Mapping 2-dimensional matrix index to a list

Are the individual parts always blocks without gaps in them? No, the parts could be either blocks with gaps or block without gaps.

For more example: (E1) The 1st and 3rd rows could be chosen as parts. (E2) 3 parts: the 1st column, the top-right cell, and the bottom-right cell. The rest is not chosen. Note: a) Parts could be the choice that does not the whole matrix as Example (E2) b) Parts' shapes are only square or rectangle, e.g no L-shape, /-shape, -shape, #-shape, or +-shape and so on.

2019-02-12 18:54:13 -0600 asked a question Mapping 2-dimensional matrix index to a list

Hi all,

I have a following matrix:

mat = matrix([[1,5,7],[3,10,12],[0,5,3]])
[ 1  5  7]
[ 3 10 12]
[ 0  5  3]

I got 3 parts from the matrix:

A = mat[[0,1,2],[0]]
[1]
[3]
[0]
B = mat[[1,2],[1,2]]
[10 12]
[ 5  3]
C = mat[[0],[1,2]]
[5 7]

To know that these 3 parts are not overlapping to each other, I have an idea to map the original matrix to 1-dimension array as IDs for each cell:

tt = copy(mat)
row = mat.nrows()
col = mat.ncols()
for x in range(row):
    for y in range(col):
        tt[x,y] = x*col+y
sage: tt
[0 1 2]
[3 4 5]
[6 7 8]

Then again I go over all coordinate that I took for A, B and C to collect these mapped ID. Regarding to A,

cells_A = []
for i in range(0, 3):
    for j in range(0, 1):
        cells_A.append(tt[i, j])
sage: cells_A
[0, 3, 6]

Regarding to B:

cells_B = []
for i in range(1, 3):
    for j in range(1, 3):
        cells_B.append(tt[i, j])
sage: cells_B
[4, 5, 7, 8]

Regarding to C, similarly we have:

sage: cells_C = [1,2]

If size of union from these 3 cells is equal to the total size of A, B, and C, then I conclude no overlapping among them.

area = sum([A.nrows()*A.ncols(), B.nrows()*B.ncols(), C.nrows()*C.ncols()])
if len(set.union(*[set(cells_A), set(cells_B), set(cells_C)])) == area:
    print("No overlapping parts")

However, this way requires lots of work and SLOW. Is there any already SageMath's Matrix feature supporting some steps above, especially a way to improve/avoid mapping index?

2019-02-11 17:14:29 -0600 received badge  Scholar (source)
2019-02-09 02:48:34 -0600 received badge  Supporter (source)
2019-02-08 16:51:52 -0600 commented question Sagemath heap size limit

I edited my post adding v:

v = MatrixSpace(GF(2), 2, 6)

@dan_fulea, I would like to share with you further process. Example:

g3 = [(1, 2, 3), (1, 2, 4), (1, 2, 5), (2, 3, 5), (1, 3, 5)]

1) g3 is a list of all c involved in good combinations, i.e. condition m.rank() >= 4 is satisfied (its result is still a huge list, which we can see by running @slelievre suggestion sum(1 for g in g3), which almost non-stop) 2) I process each list in g3 to learn relationship of any pairs, e.g:

relatives =
{(1, 2): [3, 4, 5],
 (1, 3): [2, 5],
 (1, 4): [2],
 (1, 5): [2, 3],
 (2, 3): [1, 5],
 (2, 4): [1],
 (2, 5): [1, 3],
 (3, 5): [2, 1]}

3) Consider (1,2,3), we know (1,2) can go with 4, or 5 besides 3. If all (1 ... (more)

2019-02-08 16:09:19 -0600 received badge  Editor (source)
2019-02-07 14:26:55 -0600 received badge  Student (source)
2019-02-07 09:02:42 -0600 asked a question Sagemath heap size limit

Hi all, I am not new to Python, but new to Sagemath.

My code:

v = MatrixSpace(GF(2), 2, 6)
size = binomial(4096,3)
g3 = []
for c in Combinations(range(4096), 3):
   m = block_matrix(3, 1, [v[c[0]], v[c[1]], v[c[2]]])
   if m.rank() >= 4:
      g3.append(c)

The variable "g3" raises up to about 20 GB in total. Sagemath catches "Memory Error" at some point; therefore, I divide "g3" into 1920 different parts to save. Now I need to process further with "g3", i.e. I need to assign "g3" parts again to some variables to use. The 1st solution that I think of is to create 1920 different variables to store the whole "g3" in my code; however, this way is a bit inconvenient.

Is there any better solution?

For example, increasing the limit of "list" size (python list type []), which might help me to save up to 11.444.858.880 lists in the list "g3" (about 11 billion is the size from binomial(4096,3)). I have a computer of 128 GB RAM, and it is very nice if I can utilize the computer's strength.

There is an old topic on this: trac.sagemath.org/ticket/6772. However, I do not really get the idea there.

I wish to be supported :-) Thank you a lot !!!