Added optimization for make-polar
original commit: fb31a6556e04d9aa6aa31c215394a80b9d146bd7
This commit is contained in:
parent
267e4c1e78
commit
4c41407d64
|
@ -0,0 +1,3 @@
|
|||
#lang typed/scheme #:optimize
|
||||
|
||||
(make-polar 0 0)
|
|
@ -0,0 +1,9 @@
|
|||
#lang typed/scheme #:optimize
|
||||
|
||||
(require racket/unsafe/ops)
|
||||
|
||||
;; top level
|
||||
(make-polar 1.0 1.0)
|
||||
|
||||
;; nested
|
||||
(+ 1.0+2.0i (make-polar 2.0 4.0))
|
|
@ -232,8 +232,20 @@
|
|||
#:with imag-binding (unboxed-gensym)
|
||||
#:with (bindings ...)
|
||||
(begin (log-optimization "make-rectangular elimination" #'op)
|
||||
#`(((real-binding) real.opt)
|
||||
#'(((real-binding) real.opt)
|
||||
((imag-binding) imag.opt))))
|
||||
(pattern (#%plain-app (~and op (~literal make-polar))
|
||||
r:float-coerce-expr theta:float-coerce-expr)
|
||||
#:with magnitude (unboxed-gensym)
|
||||
#:with angle (unboxed-gensym)
|
||||
#:with real-binding (unboxed-gensym)
|
||||
#:with imag-binding (unboxed-gensym)
|
||||
#:with (bindings ...)
|
||||
(begin (log-optimization "make-rectangular elimination" #'op)
|
||||
#'(((magnitude) r.opt)
|
||||
((angle) theta.opt)
|
||||
((real-binding) (unsafe-fl* magnitude (unsafe-flcos angle)))
|
||||
((imag-binding) (unsafe-fl* magnitude (unsafe-flsin angle))))))
|
||||
|
||||
;; if we see a variable that's already unboxed, use the unboxed bindings
|
||||
(pattern v:id
|
||||
|
@ -308,6 +320,16 @@
|
|||
(begin (log-optimization "unary inexact complex" #'op)
|
||||
#'(op.unsafe n.opt)))
|
||||
|
||||
(pattern (~and exp (#%plain-app (~and op (~literal make-polar)) r theta))
|
||||
#:when (isoftype? #'exp -InexactComplex)
|
||||
#:with exp*:unboxed-inexact-complex-opt-expr #'exp
|
||||
#:with opt
|
||||
(begin (log-optimization "make-polar" #'op)
|
||||
(reset-unboxed-gensym)
|
||||
#'(let*-values (exp*.bindings ...)
|
||||
(unsafe-make-flrectangular exp*.real-binding
|
||||
exp*.imag-binding))))
|
||||
|
||||
(pattern (~and e (#%plain-app op:id args:expr ...))
|
||||
#:with unboxed-info (dict-ref unboxed-funs-table #'op #f)
|
||||
#:when (syntax->datum #'unboxed-info)
|
||||
|
|
Loading…
Reference in New Issue
Block a user