Banded Matrix Design

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 1

CPSC2190 Assignment 05 the upper codiagonals are stored in the rows of an

Due date: November 13, 2008 array of size m × N.


Naoya Makino: 100106040 For example, consider the 5 × 5 matrix A with 1
Purpose: Design an ADT banded_matrix that lower and 2 upper codiagonals:
operates on (square) banded matrices (to store
only the non-zero entries).
Definition: A banded matrix is a sparse matrix
where non-zero entries appear in a diagonal band
comprising the main diagonal and 0 or more
diagonals on either side.
Codiagonals: other than the main diagonal
Banded_Matrix ADT In band storage format, the data would be arranged as
Method Description
Constructors
Banded_Matrix(size_type Default
size) constructor with
zero item
Banded_Matrix(size_type Constructor with
size, data values[]) an one
dimensional
array, values
Banded_Matrix(const Copy constructor
Banded_Matrix &that) This data would then be stored contiguously, row-
~Banded_Matrix() Destructor major order, in an array of length 20.
Accessor
size_type size() const Return the Reference:
number of rows  Boost C++ Libraries - Banded Matrix:
or columns
size_type diagonals() const Return the http://www.boost.org/doc/libs/1_35_0/libs/n
number of umeric/ublas/doc/banded.htm, November 06,
diagonals
Bool is_banded() Check if this 2008.
matrix is banded Matrix Storage Modes:

data get_item(size_type i, get element from
size_type j) values http://www.vni.com/products/imsl/document
Mutators
ation/CNL06/math/NetHelp/default.htm?turl
Void clear() Erase the matrix
Void erase(size_type row, Erase the value of =matrixstoragemodes.htm, November 12,
size_type col) the given row and
2008.
col
Void add_diagonal(data[] Add the diagonal
items) into the matrix
Private
data values[] Elements in the
matrix

Band Storage Format:


band_width = num_lower_codiagonals +
num_upper_codiagonals + 1
m = [(i - j + nuca + 1) * n + j]
// where nuca := num_upper_codiagonals, n:=
column size
In the M × N matrix lower codiagonals and

You might also like