|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! @file slu_scomplex.h
|
|
kusano |
7d535a |
* \brief Header file for complex operations
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
* -- SuperLU routine (version 2.0) --
|
|
kusano |
7d535a |
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
|
|
kusano |
7d535a |
* and Lawrence Berkeley National Lab.
|
|
kusano |
7d535a |
* November 15, 1997
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
* Contains definitions for various complex operations.
|
|
kusano |
7d535a |
* This header file is to be included in source files c*.c
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
#ifndef __SUPERLU_SCOMPLEX /* allow multiple inclusions */
|
|
kusano |
7d535a |
#define __SUPERLU_SCOMPLEX
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#ifndef SCOMPLEX_INCLUDE
|
|
kusano |
7d535a |
#define SCOMPLEX_INCLUDE
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
typedef struct { float r, i; } complex;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Macro definitions */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Complex Addition c = a + b */
|
|
kusano |
7d535a |
#define c_add(c, a, b) { (c)->r = (a)->r + (b)->r; \
|
|
kusano |
7d535a |
(c)->i = (a)->i + (b)->i; }
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Complex Subtraction c = a - b */
|
|
kusano |
7d535a |
#define c_sub(c, a, b) { (c)->r = (a)->r - (b)->r; \
|
|
kusano |
7d535a |
(c)->i = (a)->i - (b)->i; }
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Complex-Double Multiplication */
|
|
kusano |
7d535a |
#define cs_mult(c, a, b) { (c)->r = (a)->r * (b); \
|
|
kusano |
7d535a |
(c)->i = (a)->i * (b); }
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Complex-Complex Multiplication */
|
|
kusano |
7d535a |
#define cc_mult(c, a, b) { \
|
|
kusano |
7d535a |
float cr, ci; \
|
|
kusano |
7d535a |
cr = (a)->r * (b)->r - (a)->i * (b)->i; \
|
|
kusano |
7d535a |
ci = (a)->i * (b)->r + (a)->r * (b)->i; \
|
|
kusano |
7d535a |
(c)->r = cr; \
|
|
kusano |
7d535a |
(c)->i = ci; \
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#define cc_conj(a, b) { \
|
|
kusano |
7d535a |
(a)->r = (b)->r; \
|
|
kusano |
7d535a |
(a)->i = -((b)->i); \
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Complex equality testing */
|
|
kusano |
7d535a |
#define c_eq(a, b) ( (a)->r == (b)->r && (a)->i == (b)->i )
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#ifdef __cplusplus
|
|
kusano |
7d535a |
extern "C" {
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Prototypes for functions in scomplex.c */
|
|
kusano |
7d535a |
void c_div(complex *, complex *, complex *);
|
|
kusano |
7d535a |
double c_abs(complex *); /* exact */
|
|
kusano |
7d535a |
double c_abs1(complex *); /* approximate */
|
|
kusano |
7d535a |
void c_exp(complex *, complex *);
|
|
kusano |
7d535a |
void r_cnjg(complex *, complex *);
|
|
kusano |
7d535a |
double r_imag(complex *);
|
|
kusano |
7d535a |
complex c_sgn(complex *);
|
|
kusano |
7d535a |
complex c_sqrt(complex *);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#ifdef __cplusplus
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#endif /* __SUPERLU_SCOMPLEX */
|