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

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 1779
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
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
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
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
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
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
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
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
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
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
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.