<?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[Anfängerfrage - Erweiterung von math]]></title><description><![CDATA[<p>Hallo,<br />
ich habe bisher meine Probleme mit VBA lösen können. Nun steh ich aber vor dem Problem, dass VBA für mein aktuelles Projekt einfach zu langsam ist. Deswegen beschäftige ich mich sei ein paar Tagen mit c++.</p>
<p>Für meine Berechnungen benötige ich diverse mathematische Funktionen wie nat. Logarithmus, Mittelwert, Standardabweichung etc. Ersterer ist in math enthalten. Für die beiden anderen habe ich schon viele Beiträge hier im Forum und im Internet gefunden.</p>
<p>Warum wird die math denn nicht um solche mathematischen Standardformeln erweitert?</p>
<p>/Andi</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/276567/anfängerfrage-erweiterung-von-math</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 09:36:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/276567.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Nov 2010 16:37:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anfängerfrage - Erweiterung von math on Thu, 04 Nov 2010 16:37:39 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe bisher meine Probleme mit VBA lösen können. Nun steh ich aber vor dem Problem, dass VBA für mein aktuelles Projekt einfach zu langsam ist. Deswegen beschäftige ich mich sei ein paar Tagen mit c++.</p>
<p>Für meine Berechnungen benötige ich diverse mathematische Funktionen wie nat. Logarithmus, Mittelwert, Standardabweichung etc. Ersterer ist in math enthalten. Für die beiden anderen habe ich schon viele Beiträge hier im Forum und im Internet gefunden.</p>
<p>Warum wird die math denn nicht um solche mathematischen Standardformeln erweitert?</p>
<p>/Andi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975183</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975183</guid><dc:creator><![CDATA[sowosammma]]></dc:creator><pubDate>Thu, 04 Nov 2010 16:37:39 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage - Erweiterung von math on Thu, 04 Nov 2010 17:05:07 GMT]]></title><description><![CDATA[<p>Eventuell weil es nicht notwendig ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975203</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975203</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Thu, 04 Nov 2010 17:05:07 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage - Erweiterung von math on Thu, 04 Nov 2010 17:19:10 GMT]]></title><description><![CDATA[<p>Dafür gibt es genügend andere Libraries.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975217</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 04 Nov 2010 17:19:10 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage - Erweiterung von math on Thu, 04 Nov 2010 17:21:59 GMT]]></title><description><![CDATA[<p>Dafür gibts die STL (<strong>Standard</strong> Template <strong>Library</strong>, gehört zum C++ Standard):</p>
<pre><code class="language-cpp">std::vector&lt;int&gt; values;
int mean = std::accumulate(values.begin(), values.end(), 0);
int deviation = std::sqrt(inner_product(values.begin(), values.end(), values.begin(), 0.0)/(values.size()-1));
</code></pre>
<p>Da wird keine andere Bibliothek benötigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975219</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975219</guid><dc:creator><![CDATA[stl]]></dc:creator><pubDate>Thu, 04 Nov 2010 17:21:59 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage - Erweiterung von math on Thu, 04 Nov 2010 20:29:03 GMT]]></title><description><![CDATA[<p>vielen Dank stl! Klar wenn's die schon gibt dann ist neu oder anfügen an eine ander Bibliothek natürlich sinnlos <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>
<p>/Andi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975388</guid><dc:creator><![CDATA[sowosamma]]></dc:creator><pubDate>Thu, 04 Nov 2010 20:29:03 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage - Erweiterung von math on Fri, 05 Nov 2010 07:46:25 GMT]]></title><description><![CDATA[<p>also der Umstieg von VBA auf c++ ist schwieriger als erwartet. Darf ich nochmal eine (Anfänger)frage stellen?</p>
<p>Ich habe gestern versucht den Mittelwert mit accumulate zu rechnen und da ich Fließkommazahlen habe sah mein Code so aus:</p>
<pre><code class="language-cpp">int size = sizeof(iA[0])/sizeof(iA[0][0]);
double mean = accumulate(iA[0], iA[]+size, 0)/size;
</code></pre>
<p>iA ist einzweidimensionales Array. Aber das Ergebnis war immer eine Ganzahl. Irgendwann habe ich im Internet folgenden Code gefunden:</p>
<pre><code class="language-cpp">double mean = accumulate(iA[0], iA[]+size, (double)0)/size;
</code></pre>
<p>Und so funktioniert es auch. Aber woher soll ein Anänger wissen dass irgendwo im Code ein double hinein muss?</p>
<p>/Andi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975506</guid><dc:creator><![CDATA[sowosamma]]></dc:creator><pubDate>Fri, 05 Nov 2010 07:46:25 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage - Erweiterung von math on Fri, 05 Nov 2010 08:35:15 GMT]]></title><description><![CDATA[<p>versuch doch mal statt <strong>(A)</strong> <code>double(0)</code> oder <strong>(B)</strong> <code>(double)0</code> lieber <strong>(C)</strong> <code>0.</code> &lt;&lt;-- dann sieht der das du Kommazahlen nutzt und brauchst weder eine initialisierte doublezahl (A) noch ein bösen c-style-cast (B) dafür.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975517</guid><dc:creator><![CDATA[padreigh]]></dc:creator><pubDate>Fri, 05 Nov 2010 08:35:15 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage - Erweiterung von math on Fri, 05 Nov 2010 18:18:51 GMT]]></title><description><![CDATA[<p>Dies Codes die du geschrieben hast, sollten gar nicht kompilliert werden, aber da sie es scheinbar dennoch tun, nehme ich an, du hast nur falsch abgeschrieben.</p>
<p>Der Gebrauch des <code>double</code> s rührt von einer Integer Division her, das Problem hast du auch in Java. <code>accumulate</code> kannst du ruhig auch ohne double ausführen (es gibt dir die korrekte Summe als <code>int</code> zurück), nur wenn du durch size (ebenfalls <code>int</code> ) dividierst, kommt eben eine Ganzzahl heraus.<br />
Entweder kannst du <code>size</code> als <code>double</code> deklarieren oder eben für die Summe die einzelnen Werte als <code>double</code> ansehen. Das geht, indem du die <code></code>0<code>' \[int\] als \</code>0' [double] angibst und dem Compiler das mithilfe eines Punktes mitteilst. Ich mag ` <code>0.</code> ', wie von padreigh vorgeschlagen, nicht so arg, weil man den Punkt so leicht übersieht. <code></code>0.0<code>', genau das, was ich schon vorher geschrieben habe ist ebenfalls eine äquivalente Darstellung von</code> <code>(double)0</code> ' oder <code></code>static_cast&lt;double&gt;(0)` '.</p>
<p>Für einen Anfänger, wie du es bist, empfehle ich trotz allem, dir diese Funktionalität auszulagern:</p>
<pre><code class="language-cpp">template&lt;typename TRes, typename T&gt;
TRes calc_mean(const T *values, int size)
{
  return std::accumulate(values, values+size-1, TRes(0))/(size-1);
}

template&lt;typename TRes, typename T&gt;
TRes calc_deviation(const T *values, int size)
{
  return std::sqrt(inner_product(values, values+size-1, values, TRes(0))/(size-1);
}

// Gebrauch:
double mean = calc_mean&lt;double&gt;(iA, size);
</code></pre>
<p>So wird das für dich eventuell etwas vereinfacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975671</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975671</guid><dc:creator><![CDATA[stl]]></dc:creator><pubDate>Fri, 05 Nov 2010 18:18:51 GMT</pubDate></item></channel></rss>