: nestini wrote:
: > Hello everybody,
: > I am student who just begin learning about programming
: > I want to know what is Sprase Matrix.
: > And would you please show me how to add the 2 Sprase Matrix in C
: > soursecode.
: >
: A sparse matrix is a matrix whose entries are mostly zeros. You add a
: sparse matrix like a regular matrix--element by element:
: for i=1:n
: for j=1:n
: A
[j] = A[j] + B[j];
: end
: end
: Of course, the representation of a sparse matrix is usually some sort of
: other datastructure holding the (x, y) coordinate and the entry. You
: can use a linked list, if you'd like, although a hashmap with an
: iterator would be better.
: --
: Thanks,
: Elliott C. B?ck
: --------------------------
: www.elliottback.com
: www.spreadIE.com
Why would hashing ever be better, or even as good? First, the hash-table
takes up extra space, which is just what you want to avoid (you are
trying to _conserve_ space by avoiding representation of zeroes).
Secondly, hashing is involved when you want to look up a particular
element. For many sparse matrix applications, this is irrelevant: you
only need sequential access across rows and columns for
addition/subtraction, inversion, adjunct, determinant, etc.