473,562 Members | 2,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to compute eigenvalues and eigenvectors in C programming language?

Hi all,

I want to write a C program to compute eigenvalues and eigenvectors.
But the matrix is a complex matrix which has all complex numbers. Like
this:
5.8751 5.8774 + 1.5423i 2.0818 + 2.8963i 1.8692 +
1.9634i
5.8774 - 1.5423i 6.8258 2.6390 + 2.8255i 2.2955 +
1.9349i
2.0818 - 2.8963i 2.6390 - 2.8255i 3.9534 2.9155 -
0.3039i
1.8692 - 1.9634i 2.2955 - 1.9349i 2.9155 + 0.3039i 2.2816

Then, the eigenvalues are:
0.0412 0 0 0
0 0.1996 0 0
0 0 2.0591 0
0 0 0 16.6361

eigenvectors are:
-0.0506 + 0.2898i 0.1137 + 0.6431i -0.1009 - 0.3856i 0.3665 +
0.4403i
-0.0942 - 0.2603i -0.3552 - 0.5019i -0.3791 - 0.1255i 0.4927 +
0.3782i
-0.5045 - 0.0249i 0.2804 - 0.2056i 0.6644 - 0.0427i 0.4221 -
0.0503i
0.7627 -0.2731 0.4882 0.3245

Please help!

May 18 '07 #1
18 26333
On 17 May 2007 22:18:09 -0700, Jedora <je****@gmail.c omwrote:
>Hi all,

I want to write a C program to compute eigenvalues and eigenvectors.
But the matrix is a complex matrix which has all complex numbers. Like
this:
5.8751 5.8774 + 1.5423i 2.0818 + 2.8963i 1.8692 +
1.9634i
5.8774 - 1.5423i 6.8258 2.6390 + 2.8255i 2.2955 +
1.9349i
2.0818 - 2.8963i 2.6390 - 2.8255i 3.9534 2.9155 -
0.3039i
1.8692 - 1.9634i 2.2955 - 1.9349i 2.9155 + 0.3039i 2.2816

Then, the eigenvalues are:
0.0412 0 0 0
0 0.1996 0 0
0 0 2.0591 0
0 0 0 16.6361

eigenvectors are:
-0.0506 + 0.2898i 0.1137 + 0.6431i -0.1009 - 0.3856i 0.3665 +
0.4403i
-0.0942 - 0.2603i -0.3552 - 0.5019i -0.3791 - 0.1255i 0.4927 +
0.3782i
-0.5045 - 0.0249i 0.2804 - 0.2056i 0.6644 - 0.0427i 0.4221 -
0.0503i
0.7627 -0.2731 0.4882 0.3245

Please help!

I have this book "Numerical recipes in C" that has a chapter on
eigen-stuff.
maybe this title is a good search phrase for google ?
ah.. yes: www.nr.com !!

surely you could find the accompanying source on the net... I found it
on EMULE P2p...
May 18 '07 #2
On 2007-05-18 11:47:41 +0200, Osiris <no**@hotmail.c omsaid:
I have this book "Numerical recipes in C" that has a chapter on
eigen-stuff.
maybe this title is a good search phrase for google ?
ah.. yes: www.nr.com !!

surely you could find the accompanying source on the net... I found it
on EMULE P2p...
And surely you read that the book and the code snippets inside are
copyrighted and non-free, right?

--
Sensei <senseiwa at Apple's mac dot com>

If you get this in less than 10 seconds, then you are a certified geek.
"FEATUR"
(License plate seen on an old Volkswagen Beetle)
May 18 '07 #3
Sensei wrote:
On 2007-05-18 11:47:41 +0200, Osiris <no**@hotmail.c omsaid:
>I have this book "Numerical recipes in C" that has a chapter on
eigen-stuff.
maybe this title is a good search phrase for google ?
ah.. yes: www.nr.com !!

surely you could find the accompanying source on the net... I found it
on EMULE P2p...

And surely you read that the book and the code snippets inside are
copyrighted and non-free, right?
[OT, sorry]

Surely that means that one can type them in from a reference and try
them without fear of reprisal. Copyright was granted the moment the work
was created, but I see no moral reason why someone can't find the code
on the internet to study.
--
clvrmnky <mailto:sp***** *@clevermonkey. org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
May 18 '07 #4
In article <mV************ ****@nnrp.ca.mc i.com!nnrp1.uun et.ca>,
Clever Monkey <sp******@cleve rmonkey.org.INV ALIDwrote:
>Sensei wrote:
>On 2007-05-18 11:47:41 +0200, Osiris <no**@hotmail.c omsaid:
>>I have this book "Numerical recipes in C" that has a chapter on
>And surely you read that the book and the code snippets inside are
copyrighted and non-free, right?
>Surely that means that one can type them in from a reference and try
them without fear of reprisal.

No, it means that you can take the ideas expressed in the algorithms
and write your -own- versions of them.
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
May 18 '07 #5
Walter Roberson wrote:
In article <mV************ ****@nnrp.ca.mc i.com!nnrp1.uun et.ca>,
Clever Monkey <sp******@cleve rmonkey.org.INV ALIDwrote:
>Sensei wrote:
>>On 2007-05-18 11:47:41 +0200, Osiris <no**@hotmail.c omsaid:
>>>I have this book "Numerical recipes in C" that has a chapter on
>>And surely you read that the book and the code snippets inside are
copyrighted and non-free, right?
>Surely that means that one can type them in from a reference and try
them without fear of reprisal.


No, it means that you can take the ideas expressed in the algorithms
and write your -own- versions of them.
Wrong. Read http://www.nrbook.com/a/bookcpdf/c0-1.pdf where is says that
"you can type the programs from this book directly into your computer".

( I'm unable to copy the exact text from the pdf, sorry.)

Bjørn
--
Looking for an embeddable web server?
http://www.metasystems.no/products/h...der/index.html
May 18 '07 #6
Walter Roberson wrote:
In article <mV************ ****@nnrp.ca.mc i.com!nnrp1.uun et.ca>,
Clever Monkey <sp******@cleve rmonkey.org.INV ALIDwrote:
>Sensei wrote:
>>On 2007-05-18 11:47:41 +0200, Osiris <no**@hotmail.c omsaid:
>>>I have this book "Numerical recipes in C" that has a chapter on
>>And surely you read that the book and the code snippets inside are
copyrighted and non-free, right?
>Surely that means that one can type them in from a reference and try
them without fear of reprisal.


No, it means that you can take the ideas expressed in the algorithms
and write your -own- versions of them.
And, hence my comment you snipped, which I have replaced here:

"Copyright was granted the moment the work was created, but I see no
moral reason why someone can't find the code on the internet to study."

Someone points out else-thread that the copyright holders have granted
additional rights to type the code in, but even if that were not the
case most jurisdictions recognize private, personal, non-commercial use
as part of that default agreement.

For example, in my country I can make as many copies of many types of
media that I like, as long as it is for private, personal use and I do
not pass any of those copies along without express permission from the
rightsholder.

In general, rightsholders cannot ask for additional rights that local
jurisdiction expressly grants.

However, I'm not a lawyer and do not pretend to be one. I've read local
copyright code on how it affects me in some cases, and have come to the
conclusion that there is little illegal in copying source code from an
ordinary computer book into my computer for personal research.

Certainly there is very little immoral about such activities, even if
your local laws have other ideas.
--
clvrmnky <mailto:sp***** *@clevermonkey. org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
May 18 '07 #7
On May 17, 10:18 pm, Jedora <jed...@gmail.c omwrote:
Hi all,

I want to write a C program to compute eigenvalues and eigenvectors.
But the matrix is a complex matrix which has all complex numbers. Like
this:
5.8751 5.8774 + 1.5423i 2.0818 + 2.8963i 1.8692 +
1.9634i
5.8774 - 1.5423i 6.8258 2.6390 + 2.8255i 2.2955 +
1.9349i
2.0818 - 2.8963i 2.6390 - 2.8255i 3.9534 2.9155 -
0.3039i
1.8692 - 1.9634i 2.2955 - 1.9349i 2.9155 + 0.3039i 2.2816

Then, the eigenvalues are:
0.0412 0 0 0
0 0.1996 0 0
0 0 2.0591 0
0 0 0 16.6361

eigenvectors are:
-0.0506 + 0.2898i 0.1137 + 0.6431i -0.1009 - 0.3856i 0.3665 +
0.4403i
-0.0942 - 0.2603i -0.3552 - 0.5019i -0.3791 - 0.1255i 0.4927 +
0.3782i
-0.5045 - 0.0249i 0.2804 - 0.2056i 0.6644 - 0.0427i 0.4221 -
0.0503i
0.7627 -0.2731 0.4882 0.3245
It's a FAQ.

14.12: I'm looking for some code to do:
Fast Fourier Transforms (FFT's)
matrix arithmetic (multiplication , inversion, etc.)
complex arithmetic

A: Ajay Shah has prepared a nice index of free numerical
software which has been archived pretty widely; one URL
is ftp://ftp.math.psu.edu/pub/FAQ/numcomp-free-c .
See also questions 18.13, 18.15c, and 18.16.

Suggestion:
Try this search on sourceforge:
(+matrix +complex eigenvalue eigenvector eigenvalues eigenvectors) AND
-has_file:(0)

May 18 '07 #8
Jedora wrote:
Hi all,

I want to write a C program to compute eigenvalues and eigenvectors.
But the matrix is a complex matrix which has all complex numbers.

Why do you want to implement this yourself?
If you are not very experienced, there many pitfalls to watch out for,
you should at least verify your implementation with the robust code
found in EISPACK and CERNLIB. [1]

The definite reference on eigensystems, is Wilkinson and Reinsch,
"Handbook for Automatic Computation", IIRC sample code was in AGOL.
[1] Warning, it's 20 years since I solved complex eigensystems myself,
but back then we did this in FORTRAN on supercomputers. Dan Pop stated
once here, that CERNLIB these days has been ported to C++. If your
problem is simple, can't tools like e.g. Mathlab & Maple help out?

--
Tor <torust [at] online [dot] no>
May 18 '07 #9
Tor Rustad wrote:
IIRC sample code was in AGOL.
ALGOL :-)

--
Tor <torust [at] online [dot] no>
May 18 '07 #10

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

Similar topics

18
2422
by: Roman Suzi | last post by:
;-) Just type into google "best programming language" and press (I am lucky) Sincerely yours, Roman Suzi -- rnd@onego.ru =\= My AI powered by GNU/Linux RedHat 7.3
2
2233
by: Matt | last post by:
I always heard dialet of programming language. For example, Objective-C is a dialet of C programming language. What does it really mean? C is already standardize, why there are dialets? Or when people say implementation of a programming language. please advise. thanks!!
134
7917
by: evolnet.regular | last post by:
I've been utilising C for lots of small and a few medium-sized personal projects over the course of the past decade, and I've realised lately just how little progress it's made since then. I've increasingly been using scripting languages (especially Python and Bourne shell) which offer the same speed and yet are far more simple and safe to...
2
1892
by: Juuso Hukkanen | last post by:
Language is quite good, if you don't learn the language syntax in 30 minutes complain and flame. t3d(TM) in a nutshell: -Languages main documentation is two pages (presented on the last two pages of the ChOS license draft). http://www.tele3d.com/ChOS/ChOS_beta1.zip -C based, bounds checked, garbage collected, with GUI, strongly typed,
22
13663
by: Matt | last post by:
Some people identify Microsoft C# is Proprietary programming language. What is Proprietary programming language then? How does it differ from other languages such as C++, or Java?? Please advise. thanks!!
25
2557
by: Dave | last post by:
I want to spend two minutes on my soapbox. I love C#. I am so productive in it it's ridiculous. But it's so easy to write code that uses poor design principles. Example: just making variables public instead of using properties. Another example: passing references to forms to other classes so they can modify things (tight coupling). ...
7
4934
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already developed significant content for the C programming language that is available at: https://www.securecoding.cert.org/ by clicking on the "CERT C...
14
3274
by: deko | last post by:
For building Windows desktop apps, the clear favorite is C#. But my clients can't afford to buy Microsoft products. So I need to develop software for Linux users and web applications. In the open source world, what is the programmer's language of choice? Judging by the number of members in each of these...
17
4687
by: CoreyWhite | last post by:
I bought this book years ago, when I was just learning C++. Since then I've gone through every math course offered at my college, taken courses on coding C & thinking in terms how how to make the smallest tightest algorithms to preform specific functions. I've also grown and matured a lot, and am wiser and older. I'm reading through the C+...
0
7577
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7627
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
6221
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5477
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
3623
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
3608
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1191
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
903
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.