Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.25/5 (3 votes)
See more:
I have a lot of calculation on complex numbers in C#.what can i do? is there idea for doing it?
Posted
Comments
Dave Kreskowiak 17-Mar-11 15:40pm    
Your question is very vague. But, I would probably start by creating a class that represents a complex number. Beyond that, it's impossible to answer a question that you never asked. What do you want to do with these complex numbers??
Member 7753662 17-Mar-11 16:36pm    
tnx Dave
I want to integrating a complex function,such as exp(j*k*x).
(j^2=-1 !)
Dave Kreskowiak 17-Mar-11 18:22pm    
That doesn't look like it has anything to do with complex numbers. Expression parsing and evaluation, yes. If you haven't done anything like that before, you've got a bunch of research to do. I suugest starting with "Reverse Polish Notation" and moving up from there.
Henry Minute 17-Mar-11 15:45pm    
Further to Dave's comment, there is even a simple example in the C# Programming Guide --> http://msdn.microsoft.com/en-us/library/6fbs5e2h%28v=VS.90%29.aspx
apaka 17-Mar-11 15:56pm    
Maybe you want something like this http://www.codeproject.com/KB/dotnet/complex_math.aspx

First of all: read this:

http://msdn.microsoft.com/en-us/magazine/cc163995.aspx[^]

The answer on complex numbers strongly depends on .NET Framework version. If you use v.4.0. you should use new name space System.Numerics: http://msdn.microsoft.com/en-us/library/system.numerics.aspx[^].

It introduces two new things: arbitrary-precision integer arithmetic (which is a great achievement!) and complex arithmetic.

—SA
 
Share this answer
 
Comments
Espen Harlinn 21-Mar-11 5:05am    
Interesting MSDN article, 5!
Sergey Alexandrovich Kryukov 21-Mar-11 5:18am    
Thank you. Did you try BigInteger? This is amazing code. And hard to get (as I remember I uses something like that in Python; and never knew it was available anywhere else; I don't count many libraries with unlimited precision but fixed at the moment of instantiation which is not interesting at all. It is easy to exhaust all the memory with just 2-3 operations with BigInteger)
--SA
Sergey Alexandrovich Kryukov 21-Mar-11 5:21am    
And thank you for the vote!
--SA
I think you'll find that somebody has solved this problem before:
http://numerics.mathdotnet.com/[^] - the source code is available on codeplex[^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Yusuf 17-Mar-11 16:37pm    
I doubt he need that, but good link nonetheless. What he is perceiving it as complex, may not be complex at all. Some calculation as its best.
Espen Harlinn 17-Mar-11 17:33pm    
Thank you Yusuf, Math.NET handles complex numbers - as I understood it, that's what he was asking for :)
Member 7753662 18-Mar-11 2:16am    
tnx Espen.what's Math.NET and how can i use this?
Espen Harlinn 18-Mar-11 4:39am    
Follow the links provided with my answer, download the library, and you'll find a number of examples - including how to work with complex numbers
Sergey Alexandrovich Kryukov 18-Mar-11 15:12pm    
This is good, but my 4 this time. How could you forget new System.Numerics (v.4.0 only)?!
I also got another overview material. Please see my Answer.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900