473,503 Members | 4,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

request for a program

i request the group to please send me " c programs " to find the matrix
inverse and determinant for any order.

May 12 '06 #1
5 1783
kumar said:
i request the group to please send me " c programs " to find the matrix
inverse and determinant for any order.


#include <stdio.h>
#include <string.h>

#define MAXLINE 16384

int main(void)
{
char haystack[MAXLINE] = {0};
char needle[] = "the matrix inverse and determinant for any order";
unsigned long line = 0;

while(fgets(haystack, sizeof haystack, stdin) != NULL)
{
++line;
if(strstr(haystack, needle) != NULL)
{
printf("Hit on line %lu\n", line);
}
}

return 0;
}

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
May 12 '06 #2
Why? I am sure you can find some open-source software that has the two
operations you are looking for. The determinant is very easy to
implement using a recursive algorithm. Expanding along a column or row
is well-suited to recursion. Do you have any C experience?

May 12 '06 #3
On 2006-05-12, ro**********@gmail.com <ro**********@gmail.com> wrote:

[
kumar> i request the group to please send me " c programs " to find the
kumar> matrix inverse and determinant for any order.
]
Why? I am sure you can find some open-source software that has the two
operations you are looking for. The determinant is very easy to
implement using a recursive algorithm.


The recursive algorithm is easy to implement, but likely to be very
inefficient if the number of rows and columns is much more than 4.

One way to work out the determinant I've heard of is to make the matrix
upper-triangular, and then to multiply all the diagonal elements
together.

The upper-triangular matrix can also be used to invert the matrix.

I have some octave source to hand for this, which could be converted to
C fairly easily, if the OP can understand the octave. Doesn't include
solving for the inverse using U, but that part isn't too hard.

1;

function U = gauss(M)
% Make a matrix upper triangular
for i = 2:rows(M)
for j = 1:i - 1 % rows above you
f = M(i, j) / M(j, j);
M(i, :) -= M(j, :) * f;
endfor
endfor
U = M;
endfunction

function d = my_det(M)
% Compute determinant using Gaussian elimination followed by multiplying
% diagonal elements together
U = gauss(M);
d = 1;

for i = 1:rows(U)
d *= U(i, i);
endfor
endfunction

M = rand(6)

% Using built-in det
det(M)

% Using our one, for comparison
my_det(M)
May 12 '06 #4
On Fri, 12 May 2006 04:23:34 -0700, kumar wrote:
i request the group to please send me " c programs " to find the matrix
inverse and determinant for any order.

Somewhat off topic here.
You might want to try sci.math.num-analysis.
Why do you want to compute the inverse? If it's to solve
a set of linear equations then there better ways to do that;
try Googling for "LU decomposition" (which will also allow you
to compute the inverse and determinant, if you really need them).
Note that the straightforward way of computing the determinant takes
on the order of n! operations, which makes it infeasible for anything
but small matrices.
Duncan
May 12 '06 #5
ro**********@gmail.com wrote:
Why?

Why what? See below.

Brian
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
May 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2406
by: Doug Farrell | last post by:
Hi everyone, I'm trying to build a program to interface to a SOAP/XML interface provided by one of our vendors. This interface is built with MS SOAP Toolkit 3.0, so I'm guessig they are running...
6
7300
by: Marvin Libson | last post by:
Hi All: I am running DB2 UDB V7.2 with FP11. Platform is Windows 2000. I have created a java UDF and trigger. When I update my database I get the following error: SQL1224N A database...
10
2169
by: William L. Bahn | last post by:
I'm looking for a few kinds of feedback here. First, there is a program at the end of this post that has a function kgets() that I would like any feedback on - including style. Second, for...
9
1691
by: Adam Monsen | last post by:
I kindly request a code review. If this is not an appropriate place for my request, where might be? Specific questions are in the QUESTIONS section of the code. ...
4
5141
by: Josema | last post by:
Hi to all, I have a program that list broken links into a web site... The program works in the majority of the times, but in some urls, i dont know why, but the request.GetResponse (all the...
1
2912
by: EoRaptor013 | last post by:
Not sure where to ask this question, but... I'm using a TreeView component to enable browsing file folders in a specific directory (for test purposes /Program Files/). Some users use an ampersand...
1
2224
by: Vimala Sri | last post by:
Hello all, Have a great day. I wish to made interaction from c program in unix to the java servlet. That is i want to send a request from the Unix c program to the servlet. ...
7
2445
by: John Nagle | last post by:
I'm converting a web app from CGI to FCGI. The application works fine under FCGI, but it's being reloaded for every request, which makes FCGI kind of pointless. I wrote a little FCGI app which...
0
1533
by: darfur | last post by:
I'm writing an application that simplifies the interface to a few websites I use at my job. One of the web servers has a tendency to cause my program to throw a time out exception for a variety of...
1
1284
by: earthdirt | last post by:
I'm a newbie and I'm in way over my head with a pressing real world problem I need to solve with python.....one that isn't waiting for me to learn all I need to learn about programming. I have 3...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7316
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...
1
6975
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...
1
4992
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...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
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...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
371
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...

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.