Note: This is taken from the Chicken Wiki, where a more recent version could be available.
Support for complex numbers in chicken.
This library provides new versions of all numeric operations. Specifically, the following standard procedures are re-implemented:
abs complex? number? real? rational? integer? exact? inexact? zero? positive? odd? even? = < > <= >= max min + - * / quotient remainder modulo gcd lcm floor ceiling truncate round exact->inexact inexact->exact number->string string->number exp log sin cos tan asin acos atan sqrt expt
The library also provides the following definitions:
<procedure>(conj COMPLEX)</procedure>
Computes the conjugate of COMPLEX.
<constant>i</constant> <constant>-i</constant> <constant>j</constant> <constant>-j</constant>
Handy numeric values.
Note: If this library is used in compiled code, the option -usual-integrations and the declaration standard-bindings (implied by -O2) will replace invocations of numeric standard procedures with open-coded versions that support only the basic numeric types provided by the Chicken system. If you use the complex extension and compile with -O2, then add declarations that mark the used numeric primitives to disable in-lining:
<example> <init>(use complex)</init> <expr> (declare
(not standard-bindings sin number->string) )
(number→string (sin i)) </expr> <result> "0.+1.1752011936438i" </result> </example>
(This has been fixed in Chicken version 1.72 and higher)
Copyright (c) 2004 by Thomas Christian Chust All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.