From 921de6ba3f70fbff7da284bf7648deb546e2b9b3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 31 May 2009 23:28:29 -0500 Subject: [PATCH] math.functions: fix ^ for complex numbers --- basis/math/functions/functions-tests.factor | 1 + basis/math/functions/functions.factor | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index 66d813bab8..0bdc6ce00b 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -162,3 +162,4 @@ IN: math.functions.tests [ 2.5 ] [ 1.0 2.5 1.0 lerp ] unit-test [ 1.75 ] [ 1.0 2.5 0.5 lerp ] unit-test +[ C{ 1 2 } ] [ C{ 1 2 } 1 ^ ] unit-test \ No newline at end of file diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index a1bf9480d5..5d88eba9fa 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -34,8 +34,9 @@ M: integer ^n M: ratio ^n [ >fraction ] dip [ ^n ] curry bi@ / ; -M: float ^n - (^n) ; +M: float ^n (^n) ; + +M: complex ^n (^n) ; : integer^ ( x y -- z ) dup 0 > [ ^n ] [ neg ^n recip ] if ; inline