command mrdump

This commit is contained in:
h_vogt 2012-02-19 11:11:31 +00:00
parent dffe4ed156
commit 8f3f757813
7 changed files with 56 additions and 5 deletions

View File

@ -1,3 +1,7 @@
2012-02-19 Holger Vogt
* com_cdump.c, com_cdump.h, commands.c, smpdefs.h, spoutput.c, spsmp.c,
command mrdump to dump the RHS of the matrix to stdout or to a file
2012-02-19 Holger Vogt
* spiceif.c: savesnap, loadsnap enabled (still experimental!)
* com_cdump.c, com_cdump.h, commands.c, smpdefs.h, spoutput.c, spsmp.c,

View File

@ -172,3 +172,29 @@ com_mdump(wordlist *wl)
return;
}
void
com_rdump(wordlist *wl)
{
CKTcircuit *ckt = NULL;
char *s;
if (!ft_curckt || !ft_curckt->ci_ckt) {
fprintf(cp_err, "Error: no circuit loaded.\n");
return;
}
ckt = ft_curckt->ci_ckt;
if ((ckt->CKTmatrix) && (ckt->CKTrhs))
if (wl == NULL)
SMPprintRHS( ckt->CKTmatrix , NULL, ckt->CKTrhs, ckt->CKTirhs);
else {
s = cp_unquote(wl->wl_word);
SMPprintRHS( ckt->CKTmatrix , s, ckt->CKTrhs, ckt->CKTirhs);
}
else
fprintf(cp_err, "Error: no matrix or RHS available.\n");
return;
}

View File

@ -3,6 +3,7 @@
void com_cdump(wordlist *wl);
void com_mdump(wordlist *wl);
void com_rdump(wordlist *wl);
#define TABINDENT 2 /* CDHW */ /* The orginal value was 8 */
#endif

View File

@ -553,6 +553,10 @@ struct comm spcp_coms[] = {
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, 1,
NULL,
"outfile: Dump the current matrix." } ,
{ "mrdump", com_rdump, FALSE, FALSE,
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, 1,
NULL,
"outfile: Dump the current RHS to file." } ,
{ "settype", com_stype, FALSE, FALSE,
{ 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS,
NULL,

View File

@ -31,6 +31,7 @@ int SMPnewMatrix( SMPmatrix ** );
void SMPdestroy( SMPmatrix *);
int SMPpreOrder( SMPmatrix *);
void SMPprint( SMPmatrix * , char *);
void SMPprintRHS( SMPmatrix * , char *, double*, double*);
void SMPgetError( SMPmatrix *, int *, int *);
int SMPcProdDiag( SMPmatrix *, SPcomplex *, int *);
int SMPcDProd(SMPmatrix *Matrix, SPcomplex *pMantissa, int *pExponent);

View File

@ -606,10 +606,14 @@ spFileVector(MatrixPtr eMatrix, char *File, RealVector RHS, RealVector iRHS)
/* Begin `spFileVector'. */
assert( IS_SPARSE( Matrix ) && RHS != NULL);
/* Open File in append mode. */
pMatrixFile = fopen(File,"a");
if (pMatrixFile == NULL)
return 0;
if (File) {
/* Open File in append mode. */
pMatrixFile = fopen(File,"a");
if (pMatrixFile == NULL)
return 0;
}
else
pMatrixFile=stdout;
/* Output vector. */
Size = Matrix->Size;
@ -634,7 +638,8 @@ spFileVector(MatrixPtr eMatrix, char *File, RealVector RHS, RealVector iRHS)
}
/* Close file. */
if (fclose(pMatrixFile) < 0) return 0;
if (File)
if (fclose(pMatrixFile) < 0) return 0;
return 1;
}

View File

@ -277,6 +277,16 @@ SMPpreOrder(SMPmatrix *Matrix)
return spError( Matrix );
}
/*
* SMPprint()
*/
void
SMPprintRHS(SMPmatrix *Matrix, char *Filename, RealVector RHS, RealVector iRHS)
{
spFileVector( Matrix, Filename, RHS, iRHS );
}
/*
* SMPprint()
*/