[Pkg-electronics-commits] [gnucap] 30/43: spice-wrapper: use DPAIR instead of COMPLEX for spice matrix mapping

felix salfelder felix-guest at moszumanska.debian.org
Wed Oct 4 03:21:46 UTC 2017


This is an automated email from the git hooks/post-receive script.

felix-guest pushed a commit to branch master
in repository gnucap.

commit ca878ea8b04864474ae8b730e15642fd41ae715e
Author: al davis <ad211 at freeelectron.net>
Date:   Wed Jun 7 11:17:29 2017 -0400

    spice-wrapper: use DPAIR instead of COMPLEX for spice matrix mapping
    
    C++11 complex does not have lvalue real() and imag(),
    so use DPAIR instead in spice-wrapper.cc.
    also .. untested() reflects gnucap-models plugins use.
---
 include/m_matrix.h       |  8 ++++----
 include/patchlev.h       |  2 +-
 include/spice-wrapper.cc | 38 +++++++++++++++++++++-----------------
 3 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/include/m_matrix.h b/include/m_matrix.h
index fa7cfcc..b08895b 100644
--- a/include/m_matrix.h
+++ b/include/m_matrix.h
@@ -1,4 +1,4 @@
-/*$Id: m_matrix.h 2016/09/14 $ -*- C++ -*-
+/*$Id: m_matrix.h 2017/06/07 $ -*- C++ -*-
  * Copyright (C) 2001 Albert Davis
  * Author: Albert Davis <aldavis at gnu.org>
  *
@@ -537,12 +537,12 @@ T BSMATRIX<T>::s(int row, int col)const
 /*--------------------------------------------------------------------------*/
 template <class T>
 void BSMATRIX<T>::load_point(int i, int j, T value)
-{untested();
-  if (i > 0 && j > 0) {untested();
+{
+  if (i > 0 && j > 0) {
     set_changed(j);
     set_changed(i);
     m(i,j) += value;
-  }else{untested();
+  }else{
   }
 }
 /*--------------------------------------------------------------------------*/
diff --git a/include/patchlev.h b/include/patchlev.h
index c6740eb..2c25240 100644
--- a/include/patchlev.h
+++ b/include/patchlev.h
@@ -1 +1 @@
-#define PATCHLEVEL "develop 2017.05.20"
+#define PATCHLEVEL "spice-wrapper 2017.06.07"
diff --git a/include/spice-wrapper.cc b/include/spice-wrapper.cc
index 200c2cc..a1c1a4d 100644
--- a/include/spice-wrapper.cc
+++ b/include/spice-wrapper.cc
@@ -1,4 +1,4 @@
-/* $Id: spice-wrapper.cc 2016/09/17 $ -*- C++ -*-
+/* $Id: spice-wrapper.cc 2017/06/07 $ -*- C++ -*-
  * Copyright (C) 2007 Albert Davis
  * Author: Albert Davis <aldavis at gnu.org>
  *
@@ -28,6 +28,7 @@ extern "C" {
   #define public PubliC
   #define bool BooL
   #define main MaiN
+  #define setenv SetenV
   #include "capabil.h"
   #include "const.h"
   #include "iferrmsg.h"
@@ -39,6 +40,7 @@ extern "C" {
   #include "inpdefs.h"
   #include "tskdefs.h"
 #endif
+  #undef setenv
   #undef main
   #undef bool
   #undef public
@@ -192,8 +194,8 @@ private:
   const MODEL_SPICE* _model;
   const SPICE_MODEL_DATA* _spice_model;
   node_t _nodes[MATRIX_NODES];
-  COMPLEX* _matrix[MATRIX_NODES+OFFSET];	// For tran, real is now, imag is saved.
-  COMPLEX _matrix_core[MATRIX_NODES+OFFSET][MATRIX_NODES+OFFSET];
+  DPAIR* _matrix[MATRIX_NODES+OFFSET];	// For tran, real is now, imag is saved.
+  DPAIR _matrix_core[MATRIX_NODES+OFFSET][MATRIX_NODES+OFFSET];
 public:
   double _i0[MATRIX_NODES+OFFSET];	// right side - current offsets or ac real part
   double _i1[MATRIX_NODES+OFFSET];	// right side - saved ......... or ac imag part
@@ -1227,7 +1229,7 @@ bool DEV_SPICE::do_tr()
 
     for (int ii = 0; ii < matrix_nodes()+OFFSET; ++ii) {
       for (int jj = 0; jj < matrix_nodes()+OFFSET; ++jj) {
-	_matrix[ii][jj].real(0.);
+	_matrix[ii][jj].first = 0.;
       }
     }
   }
@@ -1248,7 +1250,7 @@ bool DEV_SPICE::do_tr()
   }
   for (int ii = 0; converged() && ii < matrix_nodes()+OFFSET; ++ii) {
     for (int jj = 0; converged() && jj < matrix_nodes()+OFFSET; ++jj) {
-      set_converged(conchk(_matrix[ii][jj].real(), _matrix[ii][jj].imag()));
+      set_converged(conchk(_matrix[ii][jj].first, _matrix[ii][jj].second));
     }
   }
 
@@ -1269,7 +1271,7 @@ bool DEV_SPICE::do_tr()
   }
   for (int ii = 0; !needs_load && ii < matrix_nodes()+OFFSET; ++ii) {
     for (int jj = 0; !needs_load && jj < matrix_nodes()+OFFSET; ++jj) {
-      needs_load = !conchk(_matrix[ii][jj].real(), _matrix[ii][jj].imag(),
+      needs_load = !conchk(_matrix[ii][jj].first, _matrix[ii][jj].second,
 			   0, OPT::reltol*OPT::loadtol);
     }
   }
@@ -1314,8 +1316,8 @@ void DEV_SPICE::tr_load()
 	  jhit[nj] = ni;
 	  int njj = nj-OFFSET;
 	  trace2("", jj, nj);
-	  trace2("", _matrix[nii][njj].real(), _matrix[nii][njj].imag());
-	  tr_load_point(_n[ii], _n[jj], &(_matrix[nii][njj].real()), &(_matrix[nii][njj].imag()));
+	  trace2("", _matrix[nii][njj].first, _matrix[nii][njj].second);
+	  tr_load_point(_n[ii], _n[jj], &(_matrix[nii][njj].first), &(_matrix[nii][njj].second));
 	}else{
 	  trace2("skip", jj, nj);
 	}
@@ -1331,7 +1333,7 @@ void DEV_SPICE::tr_unload()
 
   for (int ii = 0; ii < matrix_nodes(); ++ii) {untested();
     for (int jj = 0; jj < matrix_nodes(); ++jj) {untested();
-      _matrix[ii][jj].real() = 0;
+      _matrix[ii][jj].first = 0.;
     }
   }
   _sim->mark_inc_mode_bad();
@@ -1479,7 +1481,7 @@ void DEV_SPICE::do_ac()
     std::fill_n(_i1, matrix_nodes()+OFFSET, 0);
     for (int ii = 0; ii < matrix_nodes()+OFFSET; ++ii) {
       for (int jj = 0; jj < matrix_nodes()+OFFSET; ++jj) {
-	_matrix[ii][jj] = 0;
+	_matrix[ii][jj] = DPAIR(0.,0.);
       }
     }
     
@@ -1524,8 +1526,10 @@ void DEV_SPICE::ac_load()
 	    jhit[nj] = ni;
 	    int njj = nj-OFFSET;
 	    trace3("", jj, nj, njj);
-	    trace2("", _matrix[nii][njj].real(), _matrix[nii][njj].imag());
-	    ac_load_point(_n[ii], _n[jj], _matrix[nii][njj]);
+	    trace2("", _matrix[nii][njj].first, _matrix[nii][njj].second);
+	    //ac_load_point(_n[ii], _n[jj], _matrix[nii][njj]);
+	    DPAIR& dp = _matrix[nii][njj];
+	    ac_load_point(_n[ii], _n[jj], COMPLEX(dp.first, dp.second));
 	  }else{
 	    trace2("skip", jj, nj);
 	  }
@@ -1840,7 +1844,7 @@ extern "C" {
       assert(r < MATRIX_NODES+OFFSET);
       assert(c >= 0+OFFSET);
       assert(c < MATRIX_NODES+OFFSET);
-      COMPLEX** m = reinterpret_cast<COMPLEX**>(mm);
+      DPAIR** m = reinterpret_cast<DPAIR**>(mm);
       assert(m);
       assert(m[r-OFFSET]);
       return reinterpret_cast<double*>(&(m[r-OFFSET][c-OFFSET]));
@@ -1873,10 +1877,10 @@ extern "C" {
 // This is not guaranteed by the standard, but is believed to always be true.
 static struct COMPLEX_TEST {
   COMPLEX_TEST() {
-    COMPLEX x;
-    COMPLEX* px = &x;
-    double* prx = &x.real();
-    double* pix = &x.imag();
+    DPAIR x;
+    DPAIR* px = &x;
+    double* prx = &x.first;
+    double* pix = &x.second;
     assert(reinterpret_cast<void*>(prx) == reinterpret_cast<void*>(px));
     assert(reinterpret_cast<void*>(pix-1) == reinterpret_cast<void*>(px));
   }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-electronics/gnucap.git



More information about the Pkg-electronics-commits mailing list