0

Possible Duplicates:
Defining a matrix as an array of arrays and computation its inverse matrix in C++
Simple 3x3 matrix inverse code (C++)

how to find a inverse of matrix in c++ . simple coding just to find inverse of 3by3 matrix and also for 4 by 4 matrix

Community
  • 1
  • 1
saad
  • 9
  • 1
  • 1
  • 2
  • Please show the code you have and why you suspect it isn't working. You should have more trouble understanding what the inverse of a matrix is and how to obtain it than to translate that thought into code, so it's obvious you aren't putting forth much effort here. – San Jacinto Dec 22 '09 at 15:22
  • Duplicate - See http://stackoverflow.com/questions/983999/simple-3x3-matrix-inverse-code-c – zebrabox Dec 22 '09 at 16:06

3 Answers3

10

C++ provides no language facility to do this. You must either code it yourself or use a library.

If the question is how to code it, the starting place is "Do you know how to invert a matrix on paper?"

dmckee --- ex-moderator kitten
  • 98,632
  • 24
  • 142
  • 234
1

This is not a programming question per se but rather a mathematical question. Finding inverses of a matrix on a computer does, however, require ample knowledge that floating point arithmetic is flawed and imprecise. If you don't believe me create a 3x3 array such that a_mn is 1/(m+n) and use the general inverse matrix solution you'd do on pen and paper. You should go here for all your simple math algorithms needs.

wheaties
  • 35,646
  • 15
  • 94
  • 131
1

Check out this link to get inverse of the matrix , its very efficient method ( Gauss Jordan ) as compared to method based on co-factor and determinant.

Then think upon it and try to implement it yourself.

http://en.wikipedia.org/wiki/Gauss%E2%80%93Jordan_elimination

Ashish
  • 8,441
  • 12
  • 55
  • 92