CrazyEngineers Forum
Navigation
Go Back   CrazyEngineers Forum > CE : Technical Discussions > Computer Science & IT Engineering


Advertisements
Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)
Old 18th November 2008, 04:26 PM
CE - Apprentice
 
rama_krish627's Avatar
 
Join Date: 20th August 2008
I'm a Crazy computer science Engineer
Posts: 29
Exclamation Sparse Matrix

Hi
Can any one tell me how to represent a Sparse Matrix using arrays.
and also how to add two sparse matrices.
rama_krish627 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote


  #2 (permalink)
Old 19th November 2008, 10:35 AM
CE - Apprentice
 
Join Date: 8th August 2007
I'm a Crazy Computer Science Engineer
Location: Kerala
Posts: 11
Send a message via MSN to manupep Send a message via Yahoo to manupep
Default Re: Sparse Matrix

sparse matrix is a matrix contain large no of elements but most of them are zeros("0") . So inorder to save the memory utilization we are not storing the zeros, only othr elements. Any sparse matrix has only 3 colums . but the row number depends on the number of non-zero elements.

format is

<row-no> <column-no> <value>
<row-no> <column-no> <value>
-------------------------------
eg:

3 0
0 8 reprents in sparse form as

0 0 3
1 1 8

I cant explain the whole procedure of adding becz i'min office now

first you make sure that order of 3 matx are same. then sameposition elements should be added and make the resultant. I think u can able to make the logic.
manupep is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)
Old 19th November 2008, 11:22 PM
CE - Enthusiast
 
komputergeek's Avatar
 
Join Date: 21st October 2008
I'm a Crazy IT Engineer
Location: India
Posts: 234
Send a message via Yahoo to komputergeek Send a message via Skype™ to komputergeek
Default Re: Sparse Matrix

Code:
//Addition

k=n2;
for(i=0;i<n1;i++)
{
      flag=0;
      for(j=0;j<n2;j++)
      {
            if( a[i][0] == b[j][0] && a[i][1]==b[j][1] )
            {
                    flag=1;
                    break;
             }
      }
      if( flag==1)
             b[j][2]=b[j][2] + a[i][2];
      else
       {
             b[k][0]=a[i][0];
             b[k][1]=a[i][1];
             b[k][2]=a[i][2];
             b[k][0]=b[i][0];
             b[k][1]=b[i][1];
             b[k][2]=b[i][2];
             k++;
        }
}

//result of addition is stored in b
This is just a logic.I haven't compiled the code.So expect errors in it
Let me know if it works.
__________________
IF YOU CAN'T Convince THEM ...
CONFUSE THEM ...

mail me at : komputergeek[at]crazyengineers[dot]net
komputergeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)
Old 20th November 2008, 07:53 PM
CE - Regular Member
 
Join Date: 24th July 2008
I'm a Crazy Computer Engineer
Posts: 63
Default Re: Sparse Matrix

just want to add ... the purpose of sparse matrix is 2 save memory and it is used when you have few information is a big space. So to preserve the memory we use sparse matrix
__________________
free Books
niraj.kumar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)
Old 21st November 2008, 06:08 PM
CE - Apprentice
 
rama_krish627's Avatar
 
Join Date: 20th August 2008
I'm a Crazy computer science Engineer
Posts: 29
Default Re: Sparse Matrix

ok fine I understood what it is.
rama_krish627 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
iPhone 3G has a hidden data matrix code CE-InFocus CE - InFocus 0 19th September 2008 02:26 PM
problem in matrix multiplication sahana Computer Science & IT Engineering 4 19th March 2008 12:20 AM
Hello from Matrix matrix CE - Introductions 4 2nd July 2007 01:04 AM


All times are GMT +6.5. The time now is 06:20 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0
Member comments are owned by the poster. Copyright © 2005-2009 CrazyEngineers.com. All rights reserved.

Advertisements