472,989 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 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 7587
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 ....
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.