48 static char copyright[] =
49 "Sparse1.3: Copyright (c) 1985,86,87,88,89,90 by Kenneth S. Kundert";
51 "@(#)$Header: spBuild.c,v 1.3 88/06/24 05:00:31 kundert Exp $";
69 #define spINSIDE_SPARSE 132 {
for (I = Matrix->
Size; I > 0; I--)
134 while (pElement !=
NULL)
188 {
for (I = Matrix->
Size; I > 0; I--)
190 while (pElement !=
NULL)
239 for (I = Matrix->
Size; I > 0; I--) {
255 int *
Size, *NonZero, *FillIns;
260 *Size = Matrix->
Size;
273 int Accum_Col, Addend_Col;
284 while (Addend !=
NULL) {
285 while (Accum && Accum->
Row < Addend->
Row) {
289 if (!Accum || Accum->
Row > Addend->
Row) {
294 Accum->Imag += Addend->Imag;
298 return spError( (
char *)Matrix );
322 return spError( (
char *)Matrix );
327 #define M_LN2 0.69314718055994530942 330 #define M_LN10 2.30258509299404568402 368 double y, z = 1.0, k = 2.0;
376 for (y = 1.0; n; n >>= 1) {
390 spDProd( Matrix, pMantissaR, pMantissaI, pExponent)
397 double re, im, x, y, z;
403 printf(
"Determinant 10: (%20g,%20g)^%d\n", re, im, p);
417 printf(
" ** base10 -> base2 int = %g, frac = %20g\n", x, y);
423 printf(
" ** multiplier = %20g\n", z);
434 else if (im != 0.0) {
446 printf(
" ** renormalize changes = %g,%g\n", y, z);
455 printf(
" ** values are: re %g, im %g, y %g, re' %g, im' %g\n",
458 *pMantissaR =
my_scalb(re, (
int) -y);
459 *pMantissaI =
my_scalb(im, (
int) -y);
462 printf(
"Determinant 10->2: (%20g,%20g)^%d\n", *pMantissaR,
463 *pMantissaI, *pExponent);
465 return spError( (
char *)Matrix );
506 {
for (I = Matrix->
Size; I > 0; I--)
508 while (pElement !=
NULL)
509 { pElement->
Real = 0.0;
510 pElement->Imag = 0.0;
517 {
for (I = Matrix->
Size; I > 0; I--)
519 while (pElement !=
NULL)
520 { pElement->
Real = 0.0;
599 if ((Row == 0)
OR (Col == 0))
618 if ((Row > Matrix->
Size)
OR (Col > Matrix->
Size))
704 pElement = *LastAddr;
707 while (pElement !=
NULL)
708 {
if (pElement->
Row < Row)
714 else if (pElement->
Row == Row)
775 register int IntRow, IntCol, ExtRow, ExtCol;
782 if ((ExtRow > Matrix->AllocatedExtSize)
OR 783 (ExtCol > Matrix->AllocatedExtSize))
790 if ((ExtRow > Matrix->ExtSize)
OR (ExtCol > Matrix->ExtSize))
791 Matrix->ExtSize =
MAX(ExtRow, ExtCol);
794 if ((IntRow = Matrix->ExtToIntRowMap[ExtRow]) == -1)
795 { Matrix->ExtToIntRowMap[ExtRow] = ++Matrix->CurrentSize;
796 Matrix->ExtToIntColMap[ExtRow] = Matrix->CurrentSize;
797 IntRow = Matrix->CurrentSize;
805 if (IntRow > Matrix->Size)
810 Matrix->IntToExtRowMap[IntRow] = ExtRow;
811 Matrix->IntToExtColMap[IntRow] = ExtRow;
815 if ((IntCol = Matrix->ExtToIntColMap[ExtCol]) == -1)
816 { Matrix->ExtToIntRowMap[ExtCol] = ++Matrix->CurrentSize;
817 Matrix->ExtToIntColMap[ExtCol] = Matrix->CurrentSize;
818 IntCol = Matrix->CurrentSize;
826 if (IntCol > Matrix->Size)
831 Matrix->IntToExtRowMap[IntCol] = ExtCol;
832 Matrix->IntToExtColMap[IntCol] = ExtCol;
970 spGetQuad( Matrix, Row1, Row2, Col1, Col2, Template )
973 int Row1, Row2, Col1, Col2;
1045 spGetOnes(Matrix, Pos, Neg, Eqn, Template)
1128 if (Matrix->RowsLinked)
1137 Matrix->NeedsOrdering =
YES;
1142 if (Row == Col) Matrix->Diag[Row] =
pElement;
1146 pElement->
Row = Row;
1147 pElement->
Col = Col;
1148 pElement->
Real = 0.0;
1150 pElement->Imag = 0.0;
1153 pElement->pInitInfo =
NULL;
1161 pElement = Matrix->FirstInRow[Row];
1162 pLastElement =
NULL;
1163 while (pElement !=
NULL)
1166 if (pElement->
Col < Col)
1172 else pElement =
NULL;
1176 pElement = pCreatedElement;
1177 if (pLastElement ==
NULL)
1180 pElement->
NextInRow = Matrix->FirstInRow[Row];
1181 Matrix->FirstInRow[Row] =
pElement;
1203 if (Row == Col) Matrix->Diag[Row] =
pElement;
1207 pElement->
Row = Row;
1209 pElement->
Col = Col;
1211 pElement->
Real = 0.0;
1213 pElement->Imag = 0.0;
1216 pElement->pInitInfo =
NULL;
1225 return pCreatedElement;
1271 FirstInRowArray = Matrix->FirstInRow;
1272 for (Col = Matrix->Size; Col >= 1; Col--)
1275 pElement = Matrix->FirstInCol[Col];
1277 while (pElement !=
NULL)
1278 { pElement->
Col = Col;
1279 FirstInRowEntry = &FirstInRowArray[pElement->
Row];
1285 Matrix->RowsLinked =
YES;
1316 register
int NewSize;
1318 register int I, OldAllocatedSize = Matrix->AllocatedSize;
1321 Matrix->Size = NewSize;
1323 if (NewSize <= OldAllocatedSize)
1327 NewSize =
MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
1328 Matrix->AllocatedSize = NewSize;
1330 if ((
REALLOC(Matrix->IntToExtColMap,
int, NewSize+1)) ==
NULL)
1334 if ((
REALLOC(Matrix->IntToExtRowMap,
int, NewSize+1)) ==
NULL)
1355 FREE( Matrix->MarkowitzRow );
1356 FREE( Matrix->MarkowitzCol );
1357 FREE( Matrix->MarkowitzProd );
1358 FREE( Matrix->DoRealDirect );
1359 FREE( Matrix->DoCmplxDirect );
1360 FREE( Matrix->Intermediate );
1361 Matrix->InternalVectorsAllocated =
NO;
1364 for (I = OldAllocatedSize+1; I <= NewSize; I++)
1365 { Matrix->IntToExtColMap[
I] =
I;
1366 Matrix->IntToExtRowMap[
I] =
I;
1367 Matrix->Diag[
I] =
NULL;
1368 Matrix->FirstInRow[
I] =
NULL;
1369 Matrix->FirstInCol[
I] =
NULL;
1405 register int NewSize;
1407 register int I, OldAllocatedSize = Matrix->AllocatedExtSize;
1410 Matrix->ExtSize = NewSize;
1412 if (NewSize <= OldAllocatedSize)
1416 NewSize =
MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
1417 Matrix->AllocatedExtSize = NewSize;
1419 if ((
REALLOC(Matrix->ExtToIntRowMap,
int, NewSize+1)) ==
NULL)
1423 if ((
REALLOC(Matrix->ExtToIntColMap,
int, NewSize+1)) ==
NULL)
1429 for (I = OldAllocatedSize+1; I <= NewSize; I++)
1430 { Matrix->ExtToIntRowMap[
I] = -1;
1431 Matrix->ExtToIntColMap[
I] = -1;
1520 {
for (J = Matrix->
Size; J > 0; J--)
1522 while (pElement !=
NULL)
1523 { pElement->Imag = 0.0;
1531 for (J = Matrix->
Size; J > 0; J--)
1534 while (pElement !=
NULL)
1535 {
if (pElement->pInitInfo ==
NULL)
1536 { pElement->
Real = 0.0;
1538 pElement->Imag = 0.0;
1542 { Error = (*pInit)((
RealNumber *)pElement, pElement->pInitInfo,
ElementPtr spcGetElement()
void spClear(char *eMatrix)
void spGetStat(char *Matrixp, int *Size, int *NonZero, int *FillIns)
void spItoR(char *eMatrix)
This document describes the JSPICE3 Josephson junction model I derivation of the model The expression for the junction current is J
int spDProd(char *Matrix, double *pMantissaR, double *pMantissaI, int *pExponent)
#define IS_SPARSE(matrix)
BOOLEAN PreviousMatrixWasComplex
struct MatrixElement * NextInCol
struct MatrixElement * ElementPtr
ASSERT(IS_VALID(Matrix) AND IS_FACTORED(Matrix))
register ElementPtr pElement
static double my_logb(double x)
static double my_scalb(double x, int n)
int spZeroCol(char *Matrixp, int Col)
ElementPtr spcGetFillin()
void spLoadGmin(char *Matrixp, double Gmin)
int spAddCol(char *Matrixp, int Accum_Col, int Addend_Col)
RealNumber * spGetElement(char *eMatrix, int Row, int Col)
void spRtoI(char *eMatrix)
struct MatrixElement TrashCan
static void ExpandTranslationArrays()
void spcLinkRows(MatrixPtr Matrix)
#define REALLOC(ptr, type, number)
ElementPtr spcCreateElement(MatrixPtr Matrix, int Row, int Col, ElementPtr *LastAddr, BOOLEAN Fillin)
struct MatrixElement * NextInRow
ElementPtr spcFindElementInCol(MatrixPtr Matrix, ElementPtr *LastAddr, int Row, int Col, BOOLEAN CreateIfMissing)
struct MatrixFrame * MatrixPtr
#define spADD_REAL_QUAD(template, real)
static void EnlargeMatrix()
ArrayOfElementPtrs FirstInCol