Source Code to find Inverse of N X N matrix in C or in C++

Posted on 2006-11-06
Last Modified: 2012-06-22
Hi Experts

I would like to have source code to find Inverse of N X N matrix
either in C or in C++

Any algorithm can be used Crout's, Gaus' or finding co-factor

Shiju S N
Question by:Shiju Sasidharan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 45

Accepted Solution

sunnycoder earned 400 total points
ID: 17880038
LVL 14

Author Comment

by:Shiju Sasidharan
ID: 17880192
@ sunnycoder
Thank you for the code.

I am also hoping for a C++ stuff with operator overloaded.
LVL 45

Expert Comment

ID: 17880199
>I am also hoping for a C++ stuff with operator overloaded.

Homework ?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 14

Author Comment

by:Shiju Sasidharan
ID: 17880225
sorry, i am not asking for home work job.
If any one has got link or source code then pls provide
LVL 45

Expert Comment

ID: 17880239
Sounds very strange that you impose a restriction like C++ with operator overloading, unless the specific requirement of an assignment is to use operator overloading ... else, any code that does the job should suffice.
LVL 14

Author Comment

by:Shiju Sasidharan
ID: 17880386
>>impose a restriction
Please appologise if my comment gave such an impression
LVL 39

Assisted Solution

itsmeandnobodyelse earned 100 total points
ID: 17883721
>>>>  I am also hoping for a C++ stuff with operator overloaded

Suppose, you think of overloading unary operator~.

Take the sample sunnycoder gave you a link to.

Make the three functions

    double Determinant(double **a,int n)

    void CoFactor(double **a,int n,double **b)

    void Transpose(double **a,int n)

member functions of a class Matrix. 'a' and 'n' were data members of the class while 'b' needs to be passed as 'Matrx& b'. Determinant, CoFactor and Transpose have no arguments then. The rest of the implementation code should compile with minor changes (e. g. replace malloc/free by new/delete).


    Matrix& Matrix::operator~()
            Matrix b = *this;  // make a copy

            Transpose( );

            (*this) /= b.Determinant();
            return *this;

Beside of the three functions you would a copy constructor/assignment operator and a operator/= where the prototype is

   Matrix& Matrix::operator/=(double d);

Regards, Alex


LVL 14

Author Comment

by:Shiju Sasidharan
ID: 17886589
Thank you friends

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel/Word Add-in in what language? 5 162
mixing C++ & C# in Vis Studio 2013 7 279
How to programmatically differentiate between C and Java 10 221
gdb doesn't stop on breakpoint 2 140
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question