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

📄 spdefs.h

📁 spice中支持多层次元件模型仿真的可单独运行的插件源码
💻 H
📖 第 1 页 / 共 3 页
字号:
/* *  DATA STRUCTURE AND MACRO DEFINITIONS for Sparse. * *  Author:                     Advising professor: *      Kenneth S. Kundert          Alberto Sangiovanni-Vincentelli *      UC Berkeley * *  This file contains common type definitions and macros for the sparse *  matrix routines.  These definitions are of no interest to the user. *//* *  Revision and copyright information. * *  Copyright (c) 1985,86,87,88,89,90 *  by Kenneth S. Kundert and the University of California. * *  Permission to use, copy, modify, and distribute this software and *  its documentation for any purpose and without fee is hereby granted, *  provided that the copyright notices appear in all copies and *  supporting documentation and that the authors and the University of *  California are properly credited.  The authors and the University of *  California make no representations as to the suitability of this *  software for any purpose.  It is provided `as is', without express *  or implied warranty. * *  $Date: 88/06/18 11:13:40 $ *  $Revision: 1.2 $ *//* *  IMPORTS */#include <stdio.h>#include "misc.h"/* *  If running lint, change some of the compiler options to get a more *  complete inspection. */#ifdef lint#undef  REAL#undef  spCOMPLEX#undef  EXPANDABLE#undef  TRANSLATE#undef  INITIALIZE#undef  DELETE#undef  STRIP#undef  MODIFIED_NODAL#undef  QUAD_ELEMENT#undef  TRANSPOSE#undef  SCALING#undef  DOCUMENTATION#undef  MULTIPLICATION#undef  DETERMINANT#undef  CONDITION#undef  PSEUDOCONDITION#undef  FORTRAN#undef  DEBUG#undef  spCOMPATIBILITY#define  REAL                           YES#define  spCOMPLEX                      YES#define  EXPANDABLE                     YES#define  TRANSLATE                      YES#define  INITIALIZE                     YES#define  DELETE                         YES#define  STRIP                          YES#define  MODIFIED_NODAL                 YES#define  QUAD_ELEMENT                   YES#define  TRANSPOSE                      YES#define  SCALING                        YES#define  DOCUMENTATION                  YES#define  MULTIPLICATION                 YES#define  DETERMINANT                    YES#define  CONDITION                      YES#define  PSEUDOCONDITION                YES#define  FORTRAN                        YES#define  DEBUG                          YES#define  spCOMPATIBILITY                YES#define  LINT                           YES#else /* not lint */#define  LINT                           NO#endif /* not lint *//* *   MACRO DEFINITIONS * *   Macros are distinguished by using solely capital letters in their *   identifiers.  This contrasts with C defined identifiers which are strictly *   lower case, and program variable and procedure names which use both upper *   and lower case. *//* Begin macros. *//* Boolean data type */#define  BOOLEAN        int#define  NO             0#define  YES            1#define  NOT            !#define  AND            &&#define  OR             ||/* NULL pointer */#ifndef  NULL#define  NULL           0#endif#define  SPARSE_ID      0x772773        /* Arbitrary (is Sparse on phone). */#define  IS_SPARSE(matrix)      ((matrix) != NULL &&            \                                 (matrix)->ID == SPARSE_ID)#define  IS_VALID(matrix)       ((matrix) != NULL &&            \                                 (matrix)->ID == SPARSE_ID &&   \                                 (matrix)->Error >= spOKAY &&   \                                 (matrix)->Error < spFATAL)#define  IS_FACTORED(matrix)    ((matrix)->Factored && !(matrix)->NeedsOrdering)/* Macro commands *//* Macro functions that return the maximum or minimum independent of type. */#define  MAX(a,b)           ((a) > (b) ? (a) : (b))#define  MIN(a,b)           ((a) < (b) ? (a) : (b))/* Macro function that returns the absolute value of a floating point number. */#define  ABS(a)             ((a) < 0 ? -(a) : (a))/* Macro function that returns the square of a number. */#define  SQR(a)             ((a)*(a))/* Macro procedure that swaps two entities. */#define  SWAP(type, a, b)   {type swapx; swapx = a; a = b; b = swapx;}/* Macro function that returns the approx absolute value of a complex number. */#if spCOMPLEX#define  ELEMENT_MAG(ptr)   (ABS((ptr)->Real) + ABS((ptr)->Imag))#else#define  ELEMENT_MAG(ptr)   ((ptr)->Real < 0.0 ? -(ptr)->Real : (ptr)->Real)#endif/* Complex assignment statements. */#define  CMPLX_ASSIGN(to,from)  \{   (to).Real = (from).Real;    \    (to).Imag = (from).Imag;    \}#define  CMPLX_CONJ_ASSIGN(to,from)     \{   (to).Real = (from).Real;            \    (to).Imag = -(from).Imag;           \}#define  CMPLX_NEGATE_ASSIGN(to,from)   \{   (to).Real = -(from).Real;           \    (to).Imag = -(from).Imag;           \}#define  CMPLX_CONJ_NEGATE_ASSIGN(to,from)      \{   (to).Real = -(from).Real;                   \    (to).Imag = (from).Imag;                    \}#define  CMPLX_CONJ(a)  (a).Imag = -(a).Imag#define  CMPLX_NEGATE(a)        \{   (a).Real = -(a).Real;       \    (a).Imag = -(a).Imag;       \}/* Macro that returns the approx magnitude (L-1 norm) of a complex number. */#define  CMPLX_1_NORM(a)        (ABS((a).Real) + ABS((a).Imag))/* Macro that returns the approx magnitude (L-infinity norm) of a complex. */#define  CMPLX_INF_NORM(a)      (MAX (ABS((a).Real),ABS((a).Imag)))/* Macro function that returns the magnitude (L-2 norm) of a complex number. */#define  CMPLX_2_NORM(a)        (sqrt((a).Real*(a).Real + (a).Imag*(a).Imag))/* Macro function that performs complex addition. */#define  CMPLX_ADD(to,from_a,from_b)            \{   (to).Real = (from_a).Real + (from_b).Real;  \    (to).Imag = (from_a).Imag + (from_b).Imag;  \}/* Macro function that performs complex subtraction. */#define  CMPLX_SUBT(to,from_a,from_b)           \{   (to).Real = (from_a).Real - (from_b).Real;  \    (to).Imag = (from_a).Imag - (from_b).Imag;  \}/* Macro function that is equivalent to += operator for complex numbers. */#define  CMPLX_ADD_ASSIGN(to,from)      \{   (to).Real += (from).Real;           \    (to).Imag += (from).Imag;           \}/* Macro function that is equivalent to -= operator for complex numbers. */#define  CMPLX_SUBT_ASSIGN(to,from)     \{   (to).Real -= (from).Real;           \    (to).Imag -= (from).Imag;           \}/* Macro function that multiplies a complex number by a scalar. */#define  SCLR_MULT(to,sclr,cmplx)       \{   (to).Real = (sclr) * (cmplx).Real;  \    (to).Imag = (sclr) * (cmplx).Imag;  \}/* Macro function that multiply-assigns a complex number by a scalar. */#define  SCLR_MULT_ASSIGN(to,sclr)      \{   (to).Real *= (sclr);                \    (to).Imag *= (sclr);                \}/* Macro function that multiplies two complex numbers. */#define  CMPLX_MULT(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 implements to *= from for complex numbers. */#define  CMPLX_MULT_ASSIGN(to,from)             \{   RealNumber to_real_ = (to).Real;            \    (to).Real = to_real_ * (from).Real -        \                (to).Imag * (from).Imag;        \    (to).Imag = to_real_ * (from).Imag +        \                (to).Imag * (from).Real;        \}/* Macro function that multiplies two complex numbers, the first of which is * conjugated. */#define  CMPLX_CONJ_MULT(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 another. to = add + mult_a * mult_b */#define  CMPLX_MULT_ADD(to,mult_a,mult_b,add)                   \{   (to).Real = (mult_a).Real * (mult_b).Real -                 \                (mult_a).Imag * (mult_b).Imag + (add).Real;     \    (to).Imag = (mult_a).Real * (mult_b).Imag +                 \                (mult_a).Imag * (mult_b).Real + (add).Imag;     \}/* Macro function that subtracts the product of two complex numbers from * another.  to = subt - mult_a * mult_b */#define  CMPLX_MULT_SUBT(to,mult_a,mult_b,subt)                 \{   (to).Real = (subt).Real - (mult_a).Real * (mult_b).Real +   \                              (mult_a).Imag * (mult_b).Imag;    \    (to).Imag = (subt).Imag - (mult_a).Real * (mult_b).Imag -   \                              (mult_a).Imag * (mult_b).Real;    \}/* Macro function that multiplies two complex numbers and then adds them * to another. to = add + mult_a* * mult_b where mult_a* represents mult_a * conjugate. */#define  CMPLX_CONJ_MULT_ADD(to,mult_a,mult_b,add)              \{   (to).Real = (mult_a).Real * (mult_b).Real +                 \                (mult_a).Imag * (mult_b).Imag + (add).Real;     \    (to).Imag = (mult_a).Real * (mult_b).Imag -                 \                (mult_a).Imag * (mult_b).Real + (add).Imag;     \}/* Macro function that multiplies two complex numbers and then adds them * 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;         \

⌨️ 快捷键说明

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