If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
complex numbers in ruby
4 posts
• Page 1 of 1
complex numbers in ruby
input = array
In ruby:
1.
How to convert array into array of complex numbers? (is this handled as one "object"?) I mean - from what I see, ruby is handling complex numbers as single objects, but I don't know to what degree.
2.
How to multiply (and other operations) array of complex numbers through a number and through another array of complex numbers? (items with the same indexes, so resulting array has the same size)) I mean - is it working the same wah as with real numbers?
3.
How to split the number / array of complex numbers into real part on out1 and img part on out2?
In ruby:
1.
How to convert array into array of complex numbers? (is this handled as one "object"?) I mean - from what I see, ruby is handling complex numbers as single objects, but I don't know to what degree.
2.
How to multiply (and other operations) array of complex numbers through a number and through another array of complex numbers? (items with the same indexes, so resulting array has the same size)) I mean - is it working the same wah as with real numbers?
3.
How to split the number / array of complex numbers into real part on out1 and img part on out2?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: complex numbers in ruby
All methods and behaviour of complex numbers explained in detail here:
http://ruby-doc.org/core-1.9.3/Complex.html
http://ruby-doc.org/core-1.9.3/Complex.html
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: complex numbers in ruby
tester wrote:input = array
In ruby:
1.
How to convert array into array of complex numbers? (is this handled as one "object"?) I mean - from what I see, ruby is handling complex numbers as single objects, but I don't know to what degree.
real = [0.5,2.5,3.8]
imag = [10.5,20.5,30.8]
cplx = Array.new real.size
cplx.each_index {|idx| cplx[idx] = Complex(real[idx],imag[idx]) }
tester wrote:input = array
2.
How to multiply (and other operations) array of complex numbers through a number and through another array of complex numbers? (items with the same indexes, so resulting array has the same size)) I mean - is it working the same wah as with real numbers?
... normal ruby iterator
tester wrote:input = array
3.
How to split the number / array of complex numbers into real part on out1 and img part on out2?
real = cplx.collect{|i| i.real}
imag = cplx.collect{|i| i.imag}
- Tronic
- Posts: 539
- Joined: Wed Dec 21, 2011 12:59 pm
Re: complex numbers in ruby
Thanks Tronic!
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 34 guests