Blame complex/gsl_complex.h

Packit 67cb25
/* complex/gsl_complex.h
Packit 67cb25
 * 
Packit 67cb25
 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
Packit 67cb25
 * 
Packit 67cb25
 * This program is free software; you can redistribute it and/or modify
Packit 67cb25
 * it under the terms of the GNU General Public License as published by
Packit 67cb25
 * the Free Software Foundation; either version 3 of the License, or (at
Packit 67cb25
 * your option) any later version.
Packit 67cb25
 * 
Packit 67cb25
 * This program is distributed in the hope that it will be useful, but
Packit 67cb25
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 67cb25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 67cb25
 * General Public License for more details.
Packit 67cb25
 * 
Packit 67cb25
 * You should have received a copy of the GNU General Public License
Packit 67cb25
 * along with this program; if not, write to the Free Software
Packit 67cb25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 67cb25
 */
Packit 67cb25
Packit 67cb25
#ifndef __GSL_COMPLEX_H__
Packit 67cb25
#define __GSL_COMPLEX_H__
Packit 67cb25
Packit 67cb25
#undef __BEGIN_DECLS
Packit 67cb25
#undef __END_DECLS
Packit 67cb25
#ifdef __cplusplus
Packit 67cb25
# define __BEGIN_DECLS extern "C" {
Packit 67cb25
# define __END_DECLS }
Packit 67cb25
#else
Packit 67cb25
# define __BEGIN_DECLS /* empty */
Packit 67cb25
# define __END_DECLS /* empty */
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
__BEGIN_DECLS
Packit 67cb25
Packit 67cb25
Packit 67cb25
/* two consecutive built-in types as a complex number */
Packit 67cb25
typedef double *       gsl_complex_packed ;
Packit 67cb25
typedef float *        gsl_complex_packed_float  ;
Packit 67cb25
typedef long double *  gsl_complex_packed_long_double ;
Packit 67cb25
Packit 67cb25
typedef const double *       gsl_const_complex_packed ;
Packit 67cb25
typedef const float *        gsl_const_complex_packed_float  ;
Packit 67cb25
typedef const long double *  gsl_const_complex_packed_long_double ;
Packit 67cb25
Packit 67cb25
Packit 67cb25
/* 2N consecutive built-in types as N complex numbers */
Packit 67cb25
typedef double *       gsl_complex_packed_array ;
Packit 67cb25
typedef float *        gsl_complex_packed_array_float  ;
Packit 67cb25
typedef long double *  gsl_complex_packed_array_long_double ;
Packit 67cb25
Packit 67cb25
typedef const double *       gsl_const_complex_packed_array ;
Packit 67cb25
typedef const float *        gsl_const_complex_packed_array_float  ;
Packit 67cb25
typedef const long double *  gsl_const_complex_packed_array_long_double ;
Packit 67cb25
Packit 67cb25
Packit 67cb25
/* Yes... this seems weird. Trust us. The point is just that
Packit 67cb25
   sometimes you want to make it obvious that something is
Packit 67cb25
   an output value. The fact that it lacks a 'const' may not
Packit 67cb25
   be enough of a clue for people in some contexts.
Packit 67cb25
 */
Packit 67cb25
typedef double *       gsl_complex_packed_ptr ;
Packit 67cb25
typedef float *        gsl_complex_packed_float_ptr  ;
Packit 67cb25
typedef long double *  gsl_complex_packed_long_double_ptr ;
Packit 67cb25
Packit 67cb25
typedef const double *       gsl_const_complex_packed_ptr ;
Packit 67cb25
typedef const float *        gsl_const_complex_packed_float_ptr  ;
Packit 67cb25
typedef const long double *  gsl_const_complex_packed_long_double_ptr ;
Packit 67cb25
Packit 67cb25
Packit 67cb25
typedef struct
Packit 67cb25
  {
Packit 67cb25
    long double dat[2];
Packit 67cb25
  }
Packit 67cb25
gsl_complex_long_double;
Packit 67cb25
Packit 67cb25
typedef struct
Packit 67cb25
  {
Packit 67cb25
    double dat[2];
Packit 67cb25
  }
Packit 67cb25
gsl_complex;
Packit 67cb25
Packit 67cb25
typedef struct
Packit 67cb25
  {
Packit 67cb25
    float dat[2];
Packit 67cb25
  }
Packit 67cb25
gsl_complex_float;
Packit 67cb25
Packit 67cb25
#define GSL_REAL(z)     ((z).dat[0])
Packit 67cb25
#define GSL_IMAG(z)     ((z).dat[1])
Packit 67cb25
#define GSL_COMPLEX_P(zp) ((zp)->dat)
Packit 67cb25
#define GSL_COMPLEX_P_REAL(zp)  ((zp)->dat[0])
Packit 67cb25
#define GSL_COMPLEX_P_IMAG(zp)  ((zp)->dat[1])
Packit 67cb25
#define GSL_COMPLEX_EQ(z1,z2) (((z1).dat[0] == (z2).dat[0]) && ((z1).dat[1] == (z2).dat[1]))
Packit 67cb25
Packit 67cb25
#define GSL_SET_COMPLEX(zp,x,y) do {(zp)->dat[0]=(x); (zp)->dat[1]=(y);} while(0)
Packit 67cb25
#define GSL_SET_REAL(zp,x) do {(zp)->dat[0]=(x);} while(0)
Packit 67cb25
#define GSL_SET_IMAG(zp,y) do {(zp)->dat[1]=(y);} while(0)
Packit 67cb25
Packit 67cb25
#define GSL_SET_COMPLEX_PACKED(zp,n,x,y) do {*((zp)+2*(n))=(x); *((zp)+(2*(n)+1))=(y);} while(0)
Packit 67cb25
Packit 67cb25
__END_DECLS
Packit 67cb25
Packit 67cb25
#endif /* __GSL_COMPLEX_H__ */