Browse Source
Getting rid of SPARSE for Initial Circuit Matrix creation. Now KLU is totally independent from SPARSE. This opens up the interface for other solvers as well
Getting rid of SPARSE for Initial Circuit Matrix creation. Now KLU is totally independent from SPARSE. This opens up the interface for other solvers as well
SPARSE can still used through '.options sparse', but it isn't possible to switch from KLU to SPARSE and viceversa at run-timepre-master-46
committed by
Holger Vogt
83 changed files with 999 additions and 2071 deletions
-
8src/ciderlib/oned/oneadmit.c
-
77src/ciderlib/oned/onecont.c
-
51src/ciderlib/oned/onepoiss.c
-
21src/ciderlib/oned/onesolve.c
-
12src/ciderlib/twod/twoadmit.c
-
6src/ciderlib/twod/twocont.c
-
6src/ciderlib/twod/twoncont.c
-
6src/ciderlib/twod/twopcont.c
-
6src/ciderlib/twod/twopoiss.c
-
27src/ciderlib/twod/twosolve.c
-
2src/include/ngspice/cktdefs.h
-
128src/include/ngspice/klu-binding.h
-
69src/include/ngspice/klu.h
-
54src/include/ngspice/onemesh.h
-
30src/include/ngspice/smpdefs.h
-
15src/include/ngspice/spmatrix.h
-
2src/include/ngspice/tskdefs.h
-
123src/include/ngspice/twomesh.h
-
4src/maths/KLU/klu_defaults.c
-
835src/maths/KLU/klusmp.c
-
18src/maths/ni/niinit.c
-
6src/maths/sparse/Makefile.am
-
174src/maths/sparse/spCSC.c
-
10src/spicelib/analysis/acan.c
-
15src/spicelib/analysis/cktacct.c
-
85src/spicelib/analysis/cktpzset.c
-
101src/spicelib/analysis/cktsens.c
-
74src/spicelib/analysis/cktsetup.c
-
20src/spicelib/devices/adms/admst/ngspiceMODULEbindCSC.c.xml
-
20src/spicelib/devices/asrc/asrcbindCSC.c
-
20src/spicelib/devices/bjt/bjtbindCSC.c
-
20src/spicelib/devices/bsim1/b1bindCSC.c
-
20src/spicelib/devices/bsim2/b2bindCSC.c
-
20src/spicelib/devices/bsim3/b3bindCSC.c
-
20src/spicelib/devices/bsim3soi_dd/b3soiddbindCSC.c
-
20src/spicelib/devices/bsim3soi_fd/b3soifdbindCSC.c
-
20src/spicelib/devices/bsim3soi_pd/b3soipdbindCSC.c
-
20src/spicelib/devices/bsim3v0/b3v0bindCSC.c
-
20src/spicelib/devices/bsim3v1/b3v1bindCSC.c
-
20src/spicelib/devices/bsim3v32/b3v32bindCSC.c
-
20src/spicelib/devices/bsim4/b4bindCSC.c
-
20src/spicelib/devices/bsim4v5/b4v5bindCSC.c
-
20src/spicelib/devices/bsim4v6/b4v6bindCSC.c
-
20src/spicelib/devices/bsim4v7/b4v7bindCSC.c
-
20src/spicelib/devices/bsimsoi/b4soibindCSC.c
-
20src/spicelib/devices/cap/capbindCSC.c
-
20src/spicelib/devices/cccs/cccsbindCSC.c
-
20src/spicelib/devices/ccvs/ccvsbindCSC.c
-
21src/spicelib/devices/cpl/cplbindCSC.c
-
20src/spicelib/devices/csw/cswbindCSC.c
-
20src/spicelib/devices/dio/diobindCSC.c
-
20src/spicelib/devices/hfet1/hfetbindCSC.c
-
20src/spicelib/devices/hfet2/hfet2bindCSC.c
-
20src/spicelib/devices/hisim2/hsm2bindCSC.c
-
20src/spicelib/devices/hisimhv1/hsmhvbindCSC.c
-
20src/spicelib/devices/hisimhv2/hsmhv2bindCSC.c
-
20src/spicelib/devices/ind/indbindCSC.c
-
20src/spicelib/devices/ind/mutbindCSC.c
-
20src/spicelib/devices/jfet/jfetbindCSC.c
-
20src/spicelib/devices/jfet2/jfet2bindCSC.c
-
20src/spicelib/devices/ltra/ltrabindCSC.c
-
20src/spicelib/devices/mes/mesbindCSC.c
-
20src/spicelib/devices/mesa/mesabindCSC.c
-
20src/spicelib/devices/mos1/mos1bindCSC.c
-
20src/spicelib/devices/mos2/mos2bindCSC.c
-
20src/spicelib/devices/mos3/mos3bindCSC.c
-
20src/spicelib/devices/mos6/mos6bindCSC.c
-
20src/spicelib/devices/mos9/mos9bindCSC.c
-
20src/spicelib/devices/nbjt/nbjtbindCSC.c
-
20src/spicelib/devices/nbjt2/nbjt2bindCSC.c
-
20src/spicelib/devices/numd/numdbindCSC.c
-
20src/spicelib/devices/numd2/numd2bindCSC.c
-
20src/spicelib/devices/numos/numosbindCSC.c
-
20src/spicelib/devices/res/resbindCSC.c
-
20src/spicelib/devices/soi3/soi3bindCSC.c
-
20src/spicelib/devices/sw/swbindCSC.c
-
20src/spicelib/devices/tra/trabindCSC.c
-
20src/spicelib/devices/txl/txlbindCSC.c
-
20src/spicelib/devices/vbic/vbicbindCSC.c
-
20src/spicelib/devices/vccs/vccsbindCSC.c
-
20src/spicelib/devices/vcvs/vcvsbindCSC.c
-
24src/spicelib/devices/vsrc/vsrcbindCSC.c
-
20src/xspice/mif/mifbindCSC.c
835
src/maths/KLU/klusmp.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,174 +0,0 @@ |
|||
/* Sparse Matrix to CSC Matrix Conversion Routines |
|||
* Including Dump Routines |
|||
* |
|||
* Author: Francesco Lannutti 2011-2012 |
|||
* |
|||
* Instructions: |
|||
* spMatrix_CSC_dump and spRHS_CSC_dump are the dump routines; |
|||
* insert them in a point in your code after that the Sparse Matrix |
|||
* is filled in to dump the whole matrix in the CSC format. |
|||
* To solve correctly the resulting CSC linear system, it's crucial |
|||
* to perform another inversion of the Solution Vector following this code: |
|||
* |
|||
* pExtOrder = IntToExtColMap [n] ; |
|||
* for (i = n - 1 ; i >= 0 ; i--) |
|||
* RHS [*(pExtOrder--)] = Intermediate [i] ; |
|||
*/ |
|||
|
|||
/* Includes */ |
|||
#include "ngspice/spmatrix.h" |
|||
#include "spdefs.h" |
|||
|
|||
/* Body */ |
|||
int |
|||
WriteCol_original (MatrixPtr Matrix, int Col, spREAL *CSC_Element, spREAL *CSC_Element_Complex, int *CSC_Row, BindElement *BindSparseCSC, spREAL **diag) |
|||
{ |
|||
int i ; |
|||
ElementPtr current ; |
|||
|
|||
i = 0 ; |
|||
current = Matrix->FirstInCol [Col] ; |
|||
|
|||
while (current != NULL) { |
|||
BindSparseCSC [i].Sparse = (double *)current ; |
|||
BindSparseCSC [i].CSC = &(CSC_Element [i]) ; |
|||
BindSparseCSC [i].CSC_Complex = &(CSC_Element_Complex [2 * i]) ; |
|||
CSC_Row [i] = (current->Row) - 1 ; |
|||
if (CSC_Row [i] == Col - 1) |
|||
diag [0] = &(CSC_Element [i]) ; |
|||
i++ ; |
|||
current = current->NextInCol ; |
|||
} |
|||
|
|||
return i ; |
|||
} |
|||
|
|||
int |
|||
WriteCol_original_dump (MatrixPtr Matrix, int Col, spREAL *CSC_Element, int *CSC_Row, unsigned int complex) |
|||
{ |
|||
int i ; |
|||
ElementPtr current ; |
|||
i = 0 ; |
|||
current = Matrix->FirstInCol [Col] ; |
|||
|
|||
while (current != NULL) |
|||
{ |
|||
if (complex) |
|||
{ |
|||
CSC_Element [2 * i] = current->Real ; |
|||
CSC_Element [2 * i + 1] = current->Imag ; |
|||
} else { |
|||
CSC_Element [i] = current->Real ; |
|||
} |
|||
CSC_Row [i] = (current->Row) - 1 ; |
|||
i++ ; |
|||
current = current->NextInCol ; |
|||
} |
|||
|
|||
return i ; |
|||
} |
|||
|
|||
void |
|||
spMatrix_CSC (MatrixPtr Matrix, int *Ap, int *Ai, double *Ax, double *Ax_Complex, int n, BindElement *BindSparseCSC, double **diag) |
|||
{ |
|||
int offset, i ; |
|||
|
|||
offset = 0 ; |
|||
Ap[0] = offset ; |
|||
for (i = 1 ; i <= n ; i++) { |
|||
offset += WriteCol_original (Matrix, i, (spREAL *)(Ax + offset), (spREAL *)(Ax_Complex + 2 * offset), |
|||
(int *)(Ai + offset), BindSparseCSC + offset, (spREAL **)(diag + (i - 1))) ; |
|||
|
|||
Ap[i] = offset ; |
|||
} |
|||
} |
|||
|
|||
void |
|||
spMatrix_CSC_dump (MatrixPtr Matrix, unsigned int complex, char *CSC_output) |
|||
{ |
|||
FILE *output ; |
|||
int offset, i, j, *Ap, *Ai, n, nz ; |
|||
double *Ax ; |
|||
|
|||
n = spGetSize (Matrix, 1) ; |
|||
nz = Matrix->Elements ; |
|||
Ap = (int *) SP_MALLOC (int, n + 1) ; |
|||
Ai = (int *) SP_MALLOC (int, nz) ; |
|||
if (complex) |
|||
{ |
|||
Ax = (double *) SP_MALLOC (double, 2 * nz) ; |
|||
} else { |
|||
Ax = (double *) SP_MALLOC (double, nz) ; |
|||
} |
|||
|
|||
offset = 0 ; |
|||
Ap [0] = offset ; |
|||
for (i = 1 ; i <= n ; i++) { |
|||
offset += WriteCol_original_dump (Matrix, i, (spREAL *)(Ax + offset), (int *)(Ai + offset), complex) ; |
|||
Ap [i] = offset ; |
|||
} |
|||
|
|||
if (!complex && CSC_output != NULL) |
|||
{ |
|||
output = fopen (CSC_output, "w") ; |
|||
fprintf (output, "%%%%MatrixMarket matrix coordinate real general\n") ; |
|||
fprintf (output, "%%-------------------------------------------------------------------------------\n") ; |
|||
fprintf (output, "%% Transient Matrix Dump\n%% Family: ISCAS Circuit\n") ; |
|||
fprintf (output, "%%-------------------------------------------------------------------------------\n") ; |
|||
fprintf (output, "%d %d %d\n", n, n, offset) ; |
|||
for (i = 0 ; i < n ; i++) |
|||
for (j = Ap [i] ; j < Ap [i + 1] ; j++) |
|||
fprintf (output, "%d %d %-.9g\n", Ai [j] + 1, i + 1, Ax [j]) ; |
|||
fclose (output) ; |
|||
|
|||
output = fopen ("IntToExtColMap.txt", "w") ; |
|||
for (i = 1 ; i <= n ; i++) |
|||
fprintf (output, "%d\n", Matrix->IntToExtColMap [i]) ; |
|||
fclose (output) ; |
|||
} else { |
|||
fprintf (stderr, "CSC Matrix converted from SPARSE 1.3 matrix\n") ; |
|||
for (i = 0 ; i < n ; i++) |
|||
{ |
|||
for (j = Ap [i] ; j < Ap [i + 1] ; j++) |
|||
{ |
|||
if (complex) |
|||
{ |
|||
fprintf (stderr, "Row: %d\tCol: %d\tValue: %-.9g j%-.9g\n", Ai [j] + 1, i + 1, Ax [2 * j], Ax [2 * j + 1]) ; |
|||
} else { |
|||
fprintf (stderr, "Row: %d\tCol: %d\tValue: %-.9g\n", Ai [j] + 1, i + 1, Ax [j]) ; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
SP_FREE (Ap) ; |
|||
SP_FREE (Ai) ; |
|||
SP_FREE (Ax) ; |
|||
} |
|||
|
|||
void |
|||
spRHS_CSC_dump (RealNumber *RHS, char *CSC_output_b, MatrixPtr Matrix) |
|||
{ |
|||
FILE *output ; |
|||
int i, n, *pExtOrder ; |
|||
double *Intermediate ; |
|||
|
|||
n = spGetSize (Matrix, 1) ; |
|||
Intermediate = (double *) SP_MALLOC (double, n) ; |
|||
|
|||
pExtOrder = &Matrix->IntToExtRowMap [n] ; |
|||
for (i = n - 1 ; i >= 0 ; i--) |
|||
Intermediate [i] = RHS [*(pExtOrder--)] ; |
|||
|
|||
output = fopen (CSC_output_b, "w") ; |
|||
fprintf (output, "%%%%MatrixMarket matrix array real general\n") ; |
|||
fprintf (output, "%%-------------------------------------------------------------------------------\n") ; |
|||
fprintf (output, "%% Transient RHS Vector Dump\n%% Family: ISCAS Circuit\n") ; |
|||
fprintf (output, "%%-------------------------------------------------------------------------------\n") ; |
|||
fprintf (output, "%d %d\n", n, 1) ; |
|||
for (i = 1 ; i < n + 1 ; i++) |
|||
fprintf (output, "%-.9g\n", Intermediate [i]) ; |
|||
fclose (output) ; |
|||
|
|||
SP_FREE (Intermediate) ; |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue