1
edit
Changes
TudyBert
,→Drive_God
The four for loops look like they could be parallelized since they just serve as counters. From the flat file, it seems that the majority of the time is spent in the overloaded operator=() method. The code for this is:
<div>
<pre style='color:#000000;background:#ffffff;'><html><body style='color:#000000; background:#ffffff; '><pre>
<span style='color:#800000; font-weight:bold; '>void</span> Image<span style='color:#800080; '>::</span><span style='color:#800000; font-weight:bold; '>operator</span><span style='color:#808030; '>=</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>const</span> Image<span style='color:#808030; '>&</span> oldImage<span style='color:#808030; '>)</span>
<span style='color:#696969; '>/*copies oldImage into whatever you = it to*/</span>
<span style='color:#800080; '>{</span>
N <span style='color:#808030; '>=</span> oldImage<span style='color:#808030; '>.</span>N<span style='color:#800080; '>;</span>
M <span style='color:#808030; '>=</span> oldImage<span style='color:#808030; '>.</span>M<span style='color:#800080; '>;</span>
Q <span style='color:#808030; '>=</span> oldImage<span style='color:#808030; '>.</span>Q<span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>if</span><span style='color:#808030; '>(</span>dim1 <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#7d0045; '>NULL</span><span style='color:#808030; '>)</span>
<span style='color:#800080; '>{</span>
<span style='color:#800000; font-weight:bold; '>delete</span><span style='color:#808030; '>[</span><span style='color:#808030; '>]</span> dim1<span style='color:#800080; '>;</span>
<span style='color:#800080; '>}</span>
pixelVal <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> <span style='color:#800000; font-weight:bold; '>int</span><span style='color:#808030; '>*</span> <span style='color:#808030; '>[</span>N<span style='color:#808030; '>]</span><span style='color:#800080; '>;</span>
dim1 <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> <span style='color:#800000; font-weight:bold; '>int</span><span style='color:#808030; '>[</span>N<span style='color:#808030; '>*</span>M<span style='color:#808030; '>]</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> i <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> i <span style='color:#808030; '><</span> N<span style='color:#800080; '>;</span> i<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span>
<span style='color:#800080; '>{</span>
pixelVal<span style='color:#808030; '>[</span>i<span style='color:#808030; '>]</span> <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> <span style='color:#800000; font-weight:bold; '>int</span> <span style='color:#808030; '>[</span>M<span style='color:#808030; '>]</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> j <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> j <span style='color:#808030; '><</span> M<span style='color:#800080; '>;</span> j<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span>
<span style='color:#800080; '>{</span>
pixelVal<span style='color:#808030; '>[</span>i<span style='color:#808030; '>]</span><span style='color:#808030; '>[</span>j<span style='color:#808030; '>]</span> <span style='color:#808030; '>=</span> oldImage<span style='color:#808030; '>.</span>pixelVal<span style='color:#808030; '>[</span>i<span style='color:#808030; '>]</span><span style='color:#808030; '>[</span>j<span style='color:#808030; '>]</span><span style='color:#800080; '>;</span>
dim1<span style='color:#808030; '>[</span>i<span style='color:#808030; '>*</span>N <span style='color:#808030; '>+</span> j<span style='color:#808030; '>]</span> <span style='color:#808030; '>=</span> oldImage<span style='color:#808030; '>.</span>dim1<span style='color:#808030; '>[</span>i<span style='color:#808030; '>*</span>N <span style='color:#808030; '>+</span> j<span style='color:#808030; '>]</span><span style='color:#800080; '>;</span>
<span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
=== Assignment 3 ===