Add all the A tasks

This commit is contained in:
Ingy döt Net 2013-04-10 14:58:50 -07:00
parent 2dd7375f96
commit 051504d65b
1608 changed files with 18584 additions and 0 deletions

View file

@ -0,0 +1,14 @@
require 'complex' # With Ruby 1.9, this line is optional.
# Two ways to write complex numbers:
a = Complex(1, 1) # 1. call Kernel#Complex
i = Complex::I # 2. use Complex::I
b = 3.14159 + 1.25 * i
# Operations:
puts a + b # addition
puts a * b # multiplication
puts -a # negation
puts 1.quo a # multiplicative inverse
puts a.conjugate # complex conjugate
puts a.conj # alias for complex conjugate

View file

@ -0,0 +1,4 @@
# Other ways to find the multiplicative inverse:
puts 1.quo a # always works
puts 1.0 / a # works, but forces floating-point math
puts 1 / a # might truncate to integer