mmcdara

6650 Reputation

18 Badges

8 years, 132 days

MaplePrimes Activity


These are replies submitted by mmcdara

@Carl Love 

 

Thank you Carl, but the result is not the one I expected.

Maybe my question was not very clear.
So you will find below the type of output I would have to obtain (from Heck's book)


I work with Maple 2015.2 and  OS X El Capitan 10.11

Did I forget anything for testing?


Here is the modified Maple 2015 worksheet including your command

Download Maple2015.mw

 

@tomleslie 

I feel stupid not having found it alone.

But MaplePrimes is for that too ...isn't it ?

Thanks

@acer 

Great thanks to your answer that contains extremely useful coding advices


@tomleslie  Good point !


To complete my question and help you to understand where it comes from, I owe you some explanations


The problem appeared yesterday at my office.
I wanted to construct a list L of, saying, N numbers, initialized with zeros, and do some operations on it 
The first idea then was to realize the command  L :=[(seq(0, n=1..N)]:

I was using Maple 2015.1 on a Windows 7 PC with 64 Gb of memory.

N was equal to 10000 and Maple returned me an error saying that it was unable to assign a long list and suggested me to use array instead.
(unfortunately I am now at home and Maple 2015.2 on OS X 10.11 accepts this "long" list, so I cannot provide you the exact error message Maple delivered me on my professional PC ... I will publish it tomorrow)

Listening Maple I used the command L := Array(1..N):


The "structure" L is split in parts of equal lengths and each of them is sent on a different processor to be processed.
So, with 4 proccessors, I wanted to send L[1..N/4] on proc 1, L[N/4+1..N/2] on proc 2 ans so on.

-------------------------------------
The procedure that runs on each processor is of the form :

F := proc(LocalL::array)
  local N, n, x:
  N := numelems(LocalL):
  for n from 1 to LocalN do
      ...
      x := LocalL[n]:
     ...
  end do:
  ...
end proc

-------------------------------------
Next :

for n from 1 to N
   L[n] := ....
end do: 

for ProcNumber from 0 to Grid:-NumProc() do

   StartFrom := ...      # depends on N, ProcNumber and NumProc()
   Goto         := ...      # depends on N, ProcNumber and NumProc()

   Grid:-Run(ProcNumber, F(L[StartFrom...Goto]):

end do:

-------------------------------------

On processor 1 (0) F proceeds as expected, but the command  x := LocalL[n] on the other processors returns

Error, Array index out of range

This is because LocalL is a "local" array with indices ranging from N/4+1 to N/2 on the 2nd processor, from N/2+1 to 3*N/4 on the third and so on : So indices 1 to N/2 are known only on the first processor.


Obviously I could have avoid this problem by declaring L as a Matrix or Vector.
Or still using array but passing StartFrom and GoTo as arguments of F.
Or maybe using some convert(...) of the piece of L befor sending it to F ?


Finally the core problem is "why I cannot initialize a long list (with seq) on my ptrofessional PC ?"


Thank you for the help




@Carl Love  I often forget the existence of the lprint command.

Could you please take a look at the reply I am about to send to tomleslie ?

(I do not know how to reply simultaneously to two people ...)

Thanks for your help 

@Markiyan Hirnyk ...  should we follow that ? Surely not !

But what makes you think that what's done is incorrect?

In fact the term "p value" and some related notations are a kind of paradigm in statistics

Regards

 

@Carl Love
Your solution is undoubtedly more concise, "automatic" (and elagant) than my proposal and goes quickly to the essential.
When I read it I was debating whether should publish "mine" ?

But I thought it could be interesting for Tazatel to understand why the problem is in fact easy to solve. Let say that I was more interested by explanation and pedagogy than by efficiency ... or elegance

I feel like you should have publish your whole approach, from the "manual" treatment to the final elegant solution, for your phrase "The implicit nature of the model can be handled by subtracting one side from the other and using 0 as the dependent variable values." might be thought of as "pulling a rabbit out of a hat" (although you declare "The model is linear in the parameters a and b")

I am not a Maple pro and I have often a lot of difficulties to understand some solutions that, sometimes, look to me as an exercise in style.
On the one hand I agree with you thet "the essence of elegance in programming is to reduce such redundancy".
But on the other hand the best is the enemy of good ... and elegance can be the enemy of readibility, maintenability and shareability (think to people that develop codes used by others).

Your last remark makes me smile : until I came here I had never use the tilde but only map and zip.
It is people like you who have showed me this "trick" I am now a fan of (but when I develop code for others, I keep prefering "map" ... )


 

@Carl Love 

First : In french the term is "p valeur", a word to word translation of "p value". But a lot of statistician use in fact "p value" even in discussions in french

Second : the summary Maple 2016 provides is an exact copy (even if it is not explicly mentioned) of the output of the "lm" function of the statistical language R. 
R being a world reference in Statistics, I guess we can accept blindly the structure of the summary Maple returns.
Note : even the notation P(>|t|) is used in R ; so I do not  think it would be suitable to replace it

 

kind regards

 

@Thomas Richard 
I forgot to say I work with Maple 2015.
Interesting to know this limitation has been lifted !

Thank you for the answer.

@Carl Love Sorry Carl for having posted "my" solution.
I had already prepared an answer but I had i little family emergency to deal with ... when I got back I posted the answer without looking if anyone else had already done the job.

In this case my answer presents no great interest.

@cskoog

 

I'm ashamed to see that everyone else but me seems to know this printlevel command 

@Carl Love 

A quick reply to a useful answer ; thanks

@acer 

from the "do help page" : 

The setting of printlevel causes the display of the results of all statements executed up to the level indicated by printlevel. By default, printlevel is initially set to 
1
. As a result, if nested loops are being used, it may be necessary to set printlevel to a higher value in order to see the results of all the statements in the loops.




Thank you for this information


postcsript : 
I was desperatly looking for the good help page. 
Couldn't it be judicious to refer this "do help page" in the "; help page" ?

@Carl Love  ... I do understand now a little bit more the roles of savelib and march.

I will dig a little bit deeper for my part.

Thanks again

@Carl Love 

thanks Carl.

I am not sure I have clearly understood all you have said : a lot of things are quite new for me.


Just a last question before I start digesting all this material : 

When I construct a module and I want to archive it, I write in a worksheet a code like the one below (it is probably a pitiful method)


# 1) definition of the module

MyModule := module ()
export F1, F2, ....F10;
option package;
F1 := proc(...)
...

end proc;
F2 := proc(...)

...

end proc;
...
end module;

 


# 2) Archiving

MyArchive := "/.../MyModule.mla";
march(`create`, MyArchive, 10);
savelib(MyModule, MyArchive);


I have no .m file here.
But you write : "A library is stored in an .mla file. A .mla file is constructed from .m files by using march."
Did I missed something ?

First 136 137 138 139 140 Page 138 of 140