book to learn vectorize

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

book to learn vectorize

shivax
hi all,
you have to recommend exercise books to learn vectorization?
i know programming code but i've so difficult recode it through
vectorization



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: book to learn vectorize

Ian McCallion
On Thu, 25 Jul 2019 at 20:59, shivax <[hidden email]> wrote:
>
> hi all,
> you have to recommend exercise books to learn vectorization?
> i know programming code but i've so difficult recode it through
> vectorization

Good question! I've never come across such a book, which does not mean
one does not exist, but I have also not personally found one to be
necessary. In lieu of a book here is some advice...

The first step is to familiarise yourself thoroughly with the target
language's facilities designed for this. EG for octave:
  boolean indices
  repmat
  reshape
  find
  cumsum.*
  '
  (:)
  (etc)

By familiarise, I don't just mean be able to recite what the manual
says, I mean be able to predict the result of combinations of them.
For example can you predict the difference between:
reshape((1:10),2,5) and reshape((1:10)',5,2)'? Can you say which of
the quotes in the second expression is not necessary?

You can gain familiarity with vectorising language features in your
projects by trying to use them even though there may be a more
"obvious" solution. Or by playing! It really is not hard, and you will
never achieve your goal of being able to vectorise by asking others
for the solution each time!

HTH
Ian


Reply | Threaded
Open this post in threaded view
|

Re: book to learn vectorize

nrjank

I've found the main reason people look to vectorize their code is for speed. That provides a hint of what keywords to look for when searching for a guidebook. With the understanding that not everything written for Matlab applies to Octave, and vice versa, some of the following have been useful:

Writing Fast MATLAB Code - Pascal Getreuer 2009

Matlab vectorisation tricks

And one of my favorites

Peter Acklam's MATLAB array manipulation tips and tricks


Reply | Threaded
Open this post in threaded view
|

Re: book to learn vectorize

turbofib