Project

General

Profile

Actions

Feature #1316

closed

Phasor.rb: Complex number class using polar coordinates

Added by peterhil (Peter Hillerström) about 13 years ago. Updated over 10 years ago.

Status:
Rejected
Priority:
Normal
Target version:
[ruby-core:23022]

Description

=begin
Hello!

I am writing a sound synthesis program, and I needed a way to easily generate and manipulate complex sound samples (analytic signal), so I wrote a new class by adapting the Ruby Complex Number class by Keiju ISHITSUKA to make calculations using polar coordinates.

I know the complex number class in 1.9 is written in C, but I hope this would inspire someone to make a C version using polar coordinates too... Anyway, do what you wish with this. As I mainly needed to multiply and add phasors with scalars, some methods may have bugs or inaccuracies with complex arguments. There are still some weirdness in substraction (2 tests fail), and most of the trigonometry functions are absent.

I tried to use svn diff to make a patch file out of the class, but that didn't work as expected - diff didn't see my file at all, but instead tried to diff against several other files, so I will just attach the file and unit tests here.

Sincerely,
Peter H.
=end


Files

phasor.rb (10.4 KB) phasor.rb Phasor.rb: Complex number class using polar coordinates peterhil (Peter Hillerström), 03/26/2009 04:58 PM
test_phasor.rb (7.61 KB) test_phasor.rb peterhil (Peter Hillerström), 03/26/2009 04:58 PM
Actions #1

Updated by marcandre (Marc-Andre Lafortune) over 12 years ago

  • Assignee set to matz (Yukihiro Matsumoto)
  • Priority changed from Normal to 3

=begin

=end

Actions #2

Updated by mame (Yusuke Endoh) about 12 years ago

  • Target version set to 2.0.0

=begin

=end

Actions #3

Updated by shyouhei (Shyouhei Urabe) over 11 years ago

  • Status changed from Open to Assigned

=begin

=end

Updated by ko1 (Koichi Sasada) almost 11 years ago

  • Assignee changed from matz (Yukihiro Matsumoto) to mrkn (Kenta Murata)

mrkn, what do you think about it?

Updated by mame (Yusuke Endoh) over 10 years ago

Hello mrkn,

Bumping this. Please let us know your opinion.

IMHO, it is not Ruby way to define another class that has the same set
of methods and different representation. That's like defining a "List"
class for "Array."

But part of me also is purely interested in the feature.

--
Yusuke Endoh

Updated by mrkn (Kenta Murata) over 10 years ago

  • Status changed from Assigned to Rejected

I think these features are provided as a gem.

Actions

Also available in: Atom PDF