Vic

50 Reputation

5 Badges

8 years, 107 days

MaplePrimes Activity


These are replies submitted by Vic

@Carl Love Waaw! But then won't this take too much memory? The lists that satisfies this condition need to be processed further. I am reclaiming more memory by unassigning variables? how else can I reclaim more memory?

Thanks.
VIC.

Hi Carl,

My program has been running forever and I want to consider parallel computing. I have been doing a lot of reading and I am still not sure how to go about this. How can I do this for the above code so that different lists are processed at different cores of my computer?
Any help is appreciated.

Vic.

@Carl Love Thanks a lot Carl, this works perfectly.

@Carl Love Thanks a lot Carl, this now works perfectly fine. I however have a couple of questions. 
1. What does ^%T do? I know %T is transpose, but I don't know how it helps us in the line it has been used here.

2. How  do I print(whatever) for those systems with a solution? I thought I would do something like this but it doesn't work.

macro(LA= LinearAlgebra, LAM= LinearAlgebra:-Modular):
systems:=as above
vars := [indets(systems, name)[]]:
Ab:= LA:-GenerateMatrix(systems, vars, augmented):
try
     SolLAM= [LAM:-LinearSolve(2, LAM:-Mod(2, Ab, integer[]), 1, inplace= false)]^%T
catch "matrix is singular":if false then print(whatever):end if:
end try;


Thanks a lot for your help.

I don't know why copy pasting is producing the extra brackets, but my first equation should be in the form 0=f_[1,5]-f_[1,3], where the _ is an underscore. This shouldn't be affecting your results in msolve though.

@Carl Love  Hi Carl,

Here is what I did in msolve with(LinearAlgebra);
systems := {0 = f[[1, 5]]-f[[1, 3]], 0 = f[[1, 6]]-f[[1, 4]], 0 = f[[2, 4]]-f[[1, 4]], 0 = f[[2, 5]]-f[[1, 3]], 0 = f[[2, 6]]-f[[1, 3]], 0 = f[[2, 6]]-f[[1, 5]], 0 = f[[2, 6]]-f[[2, 5]], 0 = f[[2, 7]]-f[[1, 4]], 0 = f[[2, 7]]-f[[1, 6]], 0 = f[[2, 7]]-f[[2, 4]], 0 = f[[3, 1]]-f[[1, 5]], 0 = f[[3, 1]]-f[[2, 5]], 0 = f[[3, 1]]-f[[2, 6]], 0 = f[[3, 1]]-f[[3, 7]], 0 = f[[3, 5]]-f[[1, 4]], 0 = f[[3, 5]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-f[[2, 7]], 1 = f[[5, 1]]-f[[4, 6]], 1 = f[[5, 1]]-f[[4, 7]], 1 = f[[5, 2]]-f[[2, 7]], 1 = f[[5, 2]]-f[[3, 5]], 1 = f[[5, 2]]-f[[4, 6]], 1 = f[[5, 2]]-f[[4, 7]], 1 = f[[5, 3]]-f[[3, 6]], 1 = f[[5, 3]]-f[[5, 7]], 1 = f[[5, 7]]-f[[1, 6]], 1 = f[[5, 7]]-f[[2, 7]], 1 = f[[5, 7]]-f[[3, 5]], 1 = f[[5, 7]]-f[[4, 6]], 1 = f[[6, 1]]-f[[2, 6]], 1 = f[[6, 1]]-f[[3, 7]], 1 = f[[6, 1]]-f[[5, 7]], 1 = f[[6, 2]]-f[[2, 7]], 1 = f[[6, 2]]-f[[4, 7]], 1 = f[[6, 3]]-f[[4, 6]], 1 = f[[6, 3]]-f[[4, 7]], 1 = f[[6, 4]]-f[[5, 7]], 1 = f[[7, 2]]-f[[3, 7]], 1 = f[[7, 2]]-f[[5, 7]], 1 = f[[7, 3]]-f[[4, 7]]};
msolve(systems, 2);
{f[[1, 3]] = _Z1, f[[1, 4]] = 1 + _Z1, f[[1, 5]] = _Z1,

  f[[1, 6]] = 1 + _Z1, f[[2, 4]] = 1 + _Z1, f[[2, 5]] = _Z1,

  f[[2, 6]] = _Z1, f[[2, 7]] = 1 + _Z1, f[[3, 1]] = _Z1,

  f[[3, 5]] = 1 + _Z1, f[[3, 6]] = _Z1, f[[3, 7]] = _Z1,

  f[[4, 1]] = 1 + _Z1, f[[4, 2]] = 1 + _Z1, f[[4, 6]] = 1 + _Z1,

  f[[4, 7]] = 1 + _Z1, f[[5, 1]] = _Z1, f[[5, 2]] = _Z1,

  f[[5, 3]] = 1 + _Z1, f[[5, 7]] = _Z1, f[[6, 1]] = 1 + _Z1,

  f[[6, 2]] = _Z1, f[[6, 3]] = _Z1, f[[6, 4]] = 1 + _Z1,

  f[[7, 2]] = 1 + _Z1, f[[7, 3]] = _Z1}

So the solution exists interms of the variable -Z1. How come Linsolve is giving me no solution even for the ones where I know that the solutions exists?

@Carl Love 

Thanks Carl. I however used it as follows with an example that I know solution exists. It says matrix is singular. What could I be doing wrong? I am using maple 2015.

macro(LA = LinearAlgebra, LAM = LinearAlgebra:-Modular);
systems := {0 = f[[1, 5]]-f[[1, 3]], 0 = f[[1, 5]]-f[[1, 4]], 0 = f[[1, 6]]-f[[1, 3]], 0 = f[[1, 6]]-f[[1, 4]], 0 = f[[1, 6]]-f[[1, 5]], 0 = f[[2, 4]]-f[[1, 3]], 0 = f[[2, 4]]-f[[1, 4]], 0 = f[[2, 5]]-f[[1, 3]], 0 = f[[2, 5]]-f[[1, 4]], 0 = f[[2, 5]]-f[[2, 4]], 0 = f[[2, 6]]-f[[1, 3]], 0 = f[[2, 6]]-f[[1, 4]], 0 = f[[2, 6]]-f[[1, 5]], 0 = f[[2, 6]]-f[[1, 6]], 0 = f[[2, 6]]-f[[2, 4]], 0 = f[[2, 6]]-f[[2, 5]], 0 = f[[2, 7]]-f[[1, 3]], 0 = f[[2, 7]]-f[[1, 4]], 0 = f[[2, 7]]-f[[1, 5]], 0 = f[[2, 7]]-f[[1, 6]], 0 = f[[2, 7]]-f[[2, 4]], 0 = f[[2, 7]]-f[[2, 5]], 0 = f[[2, 7]]-f[[2, 6]], 0 = f[[3, 1]]-f[[1, 5]], 0 = f[[3, 1]]-f[[2, 5]], 0 = f[[3, 1]]-f[[2, 6]], 0 = f[[3, 1]]-f[[3, 7]], 0 = f[[3, 5]]-f[[1, 3]], 0 = f[[3, 5]]-f[[1, 4]], 0 = f[[3, 5]]-f[[2, 4]], 0 = f[[3, 5]]-f[[2, 5]], 0 = f[[3, 6]]-f[[1, 4]], 0 = f[[3, 6]]-f[[1, 5]], 0 = f[[3, 6]]-f[[2, 4]], 0 = f[[3, 6]]-f[[2, 5]], 0 = f[[3, 6]]-f[[3, 5]], 0 = f[[3, 7]]-f[[1, 3]], 0 = f[[3, 7]]-f[[1, 4]], 0 = f[[3, 7]]-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[[4, 7]]};
vars := [indets(systems, name)[]];
Ab := LA:-GenerateMatrix(systems, vars, augmented);
try X := LAM:-LinearSolve(2, LAM:-Mod(2, Ab, integer[]), 1) catch "matrix is singular":  end try;

@Carl Love 

Thanks Carl

@Carl Love 
Thanks Carl. Due to the nature of the lists, I might not able to post them on this site. I am generating the lists using the cartesian product iterator, then examining the lists still within the loop. I am however not familiar with garbage collction, any useful information is highly appreciated.

Thanks,

VIC.

@Carl Love  Yeah, that's right. I know for sure that members of A are lists  of two integers that are both less than or equal to n.  They are also distinct. I am considering a<b because I am interested in elements betweeen a nd b, and the number of those elements is given by b-a-1.

Vic.

@Carl Love

Waaw, that was so detailed. Thanks Carl. I like the first code because I understand it best and I can modify it to suite my case. I am however seeking the best way of writing this to take the least time possible. I will therefore need your help to understand some parts of your codes.

In the second code, what does the following line '' if p::[posint$2] and max(p).....''do? specifically [posint$2] ?  The condition if a-b need to be checked, otherwise what follows can not work unless a<b.

So if I understand your reply well, I need to use a procedure and return.  I think once I understand what [posint$2]  do then I will be good to go..

Thanks al ot.

 

@Mac Dude Thanks Mac, I however  found Import Matrix difficult to use and it did not give me the result I wanted (It could be that I didn't know the right way to use it). I however found the approach below from Carl very helpful and easier to use.

@Carl Love 

Hi Carl, thanks a lot, it worked perfectly well.

 

Always appreciated,

Vic.

@Carl Love Thanks Carl, I am beginning to enjoy working with maple.

1 2 Page 1 of 2