473,224 Members | 1,988 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,224 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 19757
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
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...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.