473,386 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

c++ code for inverse of NXN matrix

I need c++ code for inverse of nxn matrix ,if available please help me
Mar 7 '08 #1
3 7620
sanctus
84
I need c++ code for inverse of nxn matrix ,if available please help me
I do not know if it is exists for general case. For the 2X2 matrix there is the gsl library. If you have matlab you can call matlab to invert the matrix from your c++ code...
Mar 7 '08 #2
JosAH
11,448 Expert 8TB
Never invert a square matric explicitly: it is highly numerically unstable. A much
better method is to find two triangular matrixes L and U (lower and upper triangular
respectively where L has just ones (1) on its diagonal such that L.U == P.A
where P is a row permutation matrix, Given L, U and P it is extremely easy
to solve the linear system A.x == b.

P.A.x == P.b (swap the elements in b)
L.U.x == P.b
L.y == P.b (by using a simple backward substitution)
U.x == y (by using a simple forward substitution).

Calculate x for the unit vectors b and voila.

Google for "LUP decomposition" for the gory details.

kind regards,

Jos
Mar 7 '08 #3
hsriat
1,654 Expert 1GB
See if you can convert this PHP code to C++

Regards
Mar 29 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: florian kno | last post by:
hello all! i'm using gcc 3.2 on linux. i have a (self developed) matrix class: class cMatrix { // unneccessary info stripped .... double *data; // matrix data is stored in a heap array ...
6
by: greenflame | last post by:
I need code to compute the determinant and inverse of a matrix. for example the determinant and inverse of:
6
by: vishnu mahendra | last post by:
hello to all, can any one please give me an algorithm to find inverse of a matrix of order n rows and m columns. thank you in advance, vishnu.
1
by: praneeth | last post by:
hi i want a c program to find the inverse of 3X3 matrix urgent i need it fast anyoone reply thanks
1
by: ravleen bindra | last post by:
please tell me how to find inverse of a nxm matrix in C programming language
0
by: YUSUF ISIAKA | last post by:
Him please help me with the codes for the following questions: 1. Write a program in c/c++ to compute the inverse of a square matrix. 2. Write a program in c/c++ to compute the determinant of a...
2
by: leelaramtenneti | last post by:
hello I need a program to find a Inverse of a square complex matrix in java... . The program should calculate the inverse of a matrix in which each element has both real and imaginary parts. Or...
0
by: DarrenWeber | last post by:
# Copyright (C) 2007 Darren Lee Weber # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free...
3
by: aaram81 | last post by:
I need a help in C++ for the following question: write a p[rogram to read 4 by 4 matrix, store it and find the inverse of this matrix. then multiply the inverse with the original matrix , store it ....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.