<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font face="Arial">Hello,<br>
      <br>
      The cross() function was wished by <a class="moz-txt-link-freetext" href="http://bugzilla.scilab.org/9941">http://bugzilla.scilab.org/9941</a>.<br>
      It is being designed at <a class="moz-txt-link-freetext" href="https://codereview.scilab.org/#/c/11469/">https://codereview.scilab.org/#/c/11469/</a> <br>
      through the Scilab Enhancement Proposal SEP#96<br>
<a class="moz-txt-link-freetext" href="https://codereview.scilab.org/cat/11469%2C2%2CSEP/SEP_096_cross.odt">https://codereview.scilab.org/cat/11469%2C2%2CSEP/SEP_096_cross.odt</a><br>
      <br>
      It's a good new! Despite this SEP has not been posted here, here
      are some free <br>
      comments about its present implementation<br>
    </font>
    <meta http-equiv="CONTENT-TYPE" content="text/html;
      charset=ISO-8859-1">
    <h2 class="western"><font color="#009900">Rationale<br>
      </font></h2>
    <font color="#009900">cross is an elementary function that exists in
      Matlab which is
      used to return the vector cross product <br>
      of two column vectors of size
      3-by-1. It may be useful in mathematics, mechanics, etc...</font><br>
    <br>
    Why refering to Matlab? If the simple fact that something exists in
    Matlab should turn<br>
    it useful to implement in Scilab, this opens many ways to downgrade
    Scilab. We should<br>
    publish a list, if needed. Matlab has its own drawbacks, due to its
    own history. Is it really <br>
    useful to add them to Scilab, when Scilab has sometimes better
    solutions and is fighting <br>
    its own pitfalls, bad designs, etc to reduce them?<br>
    If obviously features existing elsewhere can't be all bad, IMO to be
    available elsewhere <br>
    is not an intrinsic argument.<br>
    cross() is actually expected in mechanics and many other fields of
    physics: electromagnetism,<br>
    fluid dynamics, etc. and if it was'nt available elsewhere, it would
    be useful anyway for these<br>
    reasons. So, IMO, no need to point other lab.<br>
    <h3 class="western" align="JUSTIFY"><font color="#009900"><tt><font
            face="Nimbus Sans L, sans-serif"><font size="4">Syntax
              and semantics</font></font></tt><br>
      </font></h3>
    <font color="#009900">Only
      one calling sequence is available:<br>
      C
      = cross(A,B)<tt><font face="Nimbus Sans L, sans-serif"><font
            size="3"><span style="font-weight: normal"></span></font></font></tt><br>
      <tt><font face="Nimbus Sans L, sans-serif"><font size="3"><span
              style="font-weight: normal">A
              and B can be: real, complex, polynomial, sparse or boolean
              matrix of
              size 3-by-1.</span></font></font></tt></font><br>
    <title></title>
    <meta name="GENERATOR" content="OpenOffice.org 3.4.1 (Win32)">
    <style type="text/css">
        <!--
                @page { margin: 2cm }
                P { margin-bottom: 0.21cm }
                H3 { margin-bottom: 0.21cm }
                H3.western { font-family: "Nimbus Sans L", sans-serif }
                H3.cjk { font-family: "DejaVu Sans" }
                H3.ctl { font-family: "DejaVu Sans" }
                H2 { margin-bottom: 0.21cm }
                H2.western { font-family: "Nimbus Sans L", sans-serif; font-size: 14pt; font-style: italic }
                H2.cjk { font-family: "DejaVu Sans"; font-size: 14pt; font-style: italic }
                H2.ctl { font-family: "DejaVu Sans"; font-size: 14pt; font-style: italic }
                TT { font-family: "DejaVu Sans Mono", monospace }
        -->
        </style><br>
    The extension to polynomials beyond decimals is excellent. AFAIK, it
    is not available in <br>
    the other lab. <br>
    The processing of booleans should be more clearly indicated: * =>
    AND , + => OR <br>
    or %T => 1, %F => 0  (that is to say, as if bool2s() was
    applied before processing. Since this <br>
    is not yet illustrated with an example, writting something about
    would be useful, as well<br>
    as in the help page).<br>
    Rational fractions are not supported. It could be worthwhile to
    indicate this limit.<br>
    Sparsity is an encoding type rather than a data type. It could be
    indicated rather after data types.<br>
    <br>
    The 3x1 size of required args is uselessly demanding and should be
    extended (see below).<br>
    <br>
    <big><b><font color="#009900">Present implementation</font></b></big>
    (patch set 2)<br>
    <pre style="font-family:Monospaced;font-style:normal;font-size:14.0;"><span style="color:rgb(176,24,19);">function</span> <span style="color:rgb(131,67,16);font-weight:bold;">c</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(0,0,0);text-decoration:underline;">cross</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">a</span><span style="color:rgb(0,0,0);">, </span><span style="color:rgb(131,67,16);font-weight:bold;">b</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(100,174,100);font-style:italic;">// This function returns the cross product of a and b</span>
  // (checking input arguments). Then: )
    <span style="color:rgb(131,67,16);font-weight:bold;">a</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(74,85,219);">[</span><span style="color:rgb(131,67,16);font-weight:bold;">a</span><span style="color:rgb(0,0,0);">;</span><span style="color:rgb(131,67,16);font-weight:bold;">a</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(131,67,16);font-weight:bold;">b</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(74,85,219);">[</span><span style="color:rgb(131,67,16);font-weight:bold;">b</span><span style="color:rgb(0,0,0);">;</span><span style="color:rgb(131,67,16);font-weight:bold;">b</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(131,67,16);font-weight:bold;">c</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(131,67,16);font-weight:bold;">a</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">2</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(188,143,143);">4</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">.*</span><span style="color:rgb(131,67,16);font-weight:bold;">b</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">3</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(188,143,143);">5</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(131,67,16);font-weight:bold;">b</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">2</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(188,143
 ,143);"
>4</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">.*</span><span style="color:rgb(131,67,16);font-weight:bold;">a</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">3</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(188,143,143);">5</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(176,24,19);">endfunction</span></pre>
    <br>
    It is tricky and efficient. <br>
    1) Unless willing to stick to the weak implementation of other labs,
    Scilab's one can be<br>
       easily vectorized:<br>
       <span style="color:rgb(131,67,16);font-weight:bold;">c </span><span
      style="color:rgb(92,92,92);">= </span><span
      style="color:rgb(131,67,16);font-weight:bold;">a</span><span
      style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(188,143,143);">2</span><span
      style="color:rgb(255,170,0);">:</span><span
      style="color:rgb(188,143,143);">4,:</span><span
      style="color:rgb(74,85,219);">)</span><span
      style="color:rgb(92,92,92);">.*</span><span
      style="color:rgb(131,67,16);font-weight:bold;">b</span><span
      style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(188,143,143);">3</span><span
      style="color:rgb(255,170,0);">:</span><span
      style="color:rgb(188,143,143);">5,:</span><span
      style="color:rgb(74,85,219);">) </span><span
      style="color:rgb(92,92,92);">- </span><span
      style="color:rgb(131,67,16);font-weight:bold;">b</span><span
      style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(188,143,143);">2</span><span
      style="color:rgb(255,170,0);">:</span><span
      style="color:rgb(188,143,143);">4,:</span><span
      style="color:rgb(74,85,219);">)</span><span
      style="color:rgb(92,92,92);">.*</span><span
      style="color:rgb(131,67,16);font-weight:bold;">a</span><span
      style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(188,143,143);">3</span><span
      style="color:rgb(255,170,0);">:</span><span
      style="color:rgb(188,143,143);">5,:</span><span
      style="color:rgb(74,85,219);">)</span><span
      style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(176,24,19);"></span>
    <br>
    2) About accepted formats for input args, here is a suggestion:<br>
        -  a and b must have the same format. One of their dimensions
    must be 3. <br>
          If both dimensions have a size of 3, calculations are done
    column-wise.<br>
          Else, calculations are done along the dimension of size 3.<br>
        - the result r has the same format as a and b (by the way, this
    is the way Matlab<br>
          accepts a and b and returns r: if a and b are rows, r is a
    row).<br>
    3) (Option) If hypermatrices are provided, argument tests could be
    done after<br>
        applying squeeze() to them. Hypermatices are not rare in
    physics. This is even<br>
        rather the rule.<br>
    <br>
    Hope to read comments from other potential users<br>
    <br>
    Regards<br>
    Samuel<br>
    <br>
  </body>
</html>