473,583 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inverse of 3X3 matrix

2 New Member
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 19794
Banfa
9,065 Recognized Expert Moderator Expert
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
25196
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
4836
by: ravleen bindra | last post by:
please tell me how to find inverse of a nxm matrix in C programming language
7
12670
by: ajeetbaraskar | last post by:
can any one send me the codining for finding out inverse of a 6x6 matrix
0
2383
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 square matrix.
2
13304
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 atleast help me in finding inverse of a ordinary n*n square matrix in java
2
3830
by: leelaramtenneti | last post by:
How to find inverse of a complex matrix ????
0
2802
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 Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it...
3
6371
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 . lastly print the inverse of the matrix which is output of multiplication. Could you help me please...somebody..????
1
15238
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
0
8317
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7928
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8188
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5695
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3813
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3839
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2326
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1422
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1151
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.