Hello all:<br><br>This is the best!<br><br>Many thanks Michaël Baudin!<br><br>Regards,<br><br>Berns B.<br><br><br><div class="gmail_quote">On Thu, Jun 9, 2011 at 4:09 PM, Michaël Baudin <span dir="ltr"><<a href="mailto:michael.baudin@scilab.org">michael.baudin@scilab.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<br>
Do you have a simple script to reproduce your performance issue ?<br>
<br>
You might be interested by "Programming in Scilab", especially the section "3.3 Hypermatrices" and the section "3.12 Comparison of data types" :<br>
<br>
<a href="http://forge.scilab.org/index.php/p/docprogscilab/downloads/" target="_blank">http://forge.scilab.org/index.php/p/docprogscilab/downloads/</a><br>
<br>
In the Figure 19, I analyzed the current implementation of hypermatrices in Scilab v5. Here is one explanation for the potential lack of performances, associated with the current implementation. Hypermatrices are partially implemented with mlists, supported by both compiled source code and Scilab macros. In v5, the hypermatrix is internally stored as a n-by-1 matrix of doubles, where n is the product of the dimensions. The values are stored column-by-column.<br>

<br>
So, if you extract one sub-column of this matrix, such as with A(i:j,p,q), this should be fast because data is stored locally, i.e. the next values in the extracted matrix is the neighbor of the previous values . If, on the other hand, you extract the 2nd or the 3d dimension (or more), for example, then I guess that this will be slower, because the hypermatrix has to gather values which are scattered in the internal n-by-1 matrix: there are many values in the internal matrix between two values in the extracted matrix.<br>

<br>
For those interested, here is the detail in Scilab v5. For a hypermatrix of doubles (or ints), the extraction operator is implemented in the compiled C source code: data_structures/src/c/hmops.c: intehm. This code is used in the statements :<br>

<br>
M = ones(3,3,3);<br>
B = M(1,2:3,2);<br>
<br>
For other types of values (e.g. strings), the extraction is implemented in overloading/macros/%hm_e.sci. This code is used in the statements:<br>
<br>
M = hypermat([2,2,2],["a","a","a","a","a","a","a","a"]);<br>
B = M(1,1:2,2);<br>
<br>
This also may lead to performance differences, in the sense that an hypermatrix of doubles is probably much faster than an hypermatrix of strings.<br>
<br>
In Scilab v6, the implementation is based on compiled source code for all types of contents. Anyway, data locality will limit the performances in v6 the same way as it limits the performances in v5: when we extract values, scattered values have to be gathered the same way as before.<br>

<br>
A regular matrix of doubles (i.e. with 2 indices) will in general be much faster than an hypermatrix of doubles. All in all, Scilab was first designed for that...<br>
<br>
Best regards,<br>
<br>
Michaël Baudin<div class="im"><br>
<br>
<br>
<br>
Le 01/06/2011 16:17, Mike Page a écrit :<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<div><div></div><div class="h5"><br>
<br>
I think you have encountered a general problem with hypermatrices.  They are<br>
quite fast to operate on when you work across some dimensions, but across<br>
other dimensions they can be *VERY* slow.  I don't know why this is - maybe<br>
somebody who wrote the hypermatrix code could look at it.<br>
<br>
For instance, some time ago I had a need to extract a "slice" (that is a<br>
matrix) from a hypermatrix.  This took a very long time, but when I<br>
"transposed" the hypermatrix using the permute function, then it was much<br>
faster.  I think if you arrange your dimensions so that the data to be<br>
joined fits on the end of the existing storage then it will be faster.<br>
<br>
Regards,<br>
Mike.<br>
<br>
<br>
-----Original Message-----<br>
From: Orbeman [mailto:<a href="mailto:ludo.wag@laposte.net" target="_blank">ludo.wag@laposte.net</a>]<br>
Sent: 01 June 2011 14:29<br>
To: <a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
Subject: [scilab-Users] RE: Concatenation with hypermatrix<br>
<br>
<br>
I've finally found the command C=cat(3,C,x). It works but very slowly. For<br>
exemple it needs more than 2 min to create a 890 * 2 * 5 3D hypermatrix, but<br>
barely 1 sec to create the same data with 890 * (2+2+2+2+2) 2D matrix.<br>
<br>
In fact, I've analysed n experiences which data (2 rows and variable line)<br>
are written in one file per experience. All of the files are not the same<br>
length, so I add number 'tag' to egal the maximun number of line, here 890.<br>
<br>
After that I've created some others (hyper) matrix with different size of<br>
row : 890 * 1 * 5, 890 * 3 * 5,...<br>
<br>
I can imagine the increase of time for comptute.<br>
<br>
--<br>
View this message in context:<br>
<a href="http://mailinglists.scilab.org/Concatenation-with-hypermatrix-tp3010503p3010" target="_blank">http://mailinglists.scilab.org/Concatenation-with-hypermatrix-tp3010503p3010</a><br>
714.html<br>
Sent from the Scilab users - Mailing Lists Archives mailing list archive at<br>
Nabble.com.<br>
<br>
No virus found in this incoming message.<br>
Checked by AVG - <a href="http://www.avg.com" target="_blank">www.avg.com</a><br>
Version: 9.0.901 / Virus Database: 271.1.1/3670 - Release Date: 05/31/11<br>
19:34:00<br>
<br>
</div></div></blockquote>
<br>
<br>
-- <br><font color="#888888">
Michaël Baudin<br>
Ingénieur de développement<br>
<a href="mailto:michael.baudin@scilab.org" target="_blank">michael.baudin@scilab.org</a><br>
-------------------------<br>
Consortium Scilab - Digiteo<br>
Domaine de Voluceau - Rocquencourt<br>
B.P. 105 - 78153 Le Chesnay Cedex<br>
Tel. : 01 39 63 56 87 - Fax : 01 39 63 55 94<br>
<br>
<br>
</font></blockquote></div><br>