kusano 7d535a
kusano 7d535a
/*! @file slu_dcomplex.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 z*.c
kusano 7d535a
 * 
kusano 7d535a
 */
kusano 7d535a
#ifndef __SUPERLU_DCOMPLEX /* allow multiple inclusions */
kusano 7d535a
#define __SUPERLU_DCOMPLEX
kusano 7d535a
kusano 7d535a
kusano 7d535a
#ifndef DCOMPLEX_INCLUDE
kusano 7d535a
#define DCOMPLEX_INCLUDE
kusano 7d535a
kusano 7d535a
typedef struct { double r, i; } doublecomplex;
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* Macro definitions */
kusano 7d535a
kusano 7d535a
/*! \brief Complex Addition c = a + b */
kusano 7d535a
#define z_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 z_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 zd_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 zz_mult(c, a, b) { \
kusano 7d535a
	double 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 zz_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 z_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 dcomplex.c */
kusano 7d535a
void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
kusano 7d535a
double z_abs(doublecomplex *);     /* exact */
kusano 7d535a
double z_abs1(doublecomplex *);    /* approximate */
kusano 7d535a
void z_exp(doublecomplex *, doublecomplex *);
kusano 7d535a
void d_cnjg(doublecomplex *r, doublecomplex *z);
kusano 7d535a
double d_imag(doublecomplex *);
kusano 7d535a
doublecomplex z_sgn(doublecomplex *);
kusano 7d535a
doublecomplex z_sqrt(doublecomplex *);
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_DCOMPLEX */