From 2b3a916dd22c80d2abf17b47efe57d1ea4d22b2d Mon Sep 17 00:00:00 2001 From: dwarning Date: Tue, 6 Jun 2023 14:54:17 +0200 Subject: [PATCH] more adaptions --- src/include/ngspice/spmatrix.h | 2 +- src/maths/sparse/ChangeLog | 45 ++++++++++++++++++++++++++++++++++ src/maths/sparse/spAllocate.c | 4 +-- src/maths/sparse/spConfig.h | 2 +- src/maths/sparse/spLicense | 27 ++++++++++++++++++++ src/maths/sparse/spSMP.c | 4 +-- src/maths/sparse/spextra.c | 41 ++++++++++++++++++++++--------- 7 files changed, 108 insertions(+), 17 deletions(-) create mode 100644 src/maths/sparse/spLicense diff --git a/src/include/ngspice/spmatrix.h b/src/include/ngspice/spmatrix.h index 10159d015..4e4de1297 100644 --- a/src/include/ngspice/spmatrix.h +++ b/src/include/ngspice/spmatrix.h @@ -344,6 +344,7 @@ spcEXTERN void spSetComplex( spMatrix ); spcEXTERN void spSetReal( spMatrix ); spcEXTERN void spStripFills( spMatrix ); spcEXTERN void spWhereSingular( spMatrix, int*, int* ); +spcEXTERN void spConstMult( spMatrix, double ); /* Functions with argument lists that are dependent on options. */ @@ -373,4 +374,3 @@ spcEXTERN void spSolveTransposed( spMatrix, spREAL[], spREAL[] ); #endif /* NOT (spCOMPLEX && spSEPARATED_COMPLEX_VECTORS) */ #endif /* spOKAY */ -//spcEXTERN void spConstMult(spMatrix, double); diff --git a/src/maths/sparse/ChangeLog b/src/maths/sparse/ChangeLog index 4212a55f5..af1dff85c 100644 --- a/src/maths/sparse/ChangeLog +++ b/src/maths/sparse/ChangeLog @@ -3,3 +3,48 @@ * spdefs.h: #includes spice.h instead of misc.h added a few #undefs to avoid redaclarations +2023-06-06 Dietmar Warning +spAllocate.c: + ReserveElements() not needed + Distinction between OriginalCount() and ElementCount() needed for ACCT report. + Structure Matrix has no "Original" member anymore, seems ELEMENTS plays this role. +spBuild.c: + int Min is initialized with LARGEST_LONG_INTEGER follows in -1, Min should be long int +spSMP.c: + Return value of SMP functions: what is meant for spError? the typedef to int or the spErrorState function? + SMPfindElt() calls spcFindElement() - it is not available + Compiling with spSEPARATED_COMPLEX_VECTORS=0 follows in error like this: +spSMP.c: In function ‘SMPcSolve’: +spSMP.c:222:5: error: too many arguments to function ‘spSolve’ + 222 | spSolve( (char *)Matrix, RHS, RHS, iRHS, iRHS ); + | ^~~~~~~ +In file included from spSMP.c:93: +../../../src/include/ngspice/spmatrix.h:371:23: note: declared here + 371 | spcEXTERN void spSolve( spMatrix, spREAL[], spREAL[] ); + +This shows that prototypes are OK, but in the call of the function is no difference in parameter count. + +spConfig.h: +#define REAL YES +#define EXPANDABLE YES +#define TRANSLATE YES +#define INITIALIZE NO +#define DIAGONAL_PIVOTING YES +#define ARRAY_OFFSET NO +#define MODIFIED_MARKOWITZ NO +#define DELETE NO +#define STRIP NO +#define MODIFIED_NODAL YES +#define QUAD_ELEMENT NO +#define TRANSPOSE YES +#define SCALING NO +#define DOCUMENTATION YES +#define MULTIPLICATION YES +#define DETERMINANT YES +#define STABILITY NO +#define CONDITION NO +#define PSEUDOCONDITION NO +#define FORTRAN NO +#define DEBUG YES +#define spCOMPLEX 1 +#define spSEPARATED_COMPLEX_VECTORS 1 diff --git a/src/maths/sparse/spAllocate.c b/src/maths/sparse/spAllocate.c index edc3c0d1b..e525148db 100644 --- a/src/maths/sparse/spAllocate.c +++ b/src/maths/sparse/spAllocate.c @@ -123,7 +123,7 @@ spMatrix spCreate( int Size, int Complex, - int *pError + spError *pError ) { register unsigned SizePlusOne; @@ -670,7 +670,7 @@ register AllocationListPtr ListPtr, NextListPtr; * The pointer to the matrix for which the error status is desired. */ -int +spError spErrorState( spMatrix eMatrix ) { /* Begin `spErrorState'. */ diff --git a/src/maths/sparse/spConfig.h b/src/maths/sparse/spConfig.h index 86a5ed2fa..1b466a22b 100644 --- a/src/maths/sparse/spConfig.h +++ b/src/maths/sparse/spConfig.h @@ -151,7 +151,7 @@ * matrix. ARRAY_OFFSET must be either 0 or 1, no other offsets * are valid. */ -#define ARRAY_OFFSET YES +#define ARRAY_OFFSET NO /*! * This specifies that the modified Markowitz method of pivot diff --git a/src/maths/sparse/spLicense b/src/maths/sparse/spLicense new file mode 100644 index 000000000..2b246c21f --- /dev/null +++ b/src/maths/sparse/spLicense @@ -0,0 +1,27 @@ +Copyright (c) 2003, Kenneth S. Kundert +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. Redistributions +in binary form must reproduce the above copyright notice, this list +of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. Neither the name of the +copyright holder nor the names of the authors may be used to endorse +or promote products derived from this software without specific prior +written permission. + +This software is provided by the copyright holders and contributors +"as is" and any express or implied warranties, including, but not +limited to, the implied warranties of merchantability and fitness for +a particular purpose are disclaimed. In no event shall the copyright +owner or contributors be liable for any direct, indirect, incidental, +special, exemplary, or consequential damages (including, but not limited +to, procurement of substitute goods or services; loss of use, data, or +profits; or business interruption) however caused and on any theory of +liability, whether in contract, strict liability, or tort (including +negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. diff --git a/src/maths/sparse/spSMP.c b/src/maths/sparse/spSMP.c index f40af9804..fffd5641d 100644 --- a/src/maths/sparse/spSMP.c +++ b/src/maths/sparse/spSMP.c @@ -96,7 +96,7 @@ #define NO 0 #define YES 1 -typedef spREAL RealNumber, *RealVector; +typedef spREAL *RealVector; static void LoadGmin(char *Matrix, double Gmin); @@ -417,7 +417,7 @@ SMPcDProd(SMPmatrix *Matrix, SPcomplex *pMantissa, int *pExponent) * for compatibility with Spice3. */ #include "spDefs.h" -void +static void LoadGmin( eMatrix, Gmin ) char *eMatrix; register double Gmin; diff --git a/src/maths/sparse/spextra.c b/src/maths/sparse/spextra.c index 956441f03..2dc1dc34d 100644 --- a/src/maths/sparse/spextra.c +++ b/src/maths/sparse/spextra.c @@ -23,23 +23,42 @@ */ #define spINSIDE_SPARSE +#include #include "spConfig.h" #include "ngspice/spmatrix.h" #include "spDefs.h" - void -spConstMult(MatrixPtr matrix, double constant) +spConstMult( + spMatrix eMatrix, + double constant +) { - ElementPtr e; - int i; - int size = matrix->Size; +ElementPtr pElement; +int I; +MatrixPtr Matrix = (MatrixPtr)eMatrix; +int size = Matrix->Size; - for (i = 1; i <= size; i++) { - for (e = matrix->FirstInCol[i]; e; e = e->NextInCol) { - e->Real *= constant; - e->Imag *= constant; - } - } + ASSERT_IS_SPARSE( Matrix ); +#if spCOMPLEX + for (I = 1; I <= size; I++) { + for (pElement = Matrix->FirstInCol[I]; pElement; pElement = pElement->NextInCol) { + pElement->Real *= constant; + pElement->Imag *= constant; + } + } + return; +#endif + +#if REAL + for (I = 1; I <= size; I++) { + pElement = Matrix->FirstInRow[I]; + while (pElement != NULL) + { pElement->Real *= constant; + pElement = pElement->NextInRow; + } + } + return; +#endif /* REAL */ }