473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Sprase matrix

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.

Nov 14 '05 #1
8 2381
Quoth nestini on or about 2004-11-11:
I am student who just begin learning about programming
I want to know what is Sprase Matrix.
I think you must've misread/mistyped `sparse matrix'. Some immediate
references spring to mind:

http://en.wikipedia.org/wiki/Sparse_matrix
http://planetmath.org/encyclopedia/M...ecialForm.html
And would you please show me how to add the 2 Sprase Matrix in C
sourcecode.


That sounds like homework. Mathematically, addition of sparse matrices
works like `ordinary' matrices. I suspect the distinction occurs when
sparse matrices are expressed in a compressed form.

-trent
Nov 14 '05 #2
"nestini" <xa*******@hotmail.com> wrote in message
news:d4******************************@localhost.ta lkaboutprogramming.com...
Hello everybody,
I am student who just begin learning about programming
I want to know what is Sprase Matrix.
I don't know what a "sprase matrix" is, but a "sparse matrix"
is a matrix in which unused elements do not consume storage.
And would you please show me how to add the 2 Sprase Matrix in C
soursecode.


Perhaps if you show us *your* code which implements a sparse
matrix, we could offer advice on how to add 2 of them togther.
(Can you do it with a 'normal' matrix? If not, I advise you
to work on that first.)

Nobody here is going to hand you the code on a silver platter.
Show your best efforts first, then you'll get plenty of help.
-Mike
Nov 14 '05 #3
Mike Wahler <mk******@mkwahler.net> scribbled the following:
"nestini" <xa*******@hotmail.com> wrote in message
news:d4******************************@localhost.ta lkaboutprogramming.com...
Hello everybody,
I am student who just begin learning about programming
I want to know what is Sprase Matrix.
I don't know what a "sprase matrix" is, but a "sparse matrix"
is a matrix in which unused elements do not consume storage.


I have never needed to make a sparse matrix myself, but can't this be
done with a linked list of linked lists? Every actual object in the
lists would, of course, have to carry information not only about the
element itself, but about its coordinates in the matrix as well. This
would triple its size, not counting pointers. The matrix would have to
be *very* sparse for the total storage to be less than a dense matrix,
or whatever a conventional matrix is called.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"It sure is cool having money and chicks."
- Beavis and Butt-head
Nov 14 '05 #4
Joona I Palaste wrote:
Mike Wahler <mk******@mkwahler.net> scribbled the following:
"nestini" <xa*******@hotmail.com> wrote in message
news:d4******************************@localhost.ta lkaboutprogramming.com...
Hello everybody,
I am student who just begin learning about programming
I want to know what is Sprase Matrix.

I don't know what a "sprase matrix" is, but a "sparse matrix"
is a matrix in which unused elements do not consume storage.


I have never needed to make a sparse matrix myself, but can't this be
done with a linked list of linked lists? Every actual object in the
lists would, of course, have to carry information not only about the
element itself, but about its coordinates in the matrix as well. This
would triple its size, not counting pointers. The matrix would have to
be *very* sparse for the total storage to be less than a dense matrix,
or whatever a conventional matrix is called.


It could. but access would be O(n).
With a hash table it would be O(1).

gtoomey
Nov 14 '05 #5
Joona I Palaste <pa*****@cc.helsinki.fi> wrote in message news:<cn**********@oravannahka.helsinki.fi>...
I have never needed to make a sparse matrix myself, but can't this be
done with a linked list of linked lists? Every actual object in the
lists would, of course, have to carry information not only about the
element itself, but about its coordinates in the matrix as well. This
would triple its size, not counting pointers. The matrix would have to
be *very* sparse for the total storage to be less than a dense matrix,
or whatever a conventional matrix is called.


Sparse matrices are mostly used for large linear algebra problems
(including solving partial differential equations), where it is
important that the storage structure fits well with the access pattern
of the algorithms being used. The matrices can indeed be very
sparse: it is not uncommon to have the matrix size proportional to the
square of the number of nonzero elements.

Details are OT here; sci.math.num-analysis might be a better place.

-thomas
Nov 14 '05 #6
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[i][j] = A[i][j] + B[i][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
Nov 14 '05 #7
Elliott Back <el*****@cornell.edu> wrote:
: 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[i][j] = A[i][j] + B[i][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.


Nov 14 '05 #8

"Scott J. McCaughrin" <sj******@bluestem.prairienet.org> wrote in message
news:cn**********@wildfire-pl.prairienet.org...
Elliott Back <el*****@cornell.edu> wrote:
: 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[i][j] = A[i][j] + B[i][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.

There's a lot of different ways to have a sparse array. Speaking of
computational tactics in generality is beyond the scope of tapping out an
e-mail message. MPJ
Nov 14 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
5
by: Jason | last post by:
Hello. I am trying to learn how operator overloading works so I wrote a simple class to help me practice. I understand the basic opertoar overload like + - / *, but when I try to overload more...
6
by: memocan | last post by:
#include <iostream> using namespace std; int x; //global variable matrix int main() { x= new float ; //initialize the size now }
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
2
by: DarrenWeber | last post by:
Below is a module (matrix.py) with a class to implement some basic matrix operations on a 2D list. Some things puzzle me about the best way to do this (please don't refer to scipy, numpy and...
0
by: DarrenWeber | last post by:
# Copyright (C) 2007 Darren Lee Weber # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free...
18
by: Hypnotik | last post by:
Hello everyone. I'm writing a program which uses a class called matrix. I have written all of the different functions, constructor, etc. When I run the program I receive "Constructor", which I...
2
by: rijaalu | last post by:
I am designing a matrix class that performs addition, multicpication, substraction and division. When ever i complie the code it shows an error. include <iostream> using namespace std; class...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.