26

edits

Jump to navigation
Jump to search
##
NDpar package
(edit)

###
Revision as of 20:29, 12 December 2014

1,040 bytes added
, 20:29, 12 December 2014

→Usage: add "diagonalize NxN matrices contained in an array"

Line 41:
Line 41:

* {{codeline|"ChunksPerProc", 2}} It means that each process should make 2 chunks (2 calls to {{codeline|f}} with {{codeline|"Vectorized", true}}). Increase this number to minimize memory usage for instance. Increasing this number is also useful if function executions can have very different durations. If a process is finished, it can take over jobs from another process that is still busy.

* {{codeline|"ChunksPerProc", 2}} It means that each process should make 2 chunks (2 calls to {{codeline|f}} with {{codeline|"Vectorized", true}}). Increase this number to minimize memory usage for instance. Increasing this number is also useful if function executions can have very different durations. If a process is finished, it can take over jobs from another process that is still busy.

+=== Output in cell arrays ===

+
+The following sample code was an answer to [http://stackoverflow.com/questions/27422219/for-every-row-reshape-and-calculate-eigenvectors-in-a-vectorized-way this question]. The goal was to diagonalize 2x2 matrices contained as rows of a 2d array (each row of the array being a flattened 2x2 matrix).

+
+{{code|diagonalize NxN matrices contained in an array|

+<pre>

+A = [0.6060168 0.8340029 0.0064574 0.7133187;

+0.6325375 0.0919912 0.5692567 0.7432627;

+0.8292699 0.5136958 0.4171895 0.2530783;

+0.7966113 0.1975865 0.6687064 0.3226548;

+0.0163615 0.2123476 0.9868179 0.1478827];

+
+N = 2;

+[eigenvectors, eigenvalues] = ndpar_arrayfun(nproc,

+ @(row) eig(reshape(row, N, N)),

+ A, "IdxDimensions", 1, "UniformOutput", false)

+</pre>

+}}

+
+With {{codeline|"UniformOutput", false}}, the outputs are contained in cell arrays (one cell per slice). In the sample above, both {{codeline|eigenvectors}} and {{codeline|eigenvalues}} are {{codeline|1x5}} cell arrays.

== Issues ==

== Issues ==

Please report any issue using [https://sourceforge.net/p/ndpar/tickets/ tickets].

Please report any issue using [https://sourceforge.net/p/ndpar/tickets/ tickets].

26

edits

Retrieved from "https://wiki.octave.org/Special:MobileDiff/5232"