473,385 Members | 1,486 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,385 software developers and data experts.

inverse of 3X3 matrix

hi i want a c program to find the inverse of 3X3 matrix
urgent
i need it
fast
anyoone reply
thanks
Jul 18 '06 #1
1 19769
Banfa
9,065 Expert Mod 8TB
Here is some visual basic code that does something similar, see if you can convert and adapt it.

Can you describe the process of inverting a matrix?

Expand|Select|Wrap|Line Numbers
  1. Private Function InternalMatrixSolve(ByRef r1() As Double, ByRef r2() As Double, ByVal size%)
  2.     Dim Matrix(2, 2) As Double
  3.     Dim Vector(2) As Double
  4.  
  5.     Rem Set up the normalised matrix and vector
  6.  
  7.     For y% = 0 To 2
  8.         For x% = 0 To 2
  9.             Matrix(y%, x%) = 0
  10.             For r% = 1 To size
  11.                 Matrix(y%, x%) = Matrix(y%, x%) + ((r1(r%) ^ y%) * (r1(r%) ^ x%))
  12.             Next
  13.         Next
  14.  
  15.         Vector(y%) = 0
  16.         For r% = 1 To size
  17.             Vector(y%) = Vector(y%) + ((r1(r%) ^ y%) * r2(r%))
  18.         Next
  19.     Next
  20.  
  21.     For y% = 0 To 2
  22.  
  23.         Rem Get a 1 on the diagonal by dividing through the current line by the diagnoal cell
  24.         Divisor# = Matrix(y%, y%)
  25.  
  26.         If Divisor# = 0 Then
  27.             InternalMatrixSolve = "MATHS ERROR"
  28.             Exit Function
  29.         End If
  30.  
  31.         For x% = y% To 2
  32.             Matrix(y%, x%) = Matrix(y%, x%) / Divisor#
  33.         Next
  34.  
  35.         Vector(y%) = Vector(y%) / Divisor#
  36.  
  37.         Rem get 0s below the current diagonal by taking away multiples of the current line
  38.         For y2% = y% + 1 To 2
  39.             Multiplier# = Matrix(y2%, y%)
  40.             For x% = y% To 2
  41.                 Matrix(y2%, x%) = Matrix(y2%, x%) - (Matrix(y%, x%) * Multiplier#)
  42.             Next
  43.  
  44.             Vector(y2%) = Vector(y2%) - (Vector(y%) * Multiplier#)
  45.         Next
  46.     Next
  47.  
  48.     Rem we now have 1s on the diagnoal and )s below the diagonal
  49.     Rem need to get 0s above the diagonal
  50.  
  51.     For y% = 2 To 0 Step -1
  52.  
  53.         Rem get 0s above the current diagonal by taking away multiples of the current line
  54.         For y2% = y% - 1 To 0 Step -1
  55.             Multiplier# = Matrix(y2%, y%)
  56.             For x% = y% To 2
  57.                 Matrix(y2%, x%) = Matrix(y2%, x%) - (Matrix(y%, x%) * Multiplier#)
  58.             Next
  59.  
  60.             Vector(y2%) = Vector(y2%) - (Vector(y%) * Multiplier#)
  61.         Next
  62.     Next
  63.  
  64.     InternalMatrixSolve = Vector
  65. End Function
Jul 18 '06 #2

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

Similar topics

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: ravleen bindra | last post by:
please tell me how to find inverse of a nxm matrix in C programming language
7
by: ajeetbaraskar | last post by:
can any one send me the codining for finding out inverse of a 6x6 matrix
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...
2
by: leelaramtenneti | last post by:
How to find inverse of a complex matrix ????
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 ....
1
by: dazzler | last post by:
Hi! I have problem with numpy, multiplying with an inversed matrix will crash python :( this works fine: from numpy import matrix A = matrix(,]) B = matrix(,]) print A.I #inverse matrix
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.