<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[valarray::resize()]]></title><description><![CDATA[<p>Hab eigentlich gedacht ich hätte die Frage vorhin auf der Arbeit noch abgeschickt, war aber wohl nicht:</p>
<p>Laut meiner C++-Referenz sollte valarray&lt;T&gt;::resize(size_t n, T&amp; c) so laufen, dass das valarray vergrößert/verkleinert wird und bei einer Vergrößerung die überzähligen neuen Elemente mit c initialisiert werden. Ich habs ausprobiert: es wurde das gesamte valarray mit diesem Wert initialisiert. Stellt sich die Frage: spinnt meine Referenz oder baut mein gcc dort Mist?</p>
<p>Die andere Frage wäre dann, wie ich mein Problem implementiere: ich weiß vorher nicht genau, wie groß mein valarray am Ende sein wird, möchte es also dynamisch wachsen lassen. Gibts da sowas wie push_back?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/124365/valarray-resize</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 02:27:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124365.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 Oct 2005 19:21:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to valarray::resize() on Wed, 26 Oct 2005 19:21:10 GMT]]></title><description><![CDATA[<p>Hab eigentlich gedacht ich hätte die Frage vorhin auf der Arbeit noch abgeschickt, war aber wohl nicht:</p>
<p>Laut meiner C++-Referenz sollte valarray&lt;T&gt;::resize(size_t n, T&amp; c) so laufen, dass das valarray vergrößert/verkleinert wird und bei einer Vergrößerung die überzähligen neuen Elemente mit c initialisiert werden. Ich habs ausprobiert: es wurde das gesamte valarray mit diesem Wert initialisiert. Stellt sich die Frage: spinnt meine Referenz oder baut mein gcc dort Mist?</p>
<p>Die andere Frage wäre dann, wie ich mein Problem implementiere: ich weiß vorher nicht genau, wie groß mein valarray am Ende sein wird, möchte es also dynamisch wachsen lassen. Gibts da sowas wie push_back?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901487</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901487</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 26 Oct 2005 19:21:10 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Wed, 26 Oct 2005 19:30:57 GMT]]></title><description><![CDATA[<p>hmmm. also auf vc++ 7 läuf das einwandfrei</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901495</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901495</guid><dc:creator><![CDATA[CMatt]]></dc:creator><pubDate>Wed, 26 Oct 2005 19:30:57 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Wed, 26 Oct 2005 19:52:15 GMT]]></title><description><![CDATA[<p>hihi, hab grad folgendes gefunden:<br />
<a href="http://gcc.gnu.org/ml/gcc-bugs/2003-06/msg01518.html" rel="nofollow">http://gcc.gnu.org/ml/gcc-bugs/2003-06/msg01518.html</a></p>
<p>darin ist beschrieben, dass die gcc-version (alles überschreiben) standard-konform ist, die eine oder andere microsoft-version (nur neue elemente werden beschrieben) jedoch nicht...</p>
<p>Bleibt allerdings die frage wie ich mein dynamisch wachsendes valarray hinkrieg...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901512</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901512</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 26 Oct 2005 19:52:15 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Wed, 26 Oct 2005 20:11:12 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">template&lt;typename T&gt;
void FixedResize(valarray&lt;T&gt; &amp;varr, size_t newSize, const &amp;T v)
{
#ifdef GCC
  size_t oldSize = varr.size();
  varr.resize(newSize);
  if(newSize&gt;oldSize)
  {
     for(size_t i=oldSize;i&lt;newSize;i++)
        varr[i] = v;
  }
#else
  varr.resize(newSize,v);
#endif
}
</code></pre>
<p>:p :p :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901526</guid><dc:creator><![CDATA[CMatt]]></dc:creator><pubDate>Wed, 26 Oct 2005 20:11:12 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Wed, 26 Oct 2005 20:16:03 GMT]]></title><description><![CDATA[<p>tja, leider zwei kleine Fehlerchen drin:<br />
1)auch das resize ohne Füllangabe (also valarray::resize(size_t) ) überschreibt den gesamten array mit T().</p>
<ol start="2">
<li>nicht der GCC muss gefixt werden, sondern VC6 und eventuell auch einige spätere Microsoft-Implementationen. Wie gesagt, das Verhalten des gcc IST scheinbar standardkonform...</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/901528</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901528</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 26 Oct 2005 20:16:03 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Wed, 26 Oct 2005 20:22:04 GMT]]></title><description><![CDATA[<p>o_O<br />
na dann eben</p>
<pre><code class="language-cpp">void NotFixedResize(valarray&lt;T&gt; &amp;varr, size_t newSize, const &amp;T v)
{
  valarray&lt;T&gt; newArray(v,newSize);
  for(size_t i=0;i&lt;varr.size();i++)
    newArray[i] = varr[i];
  varr = newArray;
}
</code></pre>
<p>dann doch lieber nicht konform und kein rumkopieren... :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901533</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901533</guid><dc:creator><![CDATA[CMatt]]></dc:creator><pubDate>Wed, 26 Oct 2005 20:22:04 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Wed, 26 Oct 2005 21:10:55 GMT]]></title><description><![CDATA[<p>Wusstest du schon das man std::valarray meiden soll?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901566</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901566</guid><dc:creator><![CDATA[bashing]]></dc:creator><pubDate>Wed, 26 Oct 2005 21:10:55 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Thu, 27 Oct 2005 06:38:15 GMT]]></title><description><![CDATA[<p>und wieso sollte man? hat mir schon einige gute Dienste erwiesen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901651</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901651</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 27 Oct 2005 06:38:15 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Thu, 27 Oct 2005 07:54:20 GMT]]></title><description><![CDATA[<p>weil für das was du vor hast ein vector besser geeignet wäre?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901699</guid><dc:creator><![CDATA[CMatt]]></dc:creator><pubDate>Thu, 27 Oct 2005 07:54:20 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Thu, 27 Oct 2005 17:30:24 GMT]]></title><description><![CDATA[<p>wüsste nicht, dass man bei Vektoren die ganzen arithmetischen Operatoren und Funktionen zur Verfügung hätte, die ich bei dem Prog brauche (z.B. valarray::sum(), operator+, operator/, pow(valarray, valarray), um nur mal eine Handvoll zu nennen...)<br />
Deswegen: Vector ist in diesem Fall alles andere als geeignet für mein Problem...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/902164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/902164</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 27 Oct 2005 17:30:24 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Fri, 28 Oct 2005 06:26:21 GMT]]></title><description><![CDATA[<p>pumuckl schrieb:</p>
<blockquote>
<p>Bleibt allerdings die frage wie ich mein dynamisch wachsendes valarray hinkrieg...</p>
</blockquote>
<p>Selber basteln: Nimm dir einen vector als Aufbewahrungsort und implementiere die ganzen Operationen mit &quot;for(it p=v.begin();p!=v.end();++p)&quot; oder std::transform() <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/902408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/902408</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 28 Oct 2005 06:26:21 GMT</pubDate></item><item><title><![CDATA[Reply to valarray::resize() on Mon, 31 Oct 2005 16:01:56 GMT]]></title><description><![CDATA[<p>hm dann wohl eher so, dass ichs in nem vektor aufbaue und dann in ein valarray konvertiere... das für jede Operation hin und herzukonvertiern dürfte zu viel zeit kosten...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904699</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 31 Oct 2005 16:01:56 GMT</pubDate></item></channel></rss>