<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<p>Hi,<br>
</p>
<div class="moz-cite-prefix">Le 07/05/2020 à 14:58, CRETE Denis a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:EC9DE3078260CA48826D0B33052BA9D63CC70D93@CNREXCMBX04P.core-res.rootcore.local">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style type="text/css" id="owaParaStyle"></style>
<div style="direction: ltr;font-family: Tahoma;color:
#000000;font-size: 10pt;">
<div>Hello,</div>
<div><br>
</div>
<div>I redefined a few functions in Scilab 6.1.0 to extend them
to arrays with 3 dimensions (formerly called hypermatrix).
Overloading works with "clean", "multiply", "left division"
and "element by element division" (after defining functions
%s_clean, %s_m_s, %s_l_s and %s_d_s).</div>
</div>
</blockquote>
<p>clean and element by element division do not need overloading:<br>
</p>
<p>--> clean(ones(2,2,2))<br>
ans =<br>
<br>
(:,:,1)<br>
<br>
1. 1.<br>
1. 1.<br>
(:,:,2)<br>
<br>
1. 1.<br>
1. 1.<br>
<br>
--> ones(2,2,2)./ones(2,2,2)<br>
ans =<br>
<br>
(:,:,1)<br>
<br>
1. 1.<br>
1. 1.<br>
(:,:,2)<br>
<br>
1. 1.<br>
1. 1.<br>
</p>
<p>S.<br>
</p>
<blockquote type="cite"
cite="mid:EC9DE3078260CA48826D0B33052BA9D63CC70D93@CNREXCMBX04P.core-res.rootcore.local">
<div style="direction: ltr;font-family: Tahoma;color:
#000000;font-size: 10pt;">
<div>
<div><br>
</div>
<div>I tried to overload function "inv" with the following
code:</div>
</div>
<div><br>
function y=%s_inv(x),<br>
if ndims(x)>2 then<br>
for k=1:size(x,3),<br>
y(:,:,k)=inv(x(:,:,k));<br>
end;<br>
else <br>
y=inv(x);<br>
end;<br>
endfunction</div>
<div><br>
</div>
<div>expecting that each layer of y is the reciprocal of
corresponding layer of x. Instead,
<br>
</div>
<div>inv(ones(1,1,2).*.rand(2,2)) returns the reciprocal of x
layer 1 in y layer 1 AND x LAYER n IN y LAYER n, WHEN n>1.
I use "layer" to designate the matrix obtain for a fixed value
the index along the 3rd dimension.</div>
<div><br>
</div>
<div>Code to reproduce the problem:</div>
<div><br>
</div>
<div>n=4; m=3;<br>
</div>
<div>M=ones(1,1,n).*.rand(m,m);</div>
<div>inv(M)</div>
<div><br>
</div>
<div>Attempts to circumvent this problem by using M^(-1) instead
of inv(M) run into the same problem (after redefining function
%s_p). Is this a bug or did I miss something ?</div>
<div><br>
</div>
<div>In the mean time, I avoided overloading the function "inv"
and renamed "%s_inv" to "inverse" to do successfully call
"inverse(M)"...
<br>
</div>
<div><br>
</div>
<div>Best regards</div>
<div>Denis<br>
</div>
<div><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
<a class="moz-txt-link-freetext" href="http://www.utc.fr/~mottelet">http://www.utc.fr/~mottelet</a>
</pre>
</body>
</html>