


Thread Tools  Display Modes 
Jul 14th, 2011, 8:47 PM  #1 
Banned
Join Date: Jul 2011
Posts: 1
Rep Power: 0

How to Perform Matrix Addition in C
As a C Programmer ,you need to deal with data structures likes an array.Programmers often needs to use a Multidimensional array in the form of matrix to do mathematical.Calculations.The Program Demonstrates how to Add any two matrices together and obtain the result in a new Matrix
The Core Operation performed here is C[i][j]=A[i][j]+B[i][j] ie:Elements from two Multidimensional array are added in an order and placed in a new Multidimensional array. You can get the complete source code from http://cmadeeasy.blogspot.com/2011/...adding2.html 
Jul 15th, 2011, 12:03 AM  #2 
Programming Guru
Join Date: Jun 2005
Posts: 1,333
Rep Power: 13

Re: How to Perform Matrix Addition in C
Is this meant to be an informational post? If so I suggest looking into more efficient algorithms. Large matrix operations are prone to causing cache thrashing and while the straightforward method works, it is not recommended.

Jul 24th, 2011, 12:36 PM  #3 
Newbie
Join Date: Jul 2011
Posts: 1
Rep Power: 0

Re: How to Perform Matrix Addition in C
I've created my own library for matrix operations. i think that will be somewhat efficient.
http://niralaakam.blogspot.com/2011/...nusingc.html 
Jul 25th, 2011, 12:09 PM  #4 
Programming Guru
Join Date: Jun 2005
Posts: 1,333
Rep Power: 13

Re: How to Perform Matrix Addition in C
Efficiency is relative to the problem at hand. For matrix operations, specifically a matrix mult, the baseline for efficiency is the most straightforward way to solve the problem. i.e. iterate through each column/row and perform the multiplication. For simple calculation this does the trick. But when you're dealing with large arrays as matrices often are, you will incur a lot of cache misses. There are much better ways of doing matrix multiplies to take advantage of spatial locality and limit your working set to fit into cache.
http://en.wikipedia.org/wiki/Strassen_algorithm 
Bookmarks 
Tags 
add, matrices, matrix, operations, programming, sum, tc 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
matrix calculator. need help! i have no idea where to start  rax_7  C++  2  Oct 11th, 2010 3:16 PM 
Another path matrix question.  gammaman  Software Design and Algorithms  6  Mar 24th, 2009 10:47 AM 
Matrix Class ... Operator Problem  Planet_EN  C++  10  Dec 6th, 2005 12:58 AM 
Program which computes the determinant of an n x n matrix  grimpirate  C  4  Sep 14th, 2005 3:24 AM 
Bizarre TI89 matrix algebra error (not language specific)  Generic  Other Scripting Languages  0  Sep 7th, 2005 8:16 PM 