     static var epsilon:Self { get }
 }
 // protocol extension !!!
-extension RealType {
+public extension RealType {
     /// self * 1.0i
-    var i:Complex<Self>{ return Complex(Self(0), self) }
+    public var i:Complex<Self>{ return Complex(Self(0), self) }
 }
 // Double is default since floating-point literals are Double by default
 extension Double : RealType {
-    static func abs(x:Double)->Double { return abs(x) }
+    public static func abs(x:Double)->Double { return abs(x) }
     #if os(Linux)
-    static func cos(x:Double)->Double { return Glibc.cos(x) }
-    static func exp(x:Double)->Double { return Glibc.exp(x) }
-    static func log(x:Double)->Double { return Glibc.log(x) }
-    static func sin(x:Double)->Double { return Glibc.sin(x) }
-    static func sqrt(x:Double)->Double { return Glibc.sqrt(x) }
-    static func hypot(x:Double, _ y:Double)->Double { return Glibc.hypot(x, y) }
-    static func atan2(y:Double, _ x:Double)->Double { return Glibc.atan2(y, x) }
-    static func pow(x:Double, _ y:Double)->Double { return Glibc.pow(x, y) }
+    public static func cos(x:Double)->Double { return Glibc.cos(x) }
+    public static func exp(x:Double)->Double { return Glibc.exp(x) }
+    public static func log(x:Double)->Double { return Glibc.log(x) }
+    public static func sin(x:Double)->Double { return Glibc.sin(x) }
+    public static func sqrt(x:Double)->Double { return Glibc.sqrt(x) }
+    public static func hypot(x:Double, _ y:Double)->Double { return Glibc.hypot(x, y) }
+    public static func atan2(y:Double, _ x:Double)->Double { return Glibc.atan2(y, x) }
+    public static func pow(x:Double, _ y:Double)->Double { return Glibc.pow(x, y) }
     #else
-    static func cos(x:Double)->Double { return Foundation.cos(x) }
-    static func exp(x:Double)->Double { return Foundation.exp(x) }
-    static func log(x:Double)->Double { return Foundation.log(x) }
-    static func sin(x:Double)->Double { return Foundation.sin(x) }
-    static func sqrt(x:Double)->Double { return Foundation.sqrt(x) }
-    static func hypot(x:Double, _ y:Double)->Double { return Foundation.hypot(x, y) }
-    static func atan2(y:Double, _ x:Double)->Double { return Foundation.atan2(y, x) }
-    static func pow(x:Double, _ y:Double)->Double { return Foundation.pow(x, y) }
+    public static func cos(x:Double)->Double { return Foundation.cos(x) }
+    public static func exp(x:Double)->Double { return Foundation.exp(x) }
+    public static func log(x:Double)->Double { return Foundation.log(x) }
+    public static func sin(x:Double)->Double { return Foundation.sin(x) }
+    public static func sqrt(x:Double)->Double { return Foundation.sqrt(x) }
+    public static func hypot(x:Double, _ y:Double)->Double { return Foundation.hypot(x, y) }
+    public static func atan2(y:Double, _ x:Double)->Double { return Foundation.atan2(y, x) }
+    public static func pow(x:Double, _ y:Double)->Double { return Foundation.pow(x, y) }
     #endif
     // these ought to be static let
     // but give users a chance to overwrite it
-    static var PI = 3.14159265358979323846264338327950288419716939937510
-    static var π = PI
-    static var E =  2.718281828459045235360287471352662497757247093699
-    static var e = E
-    static var LN2 =
+    public static var PI = 3.14159265358979323846264338327950288419716939937510
+    public static var π = PI
+    public static var E =  2.718281828459045235360287471352662497757247093699
+    public static var e = E
+    public static var LN2 =
     0.6931471805599453094172321214581765680755001343602552
-    static var LOG2E = 1 / LN2
-    static var LN10 =
+    public static var LOG2E = 1 / LN2
+    public static var LN10 =
     2.3025850929940456840179914546843642076011014886287729
-    static var LOG10E = 1/LN10
-    static var SQRT2 =
+    public static var LOG10E = 1/LN10
+    public static var SQRT2 =
     1.4142135623730950488016887242096980785696718753769480
-    static var SQRT1_2 = 1/SQRT2
-    static var epsilon = 0x1p-52
+    public static var SQRT1_2 = 1/SQRT2
+    public static var epsilon = 0x1p-52
 }
 // But when explicitly typed you can use Float
 extension Float : RealType {
-    static func abs(x:Float)->Float { return abs(x) }
+    public static func abs(x:Float)->Float { return abs(x) }
     #if os(Linux)
-    static func cos(x:Float)->Float { return Glibc.cosf(x) }
-    static func exp(x:Float)->Float { return Glibc.expf(x) }
-    static func log(x:Float)->Float { return Glibc.logf(x) }
-    static func sin(x:Float)->Float { return Glibc.sinf(x) }
-    static func sqrt(x:Float)->Float { return Glibc.sqrtf(x) }
-    static func hypot(x:Float, _ y:Float)->Float { return Glibc.hypotf(x, y) }
-    static func atan2(y:Float, _ x:Float)->Float { return Glibc.atan2f(y, x) }
-    static func pow(x:Float, _ y:Float)->Float { return Glibc.powf(x, y) }
+    public static func cos(x:Float)->Float { return Glibc.cosf(x) }
+    public static func exp(x:Float)->Float { return Glibc.expf(x) }
+    public static func log(x:Float)->Float { return Glibc.logf(x) }
+    public static func sin(x:Float)->Float { return Glibc.sinf(x) }
+    public static func sqrt(x:Float)->Float { return Glibc.sqrtf(x) }
+    public static func hypot(x:Float, _ y:Float)->Float { return Glibc.hypotf(x, y) }
+    public static func atan2(y:Float, _ x:Float)->Float { return Glibc.atan2f(y, x) }
+    public static func pow(x:Float, _ y:Float)->Float { return Glibc.powf(x, y) }
     #else
-    static func cos(x:Float)->Float { return Foundation.cosf(x) }
-    static func exp(x:Float)->Float { return Foundation.expf(x) }
-    static func log(x:Float)->Float { return Foundation.logf(x) }
-    static func sin(x:Float)->Float { return Foundation.sinf(x) }
-    static func sqrt(x:Float)->Float { return Foundation.sqrtf(x) }
-    static func hypot(x:Float, _ y:Float)->Float { return Foundation.hypotf(x, y) }
-    static func atan2(y:Float, _ x:Float)->Float { return Foundation.atan2f(y, x) }
-    static func pow(x:Float, _ y:Float)->Float { return Foundation.powf(x, y) }
+    public static func cos(x:Float)->Float { return Foundation.cosf(x) }
+    public static func exp(x:Float)->Float { return Foundation.expf(x) }
+    public static func log(x:Float)->Float { return Foundation.logf(x) }
+    public static func sin(x:Float)->Float { return Foundation.sinf(x) }
+    public static func sqrt(x:Float)->Float { return Foundation.sqrtf(x) }
+    public static func hypot(x:Float, _ y:Float)->Float { return Foundation.hypotf(x, y) }
+    public static func atan2(y:Float, _ x:Float)->Float { return Foundation.atan2f(y, x) }
+    public static func pow(x:Float, _ y:Float)->Float { return Foundation.powf(x, y) }
     #endif
     // these ought to be static let
     // but give users a chance to overwrite it
-    static var PI:Float = 3.14159265358979323846264338327950288419716939937510
-    static var π:Float = PI
-    static var E:Float =  2.718281828459045235360287471352662497757247093699
-    static var e:Float = E
-    static var LN2:Float =
+    public static var PI:Float = 3.14159265358979323846264338327950288419716939937510
+    public static var π:Float = PI
+    public static var E:Float =  2.718281828459045235360287471352662497757247093699
+    public static var e:Float = E
+    public static var LN2:Float =
     0.6931471805599453094172321214581765680755001343602552
-    static var LOG2E:Float = 1 / LN2
-    static var LN10:Float =
+    public static var LOG2E:Float = 1 / LN2
+    public static var LN10:Float =
     2.3025850929940456840179914546843642076011014886287729
-    static var LOG10E:Float = 1/LN10
-    static var SQRT2:Float =
+    public static var LOG10E:Float = 1/LN10
+    public static var SQRT2:Float =
     1.4142135623730950488016887242096980785696718753769480
-    static var SQRT1_2:Float = 1/SQRT2
-    static var epsilon:Float = 0x1p-23
+    public static var SQRT1_2:Float = 1/SQRT2
+    public static var epsilon:Float = 0x1p-23
 }
 // el corazon
-struct Complex<T:RealType> : Equatable, CustomStringConvertible, Hashable {
-    var (re, im): (T, T)
-    init(_ re:T, _ im:T) {
+public struct Complex<T:RealType> : Equatable, CustomStringConvertible, Hashable {
+    public var (re, im): (T, T)
+    public init(_ re:T, _ im:T) {
         self.re = re
         self.im = im
     }
-    init(){ self.init(T(0), T(0)) }
-    init(abs:T, arg:T) {
+    public init(){ self.init(T(0), T(0)) }
+    public init(abs:T, arg:T) {
         self.re = abs * T.cos(arg)
         self.im = abs * T.sin(arg)
     }
     /// real part thereof
-    var real:T { get{ return re } set(r){ re = r } }
+    public var real:T { get{ return re } set(r){ re = r } }
     /// imaginary part thereof
-    var imag:T { get{ return im } set(i){ im = i } }
+    public var imag:T { get{ return im } set(i){ im = i } }
     /// absolute value thereof
-    var abs:T {
+    public var abs:T {
         get { return T.hypot(re, im) }
         set(r){ let f = r / abs; re *= f; im *= f }
     }
     /// argument thereof
-    var arg:T  {
+    public var arg:T  {
         get { return T.atan2(im, re) }
         set(t){ let m = abs; re = m * T.cos(t); im = m * T.sin(t) }
     }
     /// norm thereof
-    var norm:T { return T.hypot(re, im) }
+    public var norm:T { return T.hypot(re, im) }
     /// conjugate thereof
-    var conj:Complex { return Complex(re, -im) }
+    public var conj:Complex { return Complex(re, -im) }
     /// projection thereof
-    var proj:Complex {
+    public var proj:Complex {
         if re.isFinite && im.isFinite {
             return self
         } else {

infix operator =~ { associativity none precedence 130 }
infix operator !~ { associativity none precedence 130 }
// != is auto-generated thanks to Equatable
func == <T>(lhs:Complex<T>, rhs:Complex<T>) -> Bool {
    return lhs.re == rhs.re && lhs.im == rhs.im
}
func == <T>(lhs:Complex<T>, rhs:T) -> Bool {
    return lhs.re == rhs && lhs.im == T(0)
}
func == <T>(lhs:T, rhs:Complex<T>) -> Bool {
    return rhs.re == lhs && rhs.im == T(0)
}
// +, +=
prefix func + <T>(z:Complex<T>) -> Complex<T> {
    return z
}
func + <T>(lhs:Complex<T>, rhs:Complex<T>) -> Complex<T> {
    return Complex(lhs.re + rhs.re, lhs.im + rhs.im)
}
func + <T>(lhs:Complex<T>, rhs:T) -> Complex<T> {
    return lhs + Complex(rhs, T(0))
}
func + <T>(lhs:T, rhs:Complex<T>) -> Complex<T> {
    return Complex(lhs, T(0)) + rhs
}
func += <T>(inout lhs:Complex<T>, rhs:Complex<T>) {
    lhs.re += rhs.re ; lhs.im += rhs.im
}
func += <T>(inout lhs:Complex<T>, rhs:T) {
    lhs.re += rhs
}
// -, -=
prefix func - <T>(z:Complex<T>) -> Complex<T> {
    return Complex<T>(-z.re, -z.im)
}
func - <T>(lhs:Complex<T>, rhs:Complex<T>) -> Complex<T> {
    return Complex(lhs.re - rhs.re, lhs.im - rhs.im)
}
func - <T>(lhs:Complex<T>, rhs:T) -> Complex<T> {
    return lhs - Complex(rhs, T(0))
}
func - <T>(lhs:T, rhs:Complex<T>) -> Complex<T> {
    return Complex(lhs, T(0)) - rhs
}
func -= <T>(inout lhs:Complex<T>, rhs:Complex<T>) {
    lhs.re -= rhs.re ; lhs.im -= rhs.im
}
func -= <T>(inout lhs:Complex<T>, rhs:T) {
    lhs.re -= rhs
}
// *, *=
func * <T>(lhs:Complex<T>, rhs:Complex<T>) -> Complex<T> {
    return Complex(
        lhs.re * rhs.re - lhs.im * rhs.im,
        lhs.re * rhs.im + lhs.im * rhs.re
    )
}
func * <T>(lhs:Complex<T>, rhs:T) -> Complex<T> {
    return Complex(lhs.re * rhs, lhs.im * rhs)
}
func * <T>(lhs:T, rhs:Complex<T>) -> Complex<T> {
    return Complex(lhs * rhs.re, lhs * rhs.im)
}
func *= <T>(inout lhs:Complex<T>, rhs:Complex<T>) {
    lhs = lhs * rhs
}
func *= <T>(inout lhs:Complex<T>, rhs:T) {
    lhs = lhs * rhs
}
// /, /=
//
// cf. https://github.com/dankogai/swift-complex/issues/3
//
func / <T>(lhs:Complex<T>, rhs:Complex<T>) -> Complex<T> {
    if abs(rhs.re) >= abs(rhs.im) {
        let r = rhs.im / rhs.re
        let d = rhs.re + rhs.im * r

        
    }
}
public func / <T>(lhs:Complex<T>, rhs:T) -> Complex<T> {
    return Complex(lhs.re / rhs, lhs.im / rhs)
}
public func / <T>(lhs:T, rhs:Complex<T>) -> Complex<T> {
    return Complex(lhs, T(0)) / rhs
}
public func /= <T>(inout lhs:Complex<T>, rhs:Complex<T>) {
    lhs = lhs / rhs
}
public func /= <T>(inout lhs:Complex<T>, rhs:T) {
    lhs = lhs / rhs
}
// exp(z)
public func exp<T>(z:Complex<T>) -> Complex<T> {
    let abs = T.exp(z.re)
    let arg = z.im
    return Complex(abs * T.cos(arg), abs * T.sin(arg))
}
// log(z)
public func log<T>(z:Complex<T>) -> Complex<T> {
    return Complex(T.log(z.abs), z.arg)
}
// log10(z) -- just because C++ has it
public func log10<T>(z:Complex<T>) -> Complex<T> { return log(z) / T.log(T(10)) }
public func log10<T:RealType>(r:T) -> T { return T.log(r) / T.log(T(10)) }
// pow(b, x)
public func pow<T>(lhs:Complex<T>, _ rhs:Complex<T>) -> Complex<T> {
    if lhs == T(0) { return Complex(T(1), T(0)) } // 0 ** 0 == 1
    let z = log(lhs) * rhs
    return exp(z)
}
public func pow<T>(lhs:Complex<T>, _ rhs:T) -> Complex<T> {
    return pow(lhs, Complex(rhs, T(0)))
}
public func pow<T>(lhs:T, _ rhs:Complex<T>) -> Complex<T> {
    return pow(Complex(lhs, T(0)), rhs)
}
// **, **=
public func **<T:RealType>(lhs:T, rhs:T) -> T {
    return T.pow(lhs, rhs)
}
public func ** <T>(lhs:Complex<T>, rhs:Complex<T>) -> Complex<T> {
    return pow(lhs, rhs)
}
public func ** <T>(lhs:T, rhs:Complex<T>) -> Complex<T> {
    return pow(lhs, rhs)
}
public func ** <T>(lhs:Complex<T>, rhs:T) -> Complex<T> {
    return pow(lhs, rhs)
}
public func **= <T:RealType>(inout lhs:T, rhs:T) {
    lhs = T.pow(lhs, rhs)
}
public func **= <T>(inout lhs:Complex<T>, rhs:Complex<T>) {
    lhs = pow(lhs, rhs)
}
public func **= <T>(inout lhs:Complex<T>, rhs:T) {
    lhs = pow(lhs, rhs)
}
// sqrt(z)
public func sqrt<T>(z:Complex<T>) -> Complex<T> {
    // return z ** 0.5
    let d = T.hypot(z.re, z.im)
    let r = T.sqrt((z.re + d)/T(2))
