⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spdefs.h

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 H
📖 第 1 页 / 共 3 页
字号:
 * to another. to += mult_a * mult_b */#define  CMPLX_MULT_ADD_ASSIGN(to,from_a,from_b)        \{   (to).Real += (from_a).Real * (from_b).Real -        \                 (from_a).Imag * (from_b).Imag;         \    (to).Imag += (from_a).Real * (from_b).Imag +        \                 (from_a).Imag * (from_b).Real;         \}/* Macro function that multiplies two complex numbers and then subtracts them * from another. */#define  CMPLX_MULT_SUBT_ASSIGN(to,from_a,from_b)       \{   (to).Real -= (from_a).Real * (from_b).Real -        \                 (from_a).Imag * (from_b).Imag;         \    (to).Imag -= (from_a).Real * (from_b).Imag +        \                 (from_a).Imag * (from_b).Real;         \}/* Macro function that multiplies two complex numbers and then adds them * to the destination. to += from_a* * from_b where from_a* represents from_a * conjugate. */#define  CMPLX_CONJ_MULT_ADD_ASSIGN(to,from_a,from_b)   \{   (to).Real += (from_a).Real * (from_b).Real +        \                 (from_a).Imag * (from_b).Imag;         \    (to).Imag += (from_a).Real * (from_b).Imag -        \                 (from_a).Imag * (from_b).Real;         \}/* Macro function that multiplies two complex numbers and then subtracts them * from the destination. to -= from_a* * from_b where from_a* represents from_a * conjugate. */#define  CMPLX_CONJ_MULT_SUBT_ASSIGN(to,from_a,from_b)  \{   (to).Real -= (from_a).Real * (from_b).Real +        \                 (from_a).Imag * (from_b).Imag;         \    (to).Imag -= (from_a).Real * (from_b).Imag -        \                 (from_a).Imag * (from_b).Real;         \}/* * Macro functions that provide complex division. *//* Complex division:  to = num / den */#define CMPLX_DIV(to,num,den)                                           \{   RealNumber  r_, s_;                                                 \    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;                                   \        s_ = (den).Real + r_*(den).Imag;                                \        (to).Real = ((num).Real + r_*(num).Imag)/s_;                    \        (to).Imag = ((num).Imag - r_*(num).Real)/s_;                    \    }                                                                   \    else                                                                \    {   r_ = (den).Real / (den).Imag;                                   \        s_ = (den).Imag + r_*(den).Real;                                \        (to).Real = (r_*(num).Real + (num).Imag)/s_;                    \        (to).Imag = (r_*(num).Imag - (num).Real)/s_;                    \    }                                                                   \}/* Complex division and assignment:  num /= den */#define CMPLX_DIV_ASSIGN(num,den)                                       \{   RealNumber  r_, s_, t_;                                             \    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;                                   \        s_ = (den).Real + r_*(den).Imag;                                \        t_ = ((num).Real + r_*(num).Imag)/s_;                           \        (num).Imag = ((num).Imag - r_*(num).Real)/s_;                   \        (num).Real = t_;                                                \    }                                                                   \    else                                                                \    {   r_ = (den).Real / (den).Imag;                                   \        s_ = (den).Imag + r_*(den).Real;                                \        t_ = (r_*(num).Real + (num).Imag)/s_;                           \        (num).Imag = (r_*(num).Imag - (num).Real)/s_;                   \        (num).Real = t_;                                                \    }                                                                   \}/* Complex reciprocation:  to = 1.0 / den */#define CMPLX_RECIPROCAL(to,den)                                        \{   RealNumber  r_;                                                     \    if (((den).Real >= (den).Imag && (den).Real > -(den).Imag) ||       \        ((den).Real < (den).Imag && (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));\    }                                                                   \}/* Allocation */extern void * tmalloc(size_t);extern void * txfree(void *);extern void * trealloc(void *, size_t);#define ALLOC(type,number)  ((type *)tmalloc((size_t)(sizeof(type)*(number))))#define REALLOC(ptr,type,number)  \           ptr = (type *)trealloc((char *)ptr,(unsigned)(sizeof(type)*(number)))#define FREE(ptr) { if ((ptr) != NULL) txfree((char *)(ptr)); (ptr) = NULL; }/* A new calloc */#ifndef HAVE_LIBGC#define CALLOC(ptr,type,number)                    	     \{ ptr = (type *) calloc(number, sizeof(type)); 		             \}#else /* HAVE_LIBCG */#define CALLOC(ptr,type,number)                         	\{ ptr = (type *) tmalloc(((size_t)number) * sizeof(type));	\}#endif#include "defines.h"/* *  MATRIX ELEMENT DATA STRUCTURE * *  Every nonzero element in the matrix is stored in a dynamically allocated *  MatrixElement structure.  These structures are linked together in an *  orthogonal linked list.  Two different MatrixElement structures exist. *  One is used when only real matrices are expected, it is missing an entry *  for imaginary data.  The other is used if complex matrices are expected. *  It contains an entry for imaginary data. * *  >>> Structure fields: *  Real  (RealNumber) *      The real portion of the value of the element.  Real must be the first *      field in this structure. *  Imag  (RealNumber) *      The imaginary portion of the value of the element. If the matrix *      routines are not compiled to handle complex matrices, then this *      field does not exist.  If it exists, it must follow immediately after *      Real. *  Row  (int) *      The row number of the element. *  Col  (int) *      The column number of the element. *  NextInRow  (struct MatrixElement *) *      NextInRow contains a pointer to the next element in the row to the *      right of this element.  If this element is the last nonzero in the *      row then NextInRow contains NULL. *  NextInCol  (struct MatrixElement *) *      NextInCol contains a pointer to the next element in the column below *      this element.  If this element is the last nonzero in the column then *      NextInCol contains NULL. *  pInitInfo  (char *) *      Pointer to user data used for initialization of the matrix element. *      Initialized to NULL. * *  >>> Type definitions: *  ElementPtr *      A pointer to a MatrixElement. *  ArrayOfElementPtrs *      An array of ElementPtrs.  Used for FirstInRow, FirstInCol and *      Diag pointer arrays. *//* Begin `MatrixElement'. */struct  MatrixElement{    RealNumber   Real;    RealNumber   Imag;    int          Row;    int          Col;    struct MatrixElement  *NextInRow;    struct MatrixElement  *NextInCol;#if INITIALIZE    char        *pInitInfo;#endif};typedef  struct MatrixElement  *ElementPtr;typedef  ElementPtr  *ArrayOfElementPtrs;/* *  ALLOCATION DATA STRUCTURE * *  The sparse matrix routines keep track of all memory that is allocated by *  the operating system so the memory can later be freed.  This is done by *  saving the pointers to all the chunks of memory that are allocated to a *  particular matrix in an allocation list.  That list is organized as a *  linked list so that it can grow without a priori bounds. * *  >>> Structure fields: *  AllocatedPtr  (char *) *      Pointer to chunk of memory that has been allocated for the matrix. *  NextRecord  (struct  AllocationRecord *) *      Pointer to the next allocation record. *//* Begin `AllocationRecord'. */struct AllocationRecord{    char  *AllocatedPtr;    struct  AllocationRecord  *NextRecord;};typedef  struct  AllocationRecord  *AllocationListPtr;/* *  FILL-IN LIST DATA STRUCTURE * *  The sparse matrix routines keep track of all fill-ins separately from *  user specified elements so they may be removed by spStripFills().  Fill-ins *  are allocated in bunched in what is called a fill-in lists.  The data *  structure defined below is used to organize these fill-in lists into a *  linked-list. * *  >>> Structure fields: *  pFillinList  (ElementPtr) *      Pointer to a fill-in list, or a bunch of fill-ins arranged contiguously *      in memory. *  NumberOfFillinsInList  (int) *      Seems pretty self explanatory to me. *  Next  (struct  FillinListNodeStruct *) *      Pointer to the next fill-in list structures. *//* Begin `FillinListNodeStruct'. */struct FillinListNodeStruct{    ElementPtr  pFillinList;    int         NumberOfFillinsInList;    struct      FillinListNodeStruct  *Next;};/* Similar to above, but keeps track of the original Elements *//* Begin `ElementListNodeStruct'. */struct ElementListNodeStruct{    ElementPtr  pElementList;    int         NumberOfElementsInList;    struct      ElementListNodeStruct  *Next;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -