1 /*$Id: e_aux.h,v 1.1 2009-10-23 12:01:45 felix 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)
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
21 *------------------------------------------------------------------
22 * helper functions, etc., that sort of belong to circuit elements
24 //testing=script 2007.07.13
29 /*--------------------------------------------------------------------------*/
31 T
port_impedance(const node_t
& n1
, const node_t
& n2
,
32 BSMATRIX
<T
>& mat
, const T
& parallel
)
34 T
* zapit
= new T
[mat
.size()+2];
36 for (unsigned ii
= 0; ii
< mat
.size()+2; ++ii
) {
43 if (n2
.m_() != 0) {untested();
49 T raw_z
= zapit
[n1
.m_()] - zapit
[n2
.m_()];
51 return (parallel
!= 0.)
52 ? 1. / ((1./raw_z
)-parallel
)
55 /*--------------------------------------------------------------------------*/
56 inline void set_sens_port(const node_t
& n1
, const node_t
& n2
)
58 std::fill_n(CKT_BASE::_sim
->_sens
, 1*CKT_BASE::_sim
->_total_nodes
+1, 0);
59 CKT_BASE::_sim
->_sens
[n1
.m_()] = 1;
61 CKT_BASE::_sim
->_sens
[n2
.m_()] = -1;
63 // weird, _sens[0] shouldnt do anything
66 /*--------------------------------------------------------------------------*/
67 inline COMPLEX
port_noise(const node_t
& n1
, const node_t
& n2
){
69 ::status
.back
.start();
70 CKT_BASE::_sim
->_acx
.fbsubt(CKT_BASE::_sim
->_sens
);
72 double a
= CARD_LIST::card_list
.do_noise();
75 /*--------------------------------------------------------------------------*/
76 /*--------------------------------------------------------------------------*/
78 // vim:ts=8:sw=2:noet: