acer

32333 Reputation

29 Badges

19 years, 323 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Please add very close followup queries as Comments/Replies to this Question or one of its Answers, instead of posting a wholly separate Question thread.

Less closely related queries could be Branched off, instead of posting a wholly separate Question thread.

@Carl Love The inplace option of MatrixMatrixMultiply is not very useful. It doesn't do "in-place" semantics by using another container on the sidelines, but rather it tries to replace rows of the first Matrix (when they are no longer needed, for the usual row-of-A * column-of-B implementation). This is not relatively fast, partly because it creates temporary Vectors.

It seems to me that the implementation of .= is well done, because it seems fast and not easy to beat. One way to beat it might be to avoid its rtable construction step.

A more useful matrix-matrix multiplication approach is to allow passing of a container (Matrix) for the result. That's how the BLAS GEMM does it: alpha*A*B+beta*C -> C where C is supplied and overwritten. But your examples need more than 64bits per integer, so it can't even be kludged using float BLAS.

But inside MatrixMatrixMultiply there are calls to a kernel builtin, named mvMultiply, which takes an optional third argument as the container C, ie. A.B -> C.

So, given that one can do that kind of "in-place" action on an input Matrix, all Matrix creation can be removed from every call to the procedure -- by acting on pregenerated module locals.

GCDwithBezout2 does that, with a copying of contents from container to container at each iteration. (I don't know whether explicit entry assignment is faster than ArrayTools:-Copy for such small examples done very many times.) gcdwithbezout2.mw

GCDwithBezout3 avoids the container-container copying, by simply switching about which containers are used for the first and third arguments passed to mvMultiply. Overall, this may be about 20% faster than the original. (But the bits and bobs of even small actions can have measurable effects, and I'm not sure that I've found the very best.) gcdwithbezout3.mw

I believe that fair timing comparisons for your candidate procedures require them to be separated by restarts, in part because memory allocation affects the timing cost of the temporary Vector/list creation.

I'm sure that you've also realized that there are some minor tweaks which might affect the timing cost for many iterations/repeats. Eg, the entry of Q that contains q could be updated directly, the case of sign(r0)=1 could avoid the list multiplication, etc. This is what I mean by "bits and bobs".

note: Module locals are not thread-safe as they are accessed thread-globally by default. IIRC there is a syntax to make module locals be accessed thread-locally, but I don't recall the specifics offhand. I'm not sure if you intend on using Threads to call your procedure on very many values.

@Adam Ledger Carl is telling you to look at the help page for the command addcoords .

You can do that by opening the Help system with the mouse pointer and the GUI's menubar. You can also do it by executing the statement,
   ?addcoords

 

@Magma I have changed the Question, to be marked as Maple 15 rather than Maple 2015 as it was previously.

Those versions are quite different. Maple 15 was released in the year 2011, and is four major releases older than Maple 2015.

Marking your Question as specific to an older release is crucial if you want Responders to realize that your version may not support certain new language syntax and features.

The max[index] syntax which Carl's code utilizes was added in Maple 2015, and is not available in Maple 15.

@mwahab Carl's code uses the index command, which is not available in Maple 2016.2 (the version in which your attachments were last saved). That command was introduced in Maple 2017.

Attached is a revision which uses such a procedure, assigned to name myindex.

Download with_codes_Maple2016.mw

(I have toggled your Question as being for product Maple 2016.)

 

@malt1752 As submitter of the Question you could toggle the cup icon beside any one Answer, to mark it as your accepted preference.

Of course that is your choice.

You could also up vote as many separate Answers as you wish, by toggling the thumbs-up icon.

@Carl Love I eventually found what I was looking for with rsolve, and augmented my Answer.

Yes, eliminating a(n) is a good key. (I am not surprised that you found it before I did.)

Which parts of the help page for topic RandomTools,BlumBlumShub,NewBitGenerator do you not understand?

Please be clear about your precise problems. That would be much more helpful than separating your queries and issue into additional Question threads.

@Carl Love My guess is that the spirit of that is to convey that -- when called alone -- `eval` does not change the stored values.

Sure, doing so might toggle some flag or DAG bit, which could be utilized to affect subsequent rtable_eval behavior.

Getting both convenient and highly efficient behavior under all circumstances seems difficult for mutable data structures -- given the need for in-place semantics and the variety of evaluation circumstances. I suppose that it is a push-me-pull-me thing, where concessions in some respects accompany benefits in others.

@HuanLuong Nobody wants to have to type in all your code, so as to try and reproduce the issue so as to diagnose it.

A screenshot image is not code that can be easily copied.

It is impolite of you to expect an answer without providing the code to reproduce. You've even ignored a explicit request to do so.

@radaar You could use,

    catch "no improved point":

or,

    catch:

where the second of those would catch any error. You can thus catch specific errors (whose messages start a certain way), or most all errors.

 

@V1 ...because you couldn't be bothered to do so.

You have posted only an image of your code, and no means to reproduce or analyze it via copy & paste. That is useless.

Use the green up-arrow to attach your worksheet, or add in the code-to-reproduce as plaintext.

@nm It is a shame that you removed your Answer, for now the discussion of it seems senseless.

My point is that using an identity on a mere reformulation of itself does not demonstrate much of anything. Even now (with your new response that the identity is not "needed") it's unclear whether you actually understand this point.

@vv Thank you. I realize that it's a tough topic, but I was surprised by the slog I had trying even with cartesian coordinates.

First 203 204 205 206 207 208 209 Last Page 205 of 591