X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 27 Feb 2013 06:40 AM by  anon
how to write matrix multiply function using cycle
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
27 Feb 2013 06:40 AM
    How to write function which will multiply matrices, using cycle (loop)? I know the integrated # and ## , but I need to write my own function.. Can anyone help me, please?

    Deleted User



    New Member


    Posts:
    New Member


    --
    27 Feb 2013 09:21 AM
    If you need to write your own loop, IDL has all the standard loop types such as FOR and WHILE, etc. However, when operating on arrays in IDL, you should only use a loop if it is absolutely necessary because it will be much slower than using the array operators, #, ##, etc. directly. This is because operators such as #, and ## are multi-threaded and will take advantage of multiple cores on your CPU. By contrast, a FOR loop will not be multi threaded. However, if you have a special case that requires looping, it would look something like this: for i=0, 9 do begin ; row for j=0, 9 do begin ;column myarray[j, i] = 42 ; or whatever operation you need endfor endfor As an example, to take advantage of multi threaded operations in the example above, the whole loop can be condensed to just one line of code which would accomplish the same thing much faster: myarray[*] = 42 -Josh Exelis VIS
    You are not authorized to post a reply.