/*
* The Spar Library - modular math parser
* Copyright (C) 2000,2001 Davide Angelocola <davide178@inwind.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef _sl_complex_h
#define _sl_complex_h
struct complex_s
{
double c[2];
};
typedef struct complex_s sl_complex;
#define SL_COMPLEX_RE(x) ((x).c[0])
#define SL_COMPLEX_IM(x) ((x).c[1])
#define SL_COMPLEX_P(p) ((p)->c)
#define SL_COMPLEX_P_RE(p) ((p)->c[0])
#define SL_COMPLEX_P_IM(p) ((p)->c[1])
#define SL_COMPLEX(x,re,im) sl_complex (x); \
SL_COMPLEX_RE(x) = re; \
SL_COMPLEX_IM(x) = im;
#include <spar/sl_conf.h>
__BEGIN_DECLS
/*
* Complex math operators
*
* there are three version for each operator:
*
* 1. complex and complex (no postfix)
* 2. complex and real (_real postfix)
* 3. complex and imag (_imag postfix)
*/
sl_complex sl_complex_add (sl_complex x, sl_complex y);
sl_complex sl_complex_add_real (sl_complex, double x);
sl_complex sl_complex_add_imag (sl_complex, double i);
sl_complex sl_complex_sub (sl_complex x, sl_complex y);
sl_complex sl_complex_sub_real (sl_complex x, double r);
sl_complex sl_complex_sub_imag (sl_complex x, double i);
sl_complex sl_complex_mul (sl_complex x, sl_complex y);
sl_complex sl_complex_mul_real (sl_complex x, double r);
sl_complex sl_complex_mul_imag (sl_complex x, double i);
sl_complex sl_complex_div (sl_complex x, sl_complex y);
sl_complex sl_complex_conjugate (sl_complex x);
sl_complex sl_complex_negative (sl_complex x);
double sl_complex_abs (sl_complex x);
double sl_complex_abs_2 (sl_complex x);
double sl_complex_arg (sl_complex x);
/*
* Complex utils
*/
sl_complex sl_complex_def (double x, double y);
sl_complex sl_complex_polar (double r, double theta);
void sl_complex_write (const sl_complex c);
void sl_complex_writeln (const sl_complex c);
void sl_complex_write_with_message (const char *msg, const sl_complex c);
void sl_complex_writeln_with_message (const char *msg, const sl_complex c);
void sl_complex_swap (sl_complex * c1, sl_complex * c2);
bool sl_complex_is_equal (sl_complex c1, sl_complex c2);
bool sl_complex_is_equal_p (sl_complex * c1, sl_complex * c2);
bool sl_complex_is_not_equal (sl_complex c1, sl_complex c2);
bool sl_complex_is_not_equal_p (sl_complex * c1, sl_complex * c2);
/*
* Complex trig
*/
sl_complex sl_complex_sin (sl_complex z);
sl_complex sl_complex_cos (sl_complex z);
sl_complex sl_complex_tan (sl_complex z);
/*
* Complex inverse trig
*/
sl_complex sl_complex_asin (sl_complex z);
sl_complex sl_complex_acos (sl_complex z);
sl_complex sl_complex_atan (sl_complex z);
/*
* Complex hyperbolic
*/
sl_complex sl_complex_sinh (sl_complex z);
sl_complex sl_complex_cosh (sl_complex z);
sl_complex sl_complex_tanh (sl_complex z);
/*
* Complex inverse hyperbolic
*/
sl_complex sl_complex_asinh (sl_complex z);
sl_complex sl_complex_acosh (sl_complex z);
sl_complex sl_complex_atanh (sl_complex z);
/*
* Complex exp
*/
sl_complex sl_complex_log (sl_complex z);
sl_complex sl_complex_exp (sl_complex z);
sl_complex sl_complex_sqrt (sl_complex z);
__END_DECLS
#endif /* _sl_complex_h_ */
syntax highlighted by Code2HTML, v. 0.9.1