<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<hr>
<h3>Ideas of Implementation</h3>
<p>
The sparse-matrix classes of CPPLapack is designed in the following policies.
<ul>
<li>The matrix data must be stored continuously in the memory space.
The link-list is not adopted because it is too slow.</li>
<li>The put and del operation of a component should not come with the relocation of the matrix data as the push_back and pop_back functions of std::vector always do.</li>
</ul>
</p>
<p>
Each sparse-matrix object has the following important member variables.
<center><table border="3">
<tr>
<td><code>int cap</code></td>
<td>size of matrix data array (capacity of the number of components)</td>
</tr>
<tr>
<td><code>int vol</code></td>
<td>current volume of array size (current number of non-zero component)</td>
</tr>
<tr>
<td><code>int* indx</code></td>
<td>row index of matrix data</td>
</tr>
<tr>
<td><code>int* jndx</code></td>
<td>column index of matrix data</td>
</tr>
</table></center>
<p>
The size of <code>array</code> is determined by <code>cap</code>.
The volume of the matrix <code>vol</code> is changed each time when a non-zero component is put or deleted.
</p>
<p>
For example, <code>CPPL::dssmatrix A(m,n,cap);</code> makes a <code>m</code>x<code>n</code> matrix <code>A</code> which has <code>cap</code> free data space.
Its <code>vol</code> is automatically set to zero in this case.
</p>
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<hr>
<h3>"put" and "fput"</h3>
<p>
To assign a value to a component of dssmatrix or zssmatrix, use "put" or "fput" function.
</p>
<p>
The <code>"put(i,j,v)"</code> function checks if the (i,j) component already exists.
When the (i,j) component exists, <code>put</code> function overwrite the existing value.
When the (i,j) component doesn't exist, <code>put</code> function creates a new element and increase the volume(VOL++;).
In case VOL=CAP, <code>put</code> function calls <code>expand</code> function before creating a new element.
</p>
<p>
On the other hand, the <code>"fput(i,j,v)"</code> function doesn't check if the (i,j) component already exists and if VOL=CAP.
The <code>fput</code> function always suppose that the (i,j) component doesn't exist and VOL<CAP,
and simply creates a new element and increase the volume(VOL++;).
</p>
<p>
The <code>"fput(i,j,v)"</code> function is faster but more dangerous than the <code>"put(i,j,v)"</code> function.
</p>
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<hr>
<h3>"add", "sub", "mult", and "div"</h3>
<p>
To add, subtract, multiply, and divide a component of dssmatrix or zssmatrix, use the <code>add</code>, <code>sub</code>, <code>mult</code>, and <code>div</code> functions, respectively.
</p>
<p>
These functions check if the (i,j) component already exists.
When the (i,j) component exists, these functions operate the existing value.
When the (i,j) component doesn't exist, the <code>add</code> and <code>sub</code> functions create a new element, set to v and -v respectively, and VOL++, and the <code>mult</code> and <code>div</code> functions do nothing.
</p>
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<hr>
<h3>"del" and "fdel"</h3>
<p>
To delete a component of dssmatrix or zssmatrix, use <code>del</code> or <code>fdel</code> function.
</p>
<p>
The <code>del(i,j)</code> function deletes the (i,j) component when it exists.
The <code>fdel(c)</code> function deletes the cth element of the array when it exists.
</p>
<p>When you use <code>del</code> or <code>fdel</code> in a loop, you must pay a lot of attention to what they do.
For example, the following for-loop doesn't work as it seems to be.
<br><code>
for(int c=0; c<A.vol; c++){<br>
if(A.indx[i]==A.jndx[c]){ A.fdel(c); }<br>
}
</code><br>
To make the code work as we expect,
<br><code>
for(int c=0; c<A.vol; c++){<br>
if(A.indx[i]==A.jndx[c]){ A.fdel(c); c--; }<br>
}
</code><br>
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<hr>
<h3>"expand" and "CPPL_SS_SECTOR"</h3>
<p>
The <code>expand</code> function creates an array which is "a little bit" larger than the current array, copies the data of current array to the new array, and deletes the current array.
The size of "a little bit" is defined in cpplapack.h as a macro "CPPL_SS_SECTOR".
You can edit cpplapack.h and change the value of "CPPL_SS_SECTOR".
</p>
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<hr>
<h3>"isListed" and "number"</h3>
<p>
The <code>isListed(i,j)</code> function checks if the (i,j) component is listed.
When the (i,j) component is listed, this function returns 1, otherwise 0.
</p>
<p>
The <code>number(i,j)</code> function returns the element number of the (i,j) component if it is listed.
When the (i,j) component is no listed, this function returns -1.
</p>
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<!---------------------------------------------------------------------------->
<hr>
<h3>"checkup"</h3>
<p>
After using fput, read, etc., you may break the consistency of the object.
The <code>checkup</code> function is helpful for the debugging.
It checks the bounds of <code>cap</code>, <code>vol</code>, <code>indx</code>, and <code>jndx</code>, and the double-entry of the elements.
</p>