From 9ee4064c46a4637f4866fa3f53760e565beaca13 Mon Sep 17 00:00:00 2001 From: pnenzi Date: Wed, 13 Aug 2003 13:00:12 +0000 Subject: [PATCH] Added more separation between sparse and the rest of the package. --- src/include/smpdefs.h | 3 ++- src/include/sperror.h | 2 +- src/maths/sparse/spconfig.h | 2 +- src/maths/sparse/spdefs.h | 28 +++++++++++++++++++++++----- src/maths/sparse/spsmp.c | 3 +-- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/include/smpdefs.h b/src/include/smpdefs.h index a051b2ad0..a1f7432a2 100644 --- a/src/include/smpdefs.h +++ b/src/include/smpdefs.h @@ -10,8 +10,9 @@ Author: 1985 Thomas L. Quarles Modified: 2000 AlansFixes **********/ -#include "complex.h" #include +#include +#include int SMPaddElt( SMPmatrix *, int , int , double ); double * SMPmakeElt( SMPmatrix * , int , int ); diff --git a/src/include/sperror.h b/src/include/sperror.h index d3ef2f3b6..90ff028b3 100644 --- a/src/include/sperror.h +++ b/src/include/sperror.h @@ -6,7 +6,7 @@ Author: 1985 Thomas L. Quarles #ifndef _SPERROR_H #define _SPERROR_H -#include "ngspice.h" +//#include "ngspice.h" #include "iferrmsg.h" /* diff --git a/src/maths/sparse/spconfig.h b/src/maths/sparse/spconfig.h index c2e2bc11f..dfbc8f6f9 100644 --- a/src/maths/sparse/spconfig.h +++ b/src/maths/sparse/spconfig.h @@ -378,7 +378,7 @@ * Grab from Spice include files */ -#include "ngspice.h" +// #include "ngspice.h" #define MACHINE_RESOLUTION DBL_EPSILON #define LARGEST_REAL DBL_MAX #define SMALLEST_REAL DBL_MIN diff --git a/src/maths/sparse/spdefs.h b/src/maths/sparse/spdefs.h index 0e11ab5ba..f13f42511 100644 --- a/src/maths/sparse/spdefs.h +++ b/src/maths/sparse/spdefs.h @@ -38,13 +38,15 @@ * IMPORTS */ -#include #include +#include "complex.h" #undef ABORT #undef MALLOC #undef FREE #undef REALLOC +#undef CMPLX_MULT +#undef CMPLX_RECIPROCAL @@ -58,9 +60,13 @@ /* Begin macros. */ +/* Boolean data type */ +#define BOOLEAN int #define NO 0 #define YES 1 - +#define NOT ! +#define AND && +#define OR || #define SPARSE_ID 0x772773 /* Arbitrary (is Sparse on phone). */ #define IS_SPARSE(matrix) ((matrix) != NULL && \ @@ -248,6 +254,20 @@ (from_a).Imag * (from_b).Real; \ } +/* Complex reciprocation: to = 1.0 / den */ +#define CMPLX_RECIPROCAL(to,den) \ +{ RealNumber r_; \ + if (((den).Real >= (den).Imag AND (den).Real > -(den).Imag) OR \ + ((den).Real < (den).Imag AND (den).Real <= -(den).Imag)) \ + { r_ = (den).Imag / (den).Real; \ + (to).Imag = -r_*((to).Real = 1.0/((den).Real + r_*(den).Imag)); \ + } \ + else \ + { r_ = (den).Real / (den).Imag; \ + (to).Real = -r_*((to).Imag = -1.0/((den).Imag + r_*(den).Real));\ + } \ +} + #define ALLOC(type,number) ((type *)tmalloc((unsigned)(sizeof(type)*(number)))) #define REALLOC(ptr,type,number) \ @@ -267,9 +287,7 @@ } #endif -#include "complex.h" - - +#include "defines.h" /* diff --git a/src/maths/sparse/spsmp.c b/src/maths/sparse/spsmp.c index eab788435..5226ac5ec 100644 --- a/src/maths/sparse/spsmp.c +++ b/src/maths/sparse/spsmp.c @@ -95,15 +95,14 @@ */ #include -#include #include #include #include +#include "spdefs.h" #include -#include "spdefs.h" static void LoadGmin(SMPmatrix *eMatrix, double Gmin);