Category talk:Wren-complex: Difference between revisions
→Source code: Removed type aliases and changed Complex.tau to be consistent with Num.tau.
(→Source code: Added support for complex matrices.) |
(→Source code: Removed type aliases and changed Complex.tau to be consistent with Num.tau.) |
||
Line 11:
<lang ecmascript>/* Module "complex.wren" */
import "./trait" for Cloneable
/* Complex represents a complex number of the form 'a + bi' where 'a' and 'b'
Line 43:
static pi { Complex.new_(Num.pi, 0) }
static e { Complex.new_(2.71828182845904523536, 0) }
static phi { Complex.new_(1.6180339887498948482, 0) } // golden ratio
▲ static tau { Complex.new_(1.6180339887498948482, 0) } // synonym for phi
static ln2 { Complex.new_(0.69314718055994530942, 0) } // 2.log
static ln10 { Complex.new_(2.30258509299404568402, 0) } // 10.log
Line 950:
static sum(a) { a.reduce { |acc, x| acc + x } }
static prod(a) { a[1..-1].reduce(a[0]) { |acc, x| acc * x } }
}</lang>
|