Modified the Sensitivity Analysis to use the SMP interface for SPARSE

This commit is contained in:
Francesco Lannutti 2016-06-21 12:50:09 +02:00 committed by rlar
parent 875cab6758
commit b174126500
3 changed files with 28 additions and 7 deletions

View File

@ -39,5 +39,7 @@ SMPelement * SMPfindElt( SMPmatrix *, int , int , int );
int SMPcZeroCol(SMPmatrix *Matrix, int Col);
int SMPcAddCol(SMPmatrix *Matrix, int Accum_Col, int Addend_Col);
int SMPzeroRow(SMPmatrix *Matrix, int Row);
void SMPconstMult(SMPmatrix *, double);
void SMPmultiply(SMPmatrix *, double *, double *, double *, double *);
#endif

View File

@ -551,3 +551,21 @@ SMPzeroRow(SMPmatrix *Matrix, int Row)
return spError( Matrix );
}
/*
* SMPconstMult()
*/
void
SMPconstMult(SMPmatrix *Matrix, double constant)
{
spConstMult(Matrix, constant);
}
/*
* SMPmultiply()
*/
void
SMPmultiply(SMPmatrix *Matrix, double *RHS, double *Solution, double *iRHS, double *iSolution)
{
spMultiply(Matrix, RHS, Solution, iRHS, iSolution);
}

View File

@ -139,9 +139,10 @@ int sens_sens(CKTcircuit *ckt, int restart)
if (error)
return error;
size = spGetSize(ckt->CKTmatrix, 1);
size = SMPmatSize(ckt->CKTmatrix);
/* Create the perturbation matrix */
// error = SMPnewMatrix(&delta_Y); // No Size...
delta_Y = spCreate(size, 1, &error);
if (error)
return error;
@ -351,7 +352,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
}
#endif
spClear(delta_Y);
SMPcClear(delta_Y);
for (j = 0; j < size; j++) {
delta_I[j] = 0.0;
@ -418,7 +419,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
if (error && error != E_BADPARM)
return error;
spConstMult(delta_Y, -1.0);
SMPconstMult(delta_Y, -1.0);
for (j = 0; j < size; j++) {
delta_I[j] *= -1.0;
delta_iI[j] *= -1.0;
@ -477,8 +478,8 @@ int sens_sens(CKTcircuit *ckt, int restart)
#endif
/* delta_Y E */
spMultiply(delta_Y, delta_I_delta_Y, E,
delta_iI_delta_Y, iE);
SMPmultiply(delta_Y, delta_I_delta_Y, E,
delta_iI_delta_Y, iE);
#ifdef ASDEBUG
DEBUG(2)
@ -503,7 +504,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
}
#endif
/* Solve; Y already factored */
spSolve(Y, delta_I, delta_I, delta_iI, delta_iI);
SMPcSolve(Y, delta_I, delta_iI, NULL, NULL);
/* the special `0' node
* the matrix indizes are [1..n]
@ -596,7 +597,7 @@ int sens_sens(CKTcircuit *ckt, int restart)
release_context(ckt->CKTirhs, saved_irhs);
release_context(ckt->CKTmatrix, saved_matrix);
spDestroy(delta_Y);
SMPdestroy(delta_Y);
FREE(delta_I);
FREE(delta_iI);