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

📄 mulglobal.h

📁 很经典的电磁计算(电容计算)软件 MIT90年代开发
💻 H
📖 第 1 页 / 共 2 页
字号:
/*Copyright (c) 1990 Massachusetts Institute of Technology, Cambridge, MA.All rights reserved.This Agreement gives you, the LICENSEE, certain rights and obligations.By using the software, you indicate that you have read, understood, andwill comply with the terms.Permission to use, copy and modify for internal, noncommercial purposesis hereby granted.  Any distribution of this program or any part thereofis strictly prohibited without prior written consent of M.I.T.Title to copyright to this software and to any associated documentationshall at all times remain with M.I.T. and LICENSEE agrees to preservesame.  LICENSEE agrees not to make any copies except for LICENSEE'Sinternal noncommercial use, or to use separately any portion of thissoftware without prior written consent of M.I.T.  LICENSEE agrees toplace the appropriate copyright notice on any such copies.Nothing in this Agreement shall be construed as conferring rights to usein advertising, publicity or otherwise any trademark or the name of"Massachusetts Institute of Technology" or "M.I.T."M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  Byway of example, but not limitation, M.I.T. MAKES NO REPRESENTATIONS ORWARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE ORTHAT THE USE OF THE LICENSED SOFTWARE COMPONENTS OR DOCUMENTATION WILLNOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.M.I.T. shall not be held liable for any liability nor for any direct,indirect or consequential damages with respect to any claim by LICENSEEor any third party on account of or arising from this Agreement or useof this software.*//* for NWS-3860 compatability */#ifdef NEWS/*** Memory management functions (from stdlib.h (recursive incl => unusable))*/extern char *   calloc();extern char *   malloc();extern char *   realloc();#else#include <stdlib.h>#endif /* end if NEWS */#include <stdio.h>#include <math.h>/* fastcap data structures */#include "mulStruct.h"/* execution time macros */#include "resusage.h"/* time variables/structs */#ifndef _TIME_                  /* if not on a Sun4 */#ifndef NEWS                    /* if not on a NWS-38XX */#include <time.h>#endif#endif#define VERSION 2.0/***********************************************************************   macros for allocation with checks for NULL pntrs and 0 byte requests  - also keep an allocated memory count  - CALLOC() is used when the memory must be zeroed    its core should be either calloc() or ualloc() (not as fast but    more space efficient, no free list - uses sbrk() and never frees)  - MALLOC() used when memory can be anything    core should be malloc() or ualloc()***********************************************************************//* SRW -- * The ualloc package causes an immediate bus error on Solaris 8 * systems.  I doubt that there is any real advantage in using an * internal allocator, particularly one that is likely to bugger * the standard allocators and crash the program.  If you really * want ualloc, define USE_UALLOC in the makefile. */#ifdef USE_UALLOC#define CALCORE(NUM, TYPE) ualloc((unsigned)(NUM)*sizeof(TYPE))#define MALCORE ualloc#else#define CALCORE(NUM, TYPE) calloc((unsigned)(NUM),sizeof(TYPE))#define MALCORE malloc#endif/* counts of memory usage by multipole matrix type */extern long memcount;extern long memQ2M;extern long memQ2L;extern long memQ2P;extern long memL2L;extern long memM2M;extern long memM2L;extern long memM2P;extern long memL2P;extern long memQ2PD;extern long memMSC;/* types of memory usage by multipole matrix type */#define AQ2M 0#define AQ2L 1#define AQ2P 2#define AL2L 3#define AM2M 4#define AM2L 5#define AM2P 6#define AL2P 7#define AQ2PD 8#define AMSC 9#ifdef NO_SBRK#define sbrk(x) 0#endif#define DUMPALLOCSIZ                                                   \{                                                                      \  (void)fprintf(stderr,                                                \		"Total Memory Allocated: %d kilobytes (brk = 0x%x)\n", \		memcount/1024, sbrk(0));                               \}#define CALLOC(PNTR, NUM, TYPE, FLAG, MTYP)                                 \{                                                                           \     if((NUM)*sizeof(TYPE)==0)                                              \       (void)fprintf(stderr,                                                \		     "zero element request in file `%s' at line %d\n",      \		     __FILE__, __LINE__);	                            \     else if(((PNTR)=(TYPE*)CALCORE(NUM, TYPE))==NULL) {                    \       (void)fprintf(stderr,                                                \	 "\nfastcap: out of memory in file `%s' at line %d\n",              \	       __FILE__, __LINE__);                                         \       (void)fprintf(stderr, " (NULL pointer on %d byte request)\n",        \		     (NUM)*sizeof(TYPE));                                   \       DUMPALLOCSIZ;                                                        \       DUMPRSS;                                                             \       (void)fflush(stderr);                                                \       (void)fflush(stdout);                                                \       if(FLAG == ON) exit(1);                                              \     }                                                                      \     else {                                                                 \       memcount += ((NUM)*sizeof(TYPE));                                    \       if(MTYP == AQ2M) memQ2M += ((NUM)*sizeof(TYPE));                     \       else if(MTYP == AQ2L) memQ2L += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AQ2P) memQ2P += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AL2L) memL2L += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AM2M) memM2M += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AM2L) memM2L += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AM2P) memM2P += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AL2P) memL2P += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AQ2PD) memQ2PD += ((NUM)*sizeof(TYPE));              \       else if(MTYP == AMSC) memMSC += ((NUM)*sizeof(TYPE));                \       else {                                                               \         (void)fprintf(stderr, "CALLOC: unknown memory type %d\n", MTYP);   \         exit(1);                                                           \       }                                                                    \     }                                                                      \}#define MALLOC(PNTR, NUM, TYPE, FLAG, MTYP)                                  \{                                                                            \     if((NUM)*sizeof(TYPE)==0)			                             \       (void)fprintf(stderr,                                                \		     "zero element request in file `%s' at line %d\n",      \		     __FILE__, __LINE__);	                            \     else if(((PNTR)=(TYPE*)MALCORE((unsigned)((NUM)*sizeof(TYPE))))==NULL) { \       (void)fprintf(stderr,                                                 \	 "\nfastcap: out of memory in file `%s' at line %d\n",               \	       __FILE__, __LINE__);                                          \       (void)fprintf(stderr, " (NULL pointer on %d byte request)\n",         \		     (NUM)*sizeof(TYPE));                                    \       DUMPALLOCSIZ;                                                         \       DUMPRSS;                                                              \       (void)fflush(stderr);                                                 \       (void)fflush(stdout);                                                 \       if(FLAG == ON) exit(1);                                               \     }                                                                       \     else {                                                                 \       memcount += ((NUM)*sizeof(TYPE));                                    \       if(MTYP == AQ2M) memQ2M += ((NUM)*sizeof(TYPE));                     \       else if(MTYP == AQ2L) memQ2L += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AQ2P) memQ2P += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AL2L) memL2L += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AM2M) memM2M += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AM2L) memM2L += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AM2P) memM2P += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AL2P) memL2P += ((NUM)*sizeof(TYPE));                \       else if(MTYP == AQ2PD) memQ2PD += ((NUM)*sizeof(TYPE));              \       else if(MTYP == AMSC) memMSC += ((NUM)*sizeof(TYPE));                \       else {                                                               \         (void)fprintf(stderr, "MALLOC: unknown memory type %d\n", MTYP);   \         exit(1);                                                           \

⌨️ 快捷键说明

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