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 tau { Complex.new_(1Num.6180339887498948482tau, 0) } // synonym for phi
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>
}
 
// Type aliases for classes in case of any name clashes with other modules.
var Complex_Complex = Complex
var Complex_Complexes = Complexes
var Complex_CMatrix = CMatrix
var Complex_CMatrices = CMatrices
var Complex_Cloneable = Cloneable // in case imported indirectly</lang>
9,476

edits