turn {DEV,MODEL}_SUBCKT into base class
[gnucap-felix.git] / include / e_aux.h
blobfb47f37a37cec033b66ab8885b07f8a810c6aed8
1 /*$Id: e_aux.h,v 26.83 2008/06/05 04:46:59 al Exp $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *------------------------------------------------------------------
22 * helper functions, etc., that sort of belong to circuit elements
24 //testing=script 2007.07.13
25 #ifndef E_AUX_H
26 #define E_AUX_H
27 #include "e_node.h"
28 /*--------------------------------------------------------------------------*/
29 template <class T>
30 T port_impedance(const node_t& n1, const node_t& n2,
31 BSMATRIX<T>& mat, const T& parallel)
33 T* zapit = new T[mat.size()+2];
35 for (int ii = 0; ii < mat.size()+2; ++ii) {
36 zapit[ii] = 0.;
38 if (n1.m_() != 0) {
39 zapit[n1.m_()] = 1.;
40 }else{untested();
42 if (n2.m_() != 0) {untested();
43 zapit[n2.m_()] = -1.;
44 }else{
47 mat.fbsub(zapit);
48 T raw_z = zapit[n1.m_()] - zapit[n2.m_()];
49 delete [] zapit;
50 return (parallel != 0.)
51 ? 1. / ((1./raw_z)-parallel)
52 : raw_z;
54 /*--------------------------------------------------------------------------*/
55 /*--------------------------------------------------------------------------*/
56 #endif
57 // vim:ts=8:sw=2:noet: