Add to Favorites    Make Home Page 8556 Online  
 Language Categories  
 Our Services  

Home » C Home » Beginners / Lab Assignments Home » Matrix Inverse By Gauss Jordan Method

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Matrix Inverse By Gauss Jordan Method
Author Tapan Kumar Mishra
Author Email mishra.tapankumar [at] gmail.com
Description It uses Gauss Jordan method to evaluate inverse of any
square
matrix.It is the most efficient method of finding inverse of a matrix
Category C » Beginners / Lab Assignments
Hits 343669
Code Select and Copy the Code
#include<stdio.h> #include<stdlib.h> int main() { float **A,**I,temp; int i,j,k,matsize; printf("Enter the size of the matrix(i.e. value of 'n' as size is nXn):"); scanf("%d",&matsize); A=(float **)malloc(matsize*sizeof(float *)); //allocate memory dynamically for matrix A(matsize X matsize) for(i=0;i<matsize;i++) A[i]=(float *)malloc(matsize*sizeof(float)); I=(float **)malloc(matsize*sizeof(float *)); //memory allocation for indentity matrix I(matsize X matsize) for(i=0;i<matsize;i++) I[i]=(float *)malloc(matsize*sizeof(float)); printf("Enter the matrix: "); // ask the user for matrix A for(i=0;i<matsize;i++) for(j=0;j<matsize;j++) scanf("%f",&A[i][j]); for(i=0;i<matsize;i++) //automatically initialize the unit matrix, e.g. for(j=0;j<matsize;j++) // - - if(i==j) // | 1 0 0 | I[i][j]=1; // | 0 1 0 | else // | 0 0 1 | I[i][j]=0; // - - /*---------------LoGiC starts here------------------*/ //procedure to make the matrix A to unit matrix for(k=0;k<matsize;k++) //by some row operations,and the same row operations of { //Unit mat. I gives the inverse of matrix A temp=A[k][k]; //'temp' stores the A[k][k] value so that A[k][k] will not change for(j=0;j<matsize;j++) //during the operation A[i][j]/=A[k][k] when i=j=k { A[k][j]/=temp; //it performs the following row operations to make A to unit matrix I[k][j]/=temp; //R0=R0/A[0][0],similarly for I also R0=R0/A[0][0] } //R1=R1-R0*A[1][0] similarly for I for(i=0;i<matsize;i++) //R2=R2-R0*A[2][0] ,, { temp=A[i][k]; //R1=R1/A[1][1] for(j=0;j<matsize;j++) //R0=R0-R1*A[0][1] { //R2=R2-R1*A[2][1] if(i==k) break; //R2=R2/A[2][2] A[i][j]-=A[k][j]*temp; //R0=R0-R2*A[0][2] I[i][j]-=I[k][j]*temp; //R1=R1-R2*A[1][2] } } } /*---------------LoGiC ends here--------------------*/ printf("The inverse of the matrix is: "); //Print the matrix I that now contains the inverse of mat. A for(i=0;i<matsize;i++) { for(j=0;j<matsize;j++) printf("%f ",I[i][j]); printf(" "); } return 0; }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi դ ? ??
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2023 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1087


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review