<?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[Matrix]]></title><description><![CDATA[<p>welche Implementierungstechnik ist effizienter bzw. benötigt geringere Speicherzugriffszeit, schneller usw. :</p>
<pre><code class="language-cpp">double a = new double[width][high];

double getValue(int i, int j){
   return a[i][j];
}

//oder 

double a = new double[width*high];

double getValue(int i, int j){
   return a[i*width+j];
}
</code></pre>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/303293/matrix</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 14:46:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/303293.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 May 2012 10:40:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Matrix on Thu, 10 May 2012 10:40:46 GMT]]></title><description><![CDATA[<p>welche Implementierungstechnik ist effizienter bzw. benötigt geringere Speicherzugriffszeit, schneller usw. :</p>
<pre><code class="language-cpp">double a = new double[width][high];

double getValue(int i, int j){
   return a[i][j];
}

//oder 

double a = new double[width*high];

double getValue(int i, int j){
   return a[i*width+j];
}
</code></pre>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2210120</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2210120</guid><dc:creator><![CDATA[Gast007]]></dc:creator><pubDate>Thu, 10 May 2012 10:40:46 GMT</pubDate></item><item><title><![CDATA[Reply to Matrix on Thu, 10 May 2012 11:01:55 GMT]]></title><description><![CDATA[<p>Exakt identisch.<br />
Zu empfehlen wäre die zweite Technik, aber mit einem std::vector anstatt new[].</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2210126</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2210126</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Thu, 10 May 2012 11:01:55 GMT</pubDate></item><item><title><![CDATA[Reply to Matrix on Thu, 10 May 2012 11:11:34 GMT]]></title><description><![CDATA[<p>Beides wird nicht kompilieren, weil double den Zeiger nicht aufnehmen kann. Prinzipiell ist die erste Technik hübscher, allerdings ist sie nur anwendbar, wenn die innere Dimension eine Compilezeitkonstante ist. Die Syntax ist dann:</p>
<pre><code class="language-cpp">double (*a)[height] = new double[width][height]; // height muss constexpr sein.
</code></pre>
<p>Außerdem sollte man das natürlich nie nackt verwenden, sondern gleich in einen RAII-Anker stopfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2210130</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2210130</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Thu, 10 May 2012 11:11:34 GMT</pubDate></item></channel></rss>