<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 06/16/2014 07:08 AM, William
      Stockhausen - NOAA Federal wrote:<br>
      <br>
      If you post the code for a working example, I'll take a look at
      it.<br>
      <br>
      without that it is impossible to know what the code really does.<br>
      <br>
           Dave<br>
      <br>
      <br>
      <br>
    </div>
    <blockquote
cite="mid:CAJF8od5OsK2QVNfUMR73TjjRYUOUk31fGJVnFb=sHJ7GsGPCgg@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi developers,
        <div><br>
          <div> I'm running ADMB 11.1 on MacOSX and Windows 7. I'm
            trying to set the initial values for a
            param_init_number_vector (p, say) from a dvector (vls, say)
            in a function using the following:</div>
          <div><br>
          </div>
          <div>p.set_initial_value(vls);<br>
            <div><br>
            </div>
            <div>The actual function is:</div>
            <div><br>
            </div>
            <div>
              <div><font face="courier new, monospace">void
                  setInitVals(BoundedNumberVectorInfo* pI,
                  param_init_bounded_number_vector& p){</font></div>
              <div><span style="font-family:'courier new',monospace">   
                  int np = pI->getSize();</span><br>
              </div>
              <div><font face="courier new, monospace">    if (np){</font></div>
              <div><font face="courier new, monospace">        dvector
                  vls = pI->getInitVals();</font></div>
              <div><font face="courier new, monospace">       
                  p.set_initial_value(vls);</font></div>
              <div><span style="font-family:'courier new',monospace">   
                      cout<<"vls = "<<vls<<endl;</span><br>
              </div>
              <div><font face="courier new, monospace">       
                  cout<<"p   = "<<p<<endl;</font></div>
              <div><font face="courier new, monospace"> </font><span
                  style="font-family:'courier new',monospace">    }</span></div>
              <div><font face="courier new, monospace">}</font></div>
            </div>
            <div><br>
            </div>
            <div>where pI is a pointer to an object whose method
              getInitVals() returns a dvector.</div>
            <div><br>
            </div>
            <div>Everything compiles fine, but when I run the code,  the
              initial values for p are not equal to vls (they're equal
              to the default initial values) after running setInits. </div>
            <div><br>
            </div>
            <div>Fortunately this caused my code to produce some really
              strange results so I realized there was a problem. Using
              the ADMB website, I tracked down the following:</div>
            <div> </div>
            <div>The 'set_initial_value' method for
              param_init_bounded_number_vector is defined in model45.cpp
              as</div>
            <div><br>
            </div>
            <div>
              <pre style="white-space:pre-wrap;font-family:monospace,fixed;font-size:9pt;border:1px solid rgb(214,229,196);padding:4px 6px;margin:4px 8px 4px 2px;overflow:auto;word-wrap:break-word;line-height:15px;color:rgb(0,0,0);background-color:rgb(252,253,251)">00008 
<a moz-do-not-send="true" name="14671f50a40b0b90_l00009" style="color:rgb(103,140,61)"></a><a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classparam__init__bounded__vector__vector.html#ad696a4660a01ad50266fcbafa7d3beb7" target="_blank" style="color:rgb(70,101,162);text-decoration:none">00009</a> <span style="color:rgb(96,64,32)">void</span> <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classparam__init__bounded__vector__vector.html#ad696a4660a01ad50266fcbafa7d3beb7" target="_blank" style="color:rgb(70,101,162);text-decoration:none">param_init_bounded_vector_vector::set_initial_value</a>(
<a moz-do-not-send="true" name="14671f50a40b0b90_l00010" style="color:rgb(103,140,61)"></a>00010   <span style="color:rgb(0,128,0)">const</span> <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdouble__index__type.html" title="Description not yet available." target="_blank" style="color:rgb(70,101,162);text-decoration:none">double_index_type</a>& _it)
<a moz-do-not-send="true" name="14671f50a40b0b90_l00011" style="color:rgb(103,140,61)"></a>00011  {
<a moz-do-not-send="true" name="14671f50a40b0b90_l00012" style="color:rgb(103,140,61)"></a>00012     <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classparam__init__bounded__vector__vector.html#a106e1b4f5049a08386645afbb658384b" target="_blank" style="color:rgb(70,101,162);text-decoration:none">it</a>=<span style="color:rgb(0,128,0)">new</span> <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdouble__index__type.html" title="Description not yet available." target="_blank" style="color:rgb(70,101,162);text-decoration:none">double_index_type</a>(_it);
<a moz-do-not-send="true" name="14671f50a40b0b90_l00013" style="color:rgb(103,140,61)"></a>00013  }
<a moz-do-not-send="true" name="14671f50a40b0b90_l00014" style="color:rgb(103,140,61)"></a>00014 
</pre>
            </div>
            <div><br>
            </div>
            <div>and the conversion of a dvector to double_index_type is
              defined in doublind.cpp as</div>
            <div>
              <pre style="white-space:pre-wrap;font-family:monospace,fixed;font-size:9pt;border:1px solid rgb(214,229,196);padding:4px 6px;margin:4px 8px 4px 2px;overflow:auto;word-wrap:break-word;line-height:15px;color:rgb(0,0,0);background-color:rgb(252,253,251)">00057 
<a moz-do-not-send="true" name="14671f50a40b0b90_l00062" style="color:rgb(103,140,61)"></a><a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdouble__index__type.html#a70db7015028be71be42cbc4c37b59319" target="_blank" style="color:rgb(70,101,162);text-decoration:none">00062</a> <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdouble__index__type.html#a2265b2e72fbd497b8cd4d4688398957a" title="Description not yet available." target="_blank" style="color:rgb(70,101,162);text-decoration:none">double_index_type::double_index_type</a>(<span style="color:rgb(0,128,0)">const</span> <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdvector.html" title="Vector of double precision numbers." target="_blank" style="color:rgb(70,101,162);text-decoration:none">dvector</a>& x)
<a moz-do-not-send="true" name="14671f50a40b0b90_l00063" style="color:rgb(103,140,61)"></a>00063   {
<a moz-do-not-send="true" name="14671f50a40b0b90_l00064" style="color:rgb(103,140,61)"></a>00064     <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdouble__index__type.html#ad1bebc88ffff9232f7502f2c764ee3f2" target="_blank" style="color:rgb(70,101,162);text-decoration:none">p</a> = <span style="color:rgb(0,128,0)">new</span> <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdvector__index.html" title="Description not yet available." target="_blank" style="color:rgb(70,101,162);text-decoration:none">dvector_index</a>((<span style="color:rgb(0,128,0)">const</span> <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdvector.html" title="Vector of double precision numbers." target="_blank" style="color:rgb(70,101,162);text-decoration:none">dvector</a>&)(x));
<a moz-do-not-send="true" name="14671f50a40b0b90_l00065" style="color:rgb(103,140,61)"></a>00065   }
<a moz-do-not-send="true" name="14671f50a40b0b90_l00066" style="color:rgb(103,140,61)"></a>00066 
</pre>
            </div>
            <div><br>
            </div>
            <div>but the constructor for the dvector_index uses the copy
              constructor for dvector</div>
            <div><br>
            </div>
            <div>
              <pre style="white-space:pre-wrap;font-family:monospace,fixed;font-size:9pt;border:1px solid rgb(214,229,196);padding:4px 6px;margin:4px 8px 4px 2px;overflow:auto;word-wrap:break-word;line-height:15px;color:rgb(0,0,0);background-color:rgb(252,253,251)">00184 
<a moz-do-not-send="true" name="14671f50a40b0b90_l00189" style="color:rgb(103,140,61)"></a><a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdvector__index.html#aba2c20e6f7432a5b4441e828427ce6e7" target="_blank" style="color:rgb(70,101,162);text-decoration:none">00189</a> <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdvector__index.html#aba2c20e6f7432a5b4441e828427ce6e7" title="Description not yet available." target="_blank" style="color:rgb(70,101,162);text-decoration:none">dvector_index::dvector_index</a>(<span style="color:rgb(0,128,0)">const</span> <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdvector.html" title="Vector of double precision numbers." target="_blank" style="color:rgb(70,101,162);text-decoration:none">dvector</a>& v) : <a moz-do-not-send="true" href="http://www.admb-project.org/documentation/api/classdvector.html" title="Vector of double precision 
 numbers."
 target="_blank" style="color:rgb(70,101,162);text-decoration:none">dvector</a>(v)
<a moz-do-not-send="true" name="14671f50a40b0b90_l00190" style="color:rgb(103,140,61)"></a>00190 {
<a moz-do-not-send="true" name="14671f50a40b0b90_l00191" style="color:rgb(103,140,61)"></a>00191 }
<a moz-do-not-send="true" name="14671f50a40b0b90_l00192" style="color:rgb(103,140,61)"></a>00192 
</pre>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">which
                makes a shallow copy of v. Not sure why this doesn't
                work, but it doesn't. </div>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">My
                immediate issue is that I want to put setInitVals(...)
                in a code library--i.e., not in the tpl code and the
                usual methods for setting the initial values (i.e.,
                simple assignment by element) are private and only work
                when the function is defined inside the tpl. </div>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">I've
                also tried the set_initial_value(...) method in the tpl
                code but it doesn't work there either. Setting the
                initial values element-by-element in the tpl code does
                work, so the problem is not on my end (e.g., the dvector
                vls is all 0's).</div>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">Hope
                this is helpful.</div>
              <div style="font-family:arial,sans-serif;font-size:13px"><br>
              </div>
              <div style="font-family:arial,sans-serif;font-size:13px">
                Buck Stockhausen</div>
            </div>
          </div>
          <div>
            <div dir="ltr"><font face="courier new, monospace">***************************************************<br>
                * Dr. William T. Stockhausen                      *<br>
                ***************************************************<br>
                * Resource Ecology and Fisheries Management       *<br>
                * Alaska Fisheries Science Center                 *<br>
                * National Marine Fisheries Service               *<br>
                * National Oceanic and Atmospheric Administration *<br>
                * 7600 Sand Point Way N.E.                        *<br>
                * Seattle, Washington 98115-6349                  *<br>
                ***************************************************<br>
                * email: <a moz-do-not-send="true"
                  href="mailto:William.Stockhausen@noaa.gov"
                  target="_blank">William.Stockhausen@noaa.gov</a>     
                       *<br>
                * voice: 206-526-4241 fax: 206-526-6723           *<br>
                * web  : <a moz-do-not-send="true"
                  href="http://www.afsc.noaa.gov" target="_blank">http://www.afsc.noaa.gov</a> 
                               *<br>
                ***************************************************<br>
                All models are wrong, some are useful.--G.E.P. Box<br>
                Beware of geeks bearing equations.    --W. Buffett<br>
                ***************************************************<br>
                Disclaimer: The opinions expressed above are personal <br>
                and do not necessarily reflect official NOAA policy.<br>
              </font><br>
              <br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Developers@admb-project.org">Developers@admb-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.admb-project.org/mailman/listinfo/developers">http://lists.admb-project.org/mailman/listinfo/developers</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>