Solved

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

Posted on 2006-11-06
8
29,952 Views
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

Regards
Shiju S N
0
Comment
Question by:Shiju Sasidharan
  • 4
  • 3
8 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 400 total points
ID: 17880038
0
 
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.
0
 
LVL 45

Expert Comment

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

Homework ?
0
 
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 45

Expert Comment

by:sunnycoder
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.
0
 
LVL 14

Author Comment

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

Assisted Solution

by:itsmeandnobodyelse
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).

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
 
LVL 14

Author Comment

by:Shiju Sasidharan
ID: 17886589
Thank you friends
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now