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

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

Regards
Shiju S N
LVL 14
Shiju SasidharanAssoc Project ManagerAsked:
Who is Participating?
 
sunnycoderConnect With a Mentor Commented:
0
 
Shiju SasidharanAssoc Project ManagerAuthor Commented:
@ sunnycoder
Thank you for the code.

I am also hoping for a C++ stuff with operator overloaded.
0
 
sunnycoderCommented:
>I am also hoping for a C++ stuff with operator overloaded.

Homework ?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Shiju SasidharanAssoc Project ManagerAuthor Commented:
sorry, i am not asking for home work job.
If any one has got link or source code then pls provide
0
 
sunnycoderCommented:
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.
0
 
Shiju SasidharanAssoc Project ManagerAuthor Commented:
>>impose a restriction
Please appologise if my comment gave such an impression
0
 
itsmeandnobodyelseConnect With a Mentor Commented:
>>>>  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).

Then

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

            CoFactor();
            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

   

0
 
Shiju SasidharanAssoc Project ManagerAuthor Commented:
Thank you friends
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.