<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <font face="Courier New">Stéphane,<br>
    </font><br>
    <blockquote type="cite"
      cite="mid:2b22db77-ab5e-03a5-f3f9-9527dff39b56@utc.fr">
      <blockquote type="cite"
        cite="mid:ff35f31e-9476-5fe2-4546-82b14e767f63@free.fr">
        <p>I hope no. These are typical -- IMO fake -- functions that i
          would not expect in Scilab (and in any other language). There
          are many trivial and fast ways to create a boolean array of
          given dimensions.<br>
        </p>
      </blockquote>
    </blockquote>
    <br>
    true(m,n) may be fake if, as in other message has been clarified,
    boolean takes 4 bytes, but I think this is definitely not right, it
    is way too inefficient as regards memory usage. <br>
    <br>
    By the same token, ones(m,n) wouldn't be strictly necessary either,
    since zeros(m,n) + 1 does the job. But it is more inefficient, and I
    guess any of the ways to get a boolean matrix resorting to ones or
    zeros is more inefficient than would be a custom primitive.    <br>
    <br>
    For instance, these codes allow to measure the average time required
    by the indirect creation of a 1000x1000 boolean matrix by two
    methods:<br>
    <br>
    <pre style="font-family:Monospaced;font-style:normal;font-size:14.0;"><span style="color:rgb(160,32,240);">for</span> <span style="color:rgb(0,0,0);">k</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(188,106,143);">1</span><span style="color:rgb(255,170,0);">:20</span><span style="color:rgb(188,106,143);"></span> 
    <span style="color:rgb(50,185,185);">tic</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(0,0,0);">a</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">ones</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,106,143);">1000</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,106,143);">1000</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">&</span> <span style="color:rgb(218,112,214);">%t</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(0,0,0);">t</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">k</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">toc</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(50,185,185);">clear</span> <span style="color:rgb(188,143,143);">a</span>
<span style="color:rgb(160,32,240);">end</span>
<span style="color:rgb(0,0,0);">to</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(174,92,176);text-decoration:underline;">mean</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">t</span><span style="color:rgb(74,85,219);">)</span> 

<span style="color:rgb(160,32,240);">for</span> <span style="color:rgb(0,0,0);">k</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(188,106,143);">1</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(188,106,143);">20</span> 
    <span style="color:rgb(50,185,185);">tic</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(0,0,0);">a</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(74,85,219);">(</span><span style="color:rgb(50,185,185);">ones</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,106,143);">1000, 1000</span><span style="color:rgb(74,85,219);"></span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(0,0,0);">t</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">k</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">toc</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(50,185,185);">clear</span> <span style="color:rgb(188,143,143);">a</span>
<span style="color:rgb(160,32,240);">end</span>
<span style="color:rgb(0,0,0);">to</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(174,92,176);text-decoration:underline;">mean</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">t</span><span style="color:rgb(74,85,219);">)</span></pre>
    In my i7 laptop it is about 0.017 each, while<br>
    <br>
    <pre style="font-family:Monospaced;font-style:normal;font-size:14.0;"><span style="color:rgb(160,32,240);">for</span> <span style="color:rgb(0,0,0);">k</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(188,106,143);">1</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(188,106,143);">20</span> 
    <span style="color:rgb(50,185,185);">tic</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(0,0,0);">a</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">ones</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,106,143);">1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">n</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);"></span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(0,0,0);">t</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">k</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">toc</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(50,185,185);">clear</span> <span style="color:rgb(188,143,143);">a</span>
<span style="color:rgb(160,32,240);">end</span>
<span style="color:rgb(0,0,0);">to</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(174,92,176);text-decoration:underline;">mean</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">t</span><span style="color:rgb(74,85,219);">)</span></pre>
    takes about half the time. However, if ones is replaced by zeros + 1
    it takes the same time as both methods for boolean  <span
      style="color:rgb(160,32,240);"><br>
      <br>
      for</span> <span style="color:rgb(0,0,0);">k</span><span
      style="color:rgb(92,92,92);">=</span><span
      style="color:rgb(188,106,143);">1</span><span
      style="color:rgb(255,170,0);">:</span><span
      style="color:rgb(188,106,143);">20</span>
    <pre style="font-family:Monospaced;font-style:normal;font-size:14.0;">    <span style="color:rgb(50,185,185);">tic</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(0,0,0);">a</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">zeros</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,106,143);">1000</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,106,143);">1000</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">+</span> <span style="color:rgb(188,106,143);">1</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(0,0,0);">t</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">k</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">toc</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(50,185,185);">clear</span> <span style="color:rgb(188,143,143);">a</span>
<span style="color:rgb(160,32,240);">end</span>
<span style="color:rgb(0,0,0);">to</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(174,92,176);text-decoration:underline;">mean</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">t</span><span style="color:rgb(74,85,219);">)</span></pre>
    That's why a primitive for booleans, whatever the syntax (such as
    the proposed ones(m,n,'boolean') would be welcome.<br>
    <br>
    Regards,<br>
    <br>
    Federico Miyara<br>
    <br>
    <br>
    <br>
    <blockquote type="cite"
      cite="mid:2b22db77-ab5e-03a5-f3f9-9527dff39b56@utc.fr">
      <blockquote type="cite"
        cite="mid:ff35f31e-9476-5fe2-4546-82b14e767f63@free.fr">
        <p> </p>
        <p>To me, the only need is to document these trivial ways in the
          help pages of %F and %T.<br>
          Replacing a few lines of documentation with a lot of trivial
          duplicated codes, separate pages, separate tests always look a
          very bad idea to me.<br>
        </p>
        <p>But i can understand that, for some habit reason, former
          octavers would appreciate their usual functions.<br>
          This is why i don't clearly understand why this sub-community
          does not build <i>and maintain</i> a "Matlabic" ATOMS package
          gathering this kind of "aliases", or do not invest time to
          contribute to the m2sci converter improvement.</p>
        <p>Even when repmat() will be fastened by a factor 7 through its
          <a moz-do-not-send="true"
href="https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/codereview.scilab.org/#/c/19782">upgrade
            pending for 7 months now</a>, it won't be the optimal way,
          noticeably due to its overhead.</p>
        <p>I am neither very convinced by the ones(m,n,.,"boolean") and
          zeros(m,n,.. "boolean") proposal, for the same reason
          initially exposed by Alain. But why not.<br>
          In the same commit, Stéphane proposes to allow using the <b>"logical"</b>
          keyword as an equivalent of the "boolean" one. On this side, i
          definitively disagree with this. Indeed,</p>
        <ol>
          <li>it would be useless, adding strictly no value to scilab</li>
          <li>it would introduce a confusion for everyone, including for
            former octavers, since in Octave an array of logical type is
            made of 0 and 1, not of %F and %T. While in Scilab we can
            also have arrays of 0 and 1.<br>
          </li>
        </ol>
      </blockquote>
      OK Samuel, I can forget this one. However, "double" should be kept
      as an equivalent of "constant", even if not the name of a scilab
      type returned by typeof(). We already have the macro "double()"
      (instead of "constant()") and the keyword "double" used everywhere
      in the API.<br>
      <blockquote type="cite"
        cite="mid:ff35f31e-9476-5fe2-4546-82b14e767f63@free.fr">
        <ol>
          <li> <br>
          </li>
        </ol>
        <p>About trivial ways, a preliminary note -- and answer to
          Federico :</p>
        <p> </p>
        <blockquote type="cite"><font face="Courier New">2) How much
            memory does it take a boolean scalar? Does a boolean vector
            eploit the fact that a byte could theoretically host up to 8
            boolean components?<br>
          </font></blockquote>
        <p>4 bytes / boolean. This big memory waste is reported since a
          while: <a class="moz-txt-link-freetext"
href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/bugzilla.scilab.org/12789"
            moz-do-not-send="true">http://bugzilla.scilab.org/12789</a></p>
      </blockquote>
      I think it was stored as 4 bytes for historical reasons (in Visual
      Studio up to version 4.2 C++ int was 4 bytes)<br>
      <blockquote type="cite"
        cite="mid:ff35f31e-9476-5fe2-4546-82b14e767f63@free.fr">
        <p>This means that, using an array of decimal numbers to create
          a boolean array uses an intermediate memory "only" ~twice
          bigger than the final result.<br>
          <br>
          About some trivial efficient ways:</p>
        <ul>
          <li>Array of %F : <br>
          </li>
          <ul>
            <li>zeros(m,n,..)==1 <br>
              as Christophe does, the way i use when, for 99,5% of
              cases, a factor 2 in intermediate memory is not critical<br>
            </li>
            <li>a(m,n,..) = %f;<br>
              or safer:<br>
              clear a, a(m,n,..) = %f;</li>
          </ul>
          <li>Array of %T :</li>
          <ul>
            <li>zeros(m,n,..)==0</li>
            <li>a(m,n,..) = %f; ~a</li>
          </ul>
          <li>Random boolean array :</li>
          <ul>
            <li>rand(m,n,..) < 0.5</li>
          </ul>
        </ul>
        <p>Personnaly, i don't need any option for getting all this. But
          documenting it would be useful.<br>
          In the same way, we can use<br>
        </p>
        <ul>
          <li>clear c, c =(5,4,7) = %i*0 // to initiate an array of 0+0i
            complex-encoded array</li>
          <li>clear p, p(5,4,7) = %z*0  // to initiate an array of 0z
            polynomials</li>
          <li>etc</li>
        </ul>
        <p>.. still without any specific functions or option.<br>
        </p>
        <p>Best regards<br>
          Samuel</p>
        <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" moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">http://www.utc.fr/~mottelet</a>
</pre>
      <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" moz-do-not-send="true">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users" moz-do-not-send="true">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  <div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /> <table style="border-top: 1px solid #D3D4DE;">
        <tr>
      <td style="width: 55px; padding-top: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
                <td style="width: 470px; padding-top: 17px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Libre de virus. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>           </td>
        </tr>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>