Skip to content

Commit

Permalink
Fedora port, updates fixing "this" handling from sparse, wrspif.
Browse files Browse the repository at this point in the history
  • Loading branch information
wrcad committed Jul 3, 2017
1 parent 9db512f commit cfdde82
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 165 deletions.
9 changes: 6 additions & 3 deletions wrspice/src/fte/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CCOBJS = $(CCFILES:.cc=.o)
INCLUDE = -I../../include -I$(LPATH)/ginterf -I$(LPATH)/miscutil \
-I$(LPATH)/malloc $(PSINCL)

$(LIB_TARGET): $(CCOBJS)
$(LIB_TARGET): include $(CCOBJS)
@if [ -f $(LIB_TARGET) ]; then \
rm -f $(LIB_TARGET); \
fi
Expand All @@ -47,6 +47,9 @@ $(LIB_TARGET): $(CCOBJS)
paramsub.cc: $(LPATH)/spnumber/paramsub.cc
cp -f $(LPATH)/spnumber/paramsub.cc .

include:
cd ../../include; $(MAKE)

depend: paramsub.cc
@echo depending in wrspice/fte
@if [ x$(DEPEND_DONE) = x ]; then \
Expand All @@ -55,9 +58,9 @@ depend: paramsub.cc
fi

clean:
-rm *.o $(LIB_TARGET)
-rm *.o $(LIB_TARGET) paramsub.cc

distclean:
-rm *.o $(LIB_TARGET) Makefile paramsub.cc
-rm *.o $(LIB_TARGET) paramsub.cc Makefile

#######################################################################
2 changes: 1 addition & 1 deletion wrspice/src/fte/source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,7 @@ sLine::process_conditionals(sParamTab *ptab)
}
else if (lstring::cimatch(PARAM_KW, dd->li_line)) {
if (!blhead && !insc) {
ptab = ptab->extract_params(dd->li_line);
ptab = sParamTab::extract_params(ptab, dd->li_line);
if (ptab->errString) {
dd->li_error = ptab->errString;
ptab->errString = 0;
Expand Down
14 changes: 7 additions & 7 deletions wrspice/src/fte/subexpand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ sScGlobal::expand_and_replace(sLine *deck, sParamTab **parm_ptr,
return (0);
}
sg_stack[sg_stack_ptr].subs = blk->cb_subs->copy();
*parm_ptr = (*parm_ptr)->update(blk->cb_prms);
*parm_ptr = sParamTab::update(*parm_ptr, blk->cb_prms);
IP.setModCache(blk->cb_mods);

// Swap in the cached function definitions.
Expand Down Expand Up @@ -487,20 +487,20 @@ sScGlobal::expand_and_replace(sLine *deck, sParamTab **parm_ptr,
// Above-scope parameter assignments override
// lower assignments.

ptab = ptab->update(sss->su_params);
ptab = sParamTab::update(ptab, sss->su_params);
if (params) {
if (!ptab)
ptab = new sParamTab;
ptab->update(params);
}
ptab = ptab->update(*parm_ptr);
ptab = sParamTab::update(ptab, *parm_ptr);
}
else {
// The "local" expansion mode, lower level parameter
// assignments override upper level.

ptab = ptab->update(*parm_ptr);
ptab = ptab->update(sss->su_params);
ptab = sParamTab::update(ptab, *parm_ptr);
ptab = sParamTab::update(ptab, sss->su_params);
if (params) {
if (!ptab)
ptab = new sParamTab;
Expand Down Expand Up @@ -2155,7 +2155,7 @@ sSubc::sSubc(sLine *def)
// First extract params defined in .subckt line.
su_params = 0;
if (pars) {
su_params = su_params->extract_params(pars);
su_params = sParamTab::extract_params(su_params, pars);
if (sParamTab::errString) {
def->errcat(sParamTab::errString);
delete [] sParamTab::errString;
Expand All @@ -2169,7 +2169,7 @@ sSubc::sSubc(sLine *def)

for (sLine *li = def; li; li = li->next()) {
if (lstring::cimatch(PARAM_KW, li->line())) {
su_params = su_params->extract_params(li->line());
su_params = sParamTab::extract_params(su_params, li->line());
li->comment_out();
if (sParamTab::errString) {
li->errcat(sParamTab::errString);
Expand Down
5 changes: 4 additions & 1 deletion wrspice/src/misc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CCFILES = \
CCOBJS = $(CCFILES:.cc=.o)
INCLUDE = -I../../include -I$(LPATH)/ginterf -I$(LPATH)/miscutil -I$(VLPATH)

$(LIB_TARGET): $(CCOBJS)
$(LIB_TARGET): include $(CCOBJS)
@if [ -f $(LIB_TARGET) ]; then \
rm -f $(LIB_TARGET); \
fi
Expand All @@ -43,6 +43,9 @@ hash.cc: $(LPATH)/spnumber/hash.cc
spnumber.cc: $(LPATH)/spnumber/spnumber.cc
spparse.cc: $(LPATH)/spnumber/spparse.cc

include:
cd ../../include; $(MAKE)

depend: $(NFILES)
@echo depending in wrspice/misc
@if [ x$(DEPEND_DONE) = x ]; then \
Expand Down
5 changes: 4 additions & 1 deletion wrspice/src/sparse/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ INCLUDE = -I../../include -I$(LPATH)/ginterf -I$(LPATH)/miscutil \
-I$(KPATH)/AMD/Include -I$(KPATH)/BTF/Include -I$(KPATH)/COLAMD/Include \
-I$(KPATH)/KLU/Include -I$(KPATH)/SuiteSparse_config

$(LIB_TARGET): $(SP_HFILES) $(CCOBJS)
$(LIB_TARGET): include $(SP_HFILES) $(CCOBJS)
@if [ -f $(LIB_TARGET) ]; then \
rm -f $(LIB_TARGET); \
fi
Expand All @@ -48,6 +48,9 @@ spoutput.cc: $(LPATH)/sparse/spoutput.cc
spsolve.cc: $(LPATH)/sparse/spsolve.cc
sputils.cc: $(LPATH)/sparse/sputils.cc

include:
cd ../../include; $(MAKE)

depend: $(SP_HFILES) $(CCFILES)
@echo depending in wrspice/sparse
@if [ x$(DEPEND_DONE) = x ]; then \
Expand Down
9 changes: 0 additions & 9 deletions wrspice/src/sparse/spmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@
#define AND &&
#define OR ||

#define SPARSE_ID 0x772773 // Arbitrary (is Sparse on phone).
#define IS_SPARSE(matrix) ((matrix) != 0 && \
(matrix)->ID == SPARSE_ID)
#define IS_VALID(matrix) ((matrix) != 0 && \
(matrix)->ID == SPARSE_ID && \
(matrix)->Error >= spOKAY && \
(matrix)->Error < spFATAL)
#define IS_FACTORED(matrix) ((matrix)->Factored && !(matrix)->NeedsOrdering)

// Macro commands
// Macro functions that return the maximum or minimum independent of type.
#ifndef SPMIN
Expand Down
5 changes: 4 additions & 1 deletion xic/src/sparse/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CCFILES = spbuild.cc spfactor.cc spsolve.cc sputils.cc
CCOBJS = $(CCFILES:.cc=.o)
INCLUDE = -I../../include -I$(LPATH)/miscutil

$(LIB_TARGET): $(HFILES) $(CCOBJS)
$(LIB_TARGET): include $(HFILES) $(CCOBJS)
@if [ -f $(LIB_TARGET) ]; then \
rm -f $(LIB_TARGET); \
fi
Expand All @@ -43,6 +43,9 @@ spfactor.cc: $(LPATH)/sparse/spfactor.cc
spsolve.cc: $(LPATH)/sparse/spsolve.cc
sputils.cc: $(LPATH)/sparse/sputils.cc

include:
cd ../../include; $(MAKE)

depend: $(HFILES) $(CCFILES)
@echo depending in xic/sparse
@if [ x$(DEPEND_DONE) = x ]; then \
Expand Down
5 changes: 4 additions & 1 deletion xic/src/wrspif/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CCFILES = $(SPFILES)
CCOBJS = $(CCFILES:.cc=.o)
INCLUDE = -I../../include -I$(LPATH)/ginterf -I$(LPATH)/miscutil

$(LIB_TARGET): $(CCOBJS)
$(LIB_TARGET): include $(CCOBJS)
@if [ -f $(LIB_TARGET) ]; then \
rm -f $(LIB_TARGET); \
fi
Expand All @@ -42,6 +42,9 @@ paramsub.cc: $(LPATH)/spnumber/paramsub.cc
spnumber.cc: $(LPATH)/spnumber/spnumber.cc
spparse.cc: $(LPATH)/spnumber/spparse.cc

include:
cd ../../include; $(MAKE)

depend: $(SPFILES)
@echo depending in xic/wrspif
@if [ x$(DEPEND_DONE) = x ]; then \
Expand Down
24 changes: 1 addition & 23 deletions xt_base/sparse/spbuild.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ spMatrixFrame::spMatrixFrame(int size, int flags)

RelThreshold = DEFAULT_THRESHOLD;
AbsThreshold = 0.0;
ID = SPARSE_ID;
#if SP_OPT_INTERRUPT
InterruptCallback = 0;
#endif
Expand Down Expand Up @@ -300,8 +299,6 @@ spMatrixFrame::spMatrixFrame(int size, int flags)
//
spMatrixFrame::~spMatrixFrame()
{
ASSERT(IS_SPARSE(this));

// Deallocate the vectors that are located in the matrix frame.
delete [] FirstInCol;
delete [] FirstInRow;
Expand Down Expand Up @@ -339,8 +336,6 @@ spMatrixFrame::~spMatrixFrame()
void
spMatrixFrame::spClear()
{
ASSERT(IS_SPARSE(this));

if (Matrix)
Matrix->clear();
else {
Expand Down Expand Up @@ -406,7 +401,7 @@ spMatrixFrame::spClear()
spREAL *
spMatrixFrame::spGetElement(int inrow, int incol)
{
ASSERT(IS_SPARSE(this) AND inrow >= 0 AND incol >= 0);
ASSERT(inrow >= 0 AND incol >= 0);

if ((inrow == 0) OR (incol == 0))
return (&TrashCan.Real);
Expand Down Expand Up @@ -822,8 +817,6 @@ spGetInitInfo(spREAL *pElement)
int
spMatrixFrame::spInitialize(spInitializeFunc pInit)
{
ASSERT(IS_SPARSE(this));

// Initialize the matrix
for (int j = Size; j > 0; j--) {
spMatrixElement *pElement = FirstInCol[j];
Expand Down Expand Up @@ -1408,11 +1401,6 @@ spHtab::~spHtab()
spMatrixElement *
spHtab::get(int row, int col)
{
{
spHtab *ht = this;
if (!ht)
return (0);
}
if (allocated) {
getcalls++;
unsigned int i = number_hash(row, col, mask);
Expand Down Expand Up @@ -1440,16 +1428,6 @@ spHtab::link(spHelt *h)
void
spHtab::stats(unsigned int *pg, unsigned int *pa)
{
{
spHtab *ht = this;
if (!ht) {
if (pg)
*pg = 0;
if (pa)
*pa = 0;
return;
}
}
if (pg)
*pg = getcalls;
if (pa)
Expand Down
5 changes: 2 additions & 3 deletions xt_base/sparse/spfactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int
spMatrixFrame::spOrderAndFactor(spREAL *rhs, spREAL relThreshold,
spREAL absThreshold, spBOOLEAN diagPivoting)
{
ASSERT(IS_VALID(this) AND NOT Factored);
ASSERT(NOT Factored);

Error = spOKAY;
ReorderFailed = NO;
Expand Down Expand Up @@ -436,7 +436,7 @@ spMatrixFrame::spOrderAndFactor(spREAL *rhs, spREAL relThreshold,
int
spMatrixFrame::spFactor()
{
ASSERT(IS_VALID(this) AND NOT Factored);
ASSERT(NOT Factored);

if (NeedsOrdering)
return (spOrderAndFactor(0, 0.0, 0.0, DIAG_PIVOTING_AS_DEFAULT));
Expand Down Expand Up @@ -1277,7 +1277,6 @@ spMatrixFrame::FactorComplexMatrix()
void
spMatrixFrame::spPartition(int mode)
{
ASSERT(IS_SPARSE(this));
if (Partitioned)
return;
Partitioned = YES;
Expand Down
9 changes: 0 additions & 9 deletions xt_base/sparse/spmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@
#define AND &&
#define OR ||

#define SPARSE_ID 0x772773 // Arbitrary (is Sparse on phone).
#define IS_SPARSE(matrix) ((matrix) != 0 && \
(matrix)->ID == SPARSE_ID)
#define IS_VALID(matrix) ((matrix) != 0 && \
(matrix)->ID == SPARSE_ID && \
(matrix)->Error >= spOKAY && \
(matrix)->Error < spFATAL)
#define IS_FACTORED(matrix) ((matrix)->Factored && !(matrix)->NeedsOrdering)

// Macro commands
// Macro functions that return the maximum or minimum independent of type.
#ifndef SPMIN
Expand Down
13 changes: 11 additions & 2 deletions xt_base/sparse/spmatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,9 @@ class spMatrixFrame
}

#endif
// Former macros.
spBOOLEAN IS_VALID() { return (Error >= spOKAY && Error < spFATAL); }
spBOOLEAN IS_FACTORED() { return (Factored && !NeedsOrdering); }

spBOOLEAN spNeedsOrdering()
{
Expand Down Expand Up @@ -1339,14 +1342,21 @@ class spMatrixFrame
//
spMatrixElement *sph_get(int row, int col)
{
return (ElementHashTab->get(row, col));
return (ElementHashTab ? ElementHashTab->get(row, col) : 0);
}

// Return the sph_get call count and the allocated size. The call
// count is zeroed.
//
void sph_stats(unsigned int *pg, unsigned int *pa)
{
if (!ElementHashTab) {
if (pg)
*pg = 0;
if (pa)
*pa = 0;
return;
}
ElementHashTab->stats(pg, pa);
}

Expand Down Expand Up @@ -1509,7 +1519,6 @@ class spMatrixFrame
spREAL RelThreshold;
spREAL AbsThreshold;
spMatrixElement TrashCan;
unsigned long ID;
#if SP_OPT_INTERRUPT
int (*InterruptCallback)();
#endif
Expand Down
10 changes: 1 addition & 9 deletions xt_base/sparse/spoutput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ void
spMatrixFrame::spPrint(int printReordered, int data, int header, FILE *fp)
#endif
{
ASSERT(IS_SPARSE(this));

double *pImagElements[PRINTER_WIDTH/10+1];
double smallestDiag = 0.0, smallestElement = 0.0;
double largestElement = 0.0, largestDiag = 0.0;
Expand Down Expand Up @@ -437,8 +435,6 @@ spMatrixFrame::spPrint(int printReordered, int data, int header, FILE *fp)
void
spMatrixFrame::spPrint(int printReordered, int data, int header)
{
ASSERT(IS_SPARSE(this));

double *pImagElements[PRINTER_WIDTH/10+1];
double smallestDiag = 0.0, smallestElement = 0.0;
double largestElement = 0.0, largestDiag = 0.0;
Expand Down Expand Up @@ -735,8 +731,6 @@ int
spMatrixFrame::spFileMatrix(char *file, char *label, int reordered, int data,
int header)
{
ASSERT(IS_SPARSE(this));

// Open file matrix file in write mode.
FILE *pMatrixFile;
if ((pMatrixFile = fopen(file, "w")) == 0)
Expand Down Expand Up @@ -891,7 +885,7 @@ spMatrixFrame::spFileMatrix(char *file, char *label, int reordered, int data,
int
spMatrixFrame::spFileVector(char *file, spREAL *rhs IMAG_RHS_P)
{
ASSERT(IS_SPARSE(this) AND RHS != 0)
ASSERT(RHS != 0)

// Open File in append mode.
FILE *pMatrixFile;
Expand Down Expand Up @@ -998,8 +992,6 @@ spMatrixFrame::spFileVector(char *file, spREAL *rhs IMAG_RHS_P)
int
spMatrixFrame::spFileStats(char *file, char *label)
{
ASSERT(IS_SPARSE(this));

// Open File in append mode
FILE *pStatsFile;
if ((pStatsFile = fopen(file, "a")) == 0)
Expand Down
Loading

0 comments on commit cfdde82

Please sign in to comment.