[prev in list] [next in list] [prev in thread] [next in thread] 

List:       scilab-users
Subject:    Re: [Scilab-users] need a little help
From:       P M <p.muehlmann () gmail ! com>
Date:       2019-02-18 19:38:10
Message-ID: CACf7ODscgdtRqMWDusK6LC+hcY_91CHwmTjVZ2ydfCLiLCCEig () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


@ Claus:

...well actually I wanted to treat every coordinate separatly....so A would
be my X coordinate of the map and B would be the x coordinate of the line.
Afterwarsd I would do the same with the Y-coordinate..

So I think my question expressed what I wanted to do in the beginning.

What I did not expect was, that the size of the arrays would matter  (did
not expect this memory issue).

Anyways....of course you are right.
Cheers,
Philipp



Am Mo., 18. Feb. 2019 um 18:32 Uhr schrieb Claus Futtrup <cfuttrup@gmail.com
> > 

> Hi Philipp
> 
> > problem solved.....I had to think differently than before.
> 
> Heh!
> 
> It helps to know what you actually want to do (and also the size of the
> problem).
> 
> Cheers,
> Claus
> 
> On 18.02.2019 18:08, P M wrote:
> 
> problem solved.....I had to think differently than before.
> 
> Actually my goal was to compare point coordinates to map coordinates and
> find the points on the map which are closest to the given point coordinates.
> 
> The map is of width:    900    // in reality the map is based on an image
> with 900x1500 pixels
> The map is of height: 1500
> 
> The points are building a line on the map...e.g: the line consists of 1076
> points
> So from the map I have build:
> 
> x = map(1,:);   // contains all x coordinates of the map
> y = map(2,:);   // contains all y coordinates of the map
> 
> points = [ lineX, lineY];      // points contain the X-Y-coordinates of
> the line
> 
> for i = 1:n
> actPoint = points(i,:);
> [nearestX xInd]   = min(abs(actPoint(1)-x));
> [nearestY yInd]  = min(abs(actPoint(2)-y));
> nearestPoint(i,:) = [x(xInd) y(yInd)];
> end
> 
> 
> This is what works for now, though it is still slow.
> 
> For searching 100 points of the line it needs about 10 seconds.
> For searching 200 points of the line it needs about 19 seconds.
> For searching 500 points of the line it needs about 45 seconds.
> For searching 1000 points of the line it needs about 98 seconds.
> 
> 
> 
> 
> 
> 
> 
> Am Mo., 18. Feb. 2019 um 16:39 Uhr schrieb P M <p.muehlmann@gmail.com>:
> 
> > Ok, thanks for your help..
> > 
> > Actually the sizes I gave where just for demonstation.
> > 
> > If I use the real array sizes, I get a message: can not allocate
> > 7469.60MB memory...which maybe is true.
> > available RAM after starting Scilab is 3701 MB
> > 
> > actual array sizes:
> > 
> > A has 1076 elements
> > B has 1'350'000 elements, with a lot of Nan's in it
> > 
> > if I use thrownan(B) I can reduce the array size of B to 867751 elements
> > but still get the Message above.
> > 
> > (without thrownan() the memory scilab wants to allocate is even bigger)
> > 
> > 
> > 
> > 
> > Am Fr., 15. Feb. 2019 um 23:25 Uhr schrieb Samuel Gougeon <
> > sgougeon@free.fr>:
> > 
> > > ... and even clearer, with respect to your own notations:
> > > 
> > > --> A = rand(1,1000);  // test's data
> > > --> B = rand(1,10000);
> > > --> [a, b] = ndgrid(A, B);
> > > --> size(a)  // same for b
> > > ans  =
> > > 1000.   10000.
> > > --> [v, i] = min(abs(a-b), *"c"*);
> > > 
> > > _______________________________________________
> > > users mailing list
> > > users@lists.scilab.org
> > > http://lists.scilab.org/mailman/listinfo/users
> > > 
> > 
> _______________________________________________
> users mailing listusers@lists.scilab.orghttp://lists.scilab.org/mailman/listinfo/users
>  
> 
> 
> 
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> \
> Virus-free. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
>  <#m_-8272210635697132897_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> _______________________________________________
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
> 


[Attachment #5 (text/html)]

<div dir="ltr"><div><div><div><div><div><div>@ Claus:<br><br>...well actually I \
wanted to treat every coordinate separatly....so A would be my X coordinate of the \
map and B would be the x coordinate of the line.<br></div>Afterwarsd I would do the \
same with the Y-coordinate..<br><br></div>So I think my question expressed what I \
wanted to do in the beginning.<br><br></div>What I did not expect was, that the size \
of the arrays would matter   (did not expect this memory \
issue).<br><br></div>Anyways....of course you are \
right.<br></div>Cheers,<br></div>Philipp<br><div><div><div>  \
<br><div><div><br></div></div></div></div></div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Mo., 18. Feb. 2019 um 18:32  \
Uhr schrieb Claus Futtrup &lt;<a \
href="mailto:cfuttrup@gmail.com">cfuttrup@gmail.com</a>&gt;:<br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">  
    
  
  <div bgcolor="#FFFFFF">
    <div class="gmail-m_-8272210635697132897moz-cite-prefix">Hi Philipp</div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
    </div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix">&gt;problem solved.....I \
had to think  differently than before.</div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
    </div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix">Heh!</div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
    </div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix">It helps to know what \
you actually want  to do (and also the size of the problem).<br>
    </div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
    </div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix">Cheers,<br>
    </div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix">Claus<br>
    </div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
    </div>
    <div class="gmail-m_-8272210635697132897moz-cite-prefix">On 18.02.2019 18:08, P M \
wrote:<br>  </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">
            <div dir="ltr">
              <div dir="ltr">
                <div dir="ltr">
                  <div dir="ltr">
                    <div>
                      <div>problem solved.....I had to think differently
                        than before.<br>
                        <br>
                      </div>
                      Actually my goal was to compare point coordinates
                      to map coordinates and find the points on the map
                      which are closest to the given point coordinates.<br>
                      <br>
                    </div>
                    <div>The map is of width:      900       // in reality
                      the map is based on an image with 900x1500 pixels<br>
                    </div>
                    <div>The map is of height: 1500<br>
                    </div>
                    <div><br>
                    </div>
                    <div>The points are building a line on the
                      map...e.g: the line consists of 1076 points<br>
                    </div>
                    <div>So from the map I have build:<br>
                      <br>
                    </div>
                    <div>x = map(1,:);     // contains all x coordinates
                      of the map<br>
                      y = map(2,:);     // contains all y coordinates of
                      the map</div>
                    <div><br>
                    </div>
                    <div>points = [ lineX, lineY];           // points
                      contain the X-Y-coordinates of the line<br>
                      <br>
                      for i = 1:n<br>
                              actPoint = points(i,:);<br>
                              [nearestX xInd]     = min(abs(actPoint(1)-x));<br>
                              [nearestY yInd]   = min(abs(actPoint(2)-y));<br>
                              nearestPoint(i,:) = [x(xInd) y(yInd)];<br>
                      end</div>
                    <div><br>
                      <br>
                    </div>
                    <div>This is what works for now, though it is still
                      slow.<br>
                    </div>
                    <div><br>
                      For searching 100 points of the line it needs
                      about 10 seconds.<br>
                      For searching 200 points of the line it needs
                      about 19 seconds.</div>
                    <div>For searching 500 points of the line it needs
                      about 45 seconds.<br>
                      For searching 1000 points of the line it needs
                      about 98 seconds.</div>
                    <div><br>
                      <br>
                      <br>
                      <br>
                    </div>
                    <br>
                    <div><br>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">Am Mo., 18. Feb. 2019 um
          16:39  Uhr schrieb P M &lt;<a href="mailto:p.muehlmann@gmail.com" \
target="_blank">p.muehlmann@gmail.com</a>&gt;:<br>  </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div dir="ltr">
            <div dir="ltr">
              <div>Ok, thanks for your help..<br>
                <br>
              </div>
              <div>Actually the sizes I gave where just for
                demonstation.<br>
                <br>
              </div>
              <div>If I use the real array sizes, I get a message: can
                not allocate   7469.60MB memory...which maybe is true.<br>
              </div>
              <div>available RAM after starting Scilab is 3701 MB<br>
                <br>
              </div>
              <div>actual array sizes:<br>
                <br>
                A has 1076 elements<br>
              </div>
              <div>B has 1&#39;350&#39;000 elements, with a lot of Nan&#39;s in \
it<br>  <br>
              </div>
              <div>if I use thrownan(B) I can reduce the array size of B
                to 867751 elements but still get the Message above.<br>
                <br>
              </div>
              <div>(without thrownan() the memory scilab wants to
                allocate is even bigger)<br>
              </div>
              <div><br>
                <br>
                <br>
              </div>
            </div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">Am Fr., 15. Feb. 2019 um
              23:25  Uhr schrieb Samuel Gougeon &lt;<a href="mailto:sgougeon@free.fr" \
target="_blank">sgougeon@free.fr</a>&gt;:<br>  </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">  <div \
                bgcolor="#FFFFFF">
                <div \
class="gmail-m_-8272210635697132897gmail-m_5577763922447151768gmail-m_3771141033949040913moz-cite-prefix">...
                
                  and even clearer, with respect to your own notations:<br>
                  <br>
                  <font size="-1"><tt>--&gt; A = </tt></font><font \
size="-1"><tt><font size="-1"><tt>rand(1,1000);</tt></font></tt></font><font \
size="-1"><tt>   // test&#39;s data</tt></font><font size="-1"><tt><font \
                size="-1"><tt> <br>
                          --&gt; B = rand(1,10000);</tt></font><br>
                      --&gt; [a, b] = ndgrid(A, B);</tt><tt><br>
                    </tt><tt>--&gt; size(a)</tt><tt>   // same for b<br>
                    </tt><tt>  ans   =</tt><tt><br>
                    </tt><tt>     1000.     10000.</tt><tt><br>
                    </tt><tt>--&gt; [v, i] = min(abs(a-b), \
</tt></font><tt><b>&quot;c&quot;</b></tt><font size="-1"><tt>);</tt></font><br>  \
</div>  <br>
              </div>
              _______________________________________________<br>
              users mailing list<br>
              <a href="mailto:users@lists.scilab.org" \
                target="_blank">users@lists.scilab.org</a><br>
              <a href="http://lists.scilab.org/mailman/listinfo/users" \
rel="noreferrer" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
  </blockquote>
          </div>
        </blockquote>
      </div>
      <br>
      <fieldset class="gmail-m_-8272210635697132897mimeAttachmentHeader"></fieldset>
      <pre class="gmail-m_-8272210635697132897moz-quote-pre">_______________________________________________
 users mailing list
<a class="gmail-m_-8272210635697132897moz-txt-link-abbreviated" \
href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a> <a \
class="gmail-m_-8272210635697132897moz-txt-link-freetext" \
href="http://lists.scilab.org/mailman/listinfo/users" \
target="_blank">http://lists.scilab.org/mailman/listinfo/users</a> </pre>
    </blockquote>
    <p><br>
    </p>
  <div id="gmail-m_-8272210635697132897DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid rgb(211,212,222)">
	<tbody><tr>
        <td style="width:55px;padding-top:13px"><a \
href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient" \
target="_blank"><img \
src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" \
alt="" style="width: 46px; height: 29px;" height="29" width="46"></a></td>  <td \
style="width:470px;padding-top:12px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. \
<a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient" \
style="color:rgb(68,83,234)" target="_blank">www.avast.com</a>  </td>
	</tr>
</tbody></table><a href="#m_-8272210635697132897_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" \
width="1" height="1"> </a></div></div>

_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" \
target="_blank">users@lists.scilab.org</a><br> <a \
href="http://lists.scilab.org/mailman/listinfo/users" rel="noreferrer" \
target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br> \
</blockquote></div>



_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic