Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Complex Numbers in Java

  1. #1
    Junior Member
    Join Date
    May 2011
    Thanked 0 Times in 0 Posts

    Default Complex Numbers in Java

    Hello Everyone,

    I am new to programming in Java. Been a Matlab programmer for the past 8-9 years. I have a question (This might look like a very dumb question to many of you Java programmers)?

    Let say Z(n) is an array of complex number defined as (3+4*i)/(9-(7*i)*n); where for simplicity n=0,1,23,.....9;

    T(n) is an array of complex number defined as (2.25-(9*i)*n)/(8+11.34*i); where n=0,1,23,.....9;

    1. Now how do i store this complex numbers into an array using Java?

    I prefer using a "for" loop
    for (int n=0, n<10,n++){

    But i know Java don't recognize "i" which is sqrt(-1). How to go about creating a Z array then?

    2. Next, how do i find the product of Z*T; lets say Z is saved as "nx1" vector (matrix) and T is saved as "1xn" vector (matrix)? I want the result to be "nxn" matrix.

    I have looked at Michael Flanagan's Java library on Complex (Michael Thomas Flanagan's Java Scientific and Numerical Library), but still can't figure out. Any suggestions would be greatly appreciated.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,692 Times in 2,642 Posts

    Default Re: Complex Numbers in Java

    You've sort of hidden you posting in the Member Introduction part of the forum.
    I have no mathematical training and can't help you with the theory part of your problem.
    I don't know of any complex number classes in Java, but there could be some. Java is continually adding new classes.

    Only suggestion is to use Google and see what comes up.

Similar Threads

  1. Display prime numbers from 100 to 200 in Java
    By c.P.u1 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: January 25th, 2011, 03:14 PM
  2. [SOLVED] Very complex project. It's hard to explain.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 55
    Last Post: November 4th, 2010, 11:30 AM
  3. Java Question Need Help Restarting the Values of Variables from Random Numbers So Out
    By JavaStudent1990 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 24th, 2010, 02:25 PM
  4. How do you design a complex program
    By mydarkpassenger in forum Java Theory & Questions
    Replies: 5
    Last Post: March 19th, 2010, 06:52 PM
  5. Replies: 2
    Last Post: February 19th, 2010, 08:10 AM