## 410 Reputation

7 years, 328 days

## Retrieve elements of lists of a list ign...

Maple 2020

Hello

Since my solutions are neither efficient nor concise, I wonder if someone could help me with the following problem. Suppose

`L:=[[[],[],3,2,1,4],[1,4,[],5,8,[]],[5,6,7,8,[],1]]:`

(Just a short and simplified version - L is a huge list). I need the elements to be rearranged as follows

`newL:=[[1,5],[4,6],[3,7],[2,5,8],[1,8],[4,1]]:`

that is, the first sublist of newL contains the first elements of all sublists of L without [], the second sublist of newL contains the second elements of all sublists of L without [] and so on.

How can that be achieved without seq and remove?

Many thanks

Ed

PS. My solution

`newL:=[seq(remove(y->y=[],map(x->x[i],L)),i=1..nops(L[1]))]`

The size of the sublists does not change.

## A threadsafe procedure to count the numb...

Maple 2020

Hello

I need to check if the solution (sols) of a (nonlinear) polynomial system of equations (the coefficients are not numeric) has only one solution for, let's say, y and (one solution for y and one solution for z).  I cannot use allvalues (not threadsafe according to CodeTools:-ThreadSafetyCheck) and then count the number of solutions.

I have removed all solutions that fit the command

`ormap(x->x=true,map(has,rhs~(op~(sols)),_Z))`

(RootOf works too).  (Please tell me if I am using ormap correctly).

Even using the above command and then checking if nops(sols)=1, not all one solutions are caught.

Many thanks

Ed

## How to minimize the usage of memory usin...

Maple

Hello

I had to save previous results of a calculation to files as the number of elements is too big for my computer to handle in one go.   Here it is an idea of what I am doing to read the files and perform the calculations.

```mainproc:=proc(arg1,arg2,arg3,arg4) ... end proc:

Grid:-Set(mainproc):
Grid:-Set(arg2,arg3,arg4):   #  They don't change ever.

for i from 1 to number_of_files do
Grid:-Set(arg1):
ans:=Grid:-Seq(mainproc(arg1[i],arg2,arg3,arg4),i=1..numelems(arg1))):
Grid:-Wait():
save ans, ....:
unassign('arg1'):
unassign('ans'):
gc():  # An attempt
end do:

```

The actual code works but, for every step in the loop, the memory used by Maple increases by a certain amount that seems to be mostly related to arg1 (as if arg1 is piling up from iteration to iteration).

I read some of the earlier posts on a similar subject dated 5 to 10 years old.  I wonder if there is something new that can be done to minimize the usage of memory.

Many thanks

Ed

## How to avoid memory exhaustion when usin...

Maple 2020

Hello

Maple is dangerously close to using all available memory on my Linux machine by doing a calculation using  Grid:-Seq (Map, ..).   Is there a way to control the amount of memory used? Is numcpus a good option?   Or tasksize?

I expect that Maple will use a large amount of memory since the calculations are performed over a rather large list of sets.

Many thanks.

Ed

[Moderator's note: The original version of this Question mentioned using both Grid and Threads. The following 5 Replys will not make sense without knowing that Threads was mentioned.

## The fastest way to search the elements o...

Maple 2020

Hello again

I need to find the position of the elements of one list in another list.  Here it is a simple example

```L1:=[837, 526, 283, 216, 93, 512, 161, 202, 76, 851, 503, 437, 147, 36, 922];
L2:=[526, 283, 202, 437, 922, 865, 879, 804, 473, 325];
remove(has,map(x->ListTools:-Search(x,L1),L2),0)

```

the position of the elements in list L1 is [2, 3, 8, 12, 15].

For huge lists, this solution is not efficient.  Can that be done faster and less memory demanding? (Threads or Grid safe?).

Many thanks.

Ed

 4 5 6 7 8 9 10 Last Page 6 of 14
﻿