1 /*$Id: bm_complex.cc,v 26.137 2010/04/10 02:37:05 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)
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 * behavioral modeling complex value
23 * used with tc, etc, and conditionals
25 //testing=script 2006.07.13
29 /*--------------------------------------------------------------------------*/
31 /*--------------------------------------------------------------------------*/
32 class EVAL_BM_COMPLEX
: public EVAL_BM_ACTION_BASE
{
35 explicit EVAL_BM_COMPLEX(const EVAL_BM_COMPLEX
& p
);
37 explicit EVAL_BM_COMPLEX(int c
=0);
39 private: // override virtual
40 bool operator==(const COMMON_COMPONENT
&)const;
41 COMMON_COMPONENT
* clone()const {return new EVAL_BM_COMPLEX(*this);}
42 void print_common_obsolete_callback(OMSTREAM
&, LANGUAGE
*)const;
43 void tr_eval(ELEMENT
*)const;
44 void ac_eval(ELEMENT
*)const;
45 std::string
name()const {return "complex";}
46 bool ac_too()const {untested();return true;}
47 bool parse_numlist(CS
&);
49 /*--------------------------------------------------------------------------*/
50 /*--------------------------------------------------------------------------*/
51 EVAL_BM_COMPLEX::EVAL_BM_COMPLEX(int c
)
52 :EVAL_BM_ACTION_BASE(c
),
56 /*--------------------------------------------------------------------------*/
57 EVAL_BM_COMPLEX::EVAL_BM_COMPLEX(const EVAL_BM_COMPLEX
& p
)
58 :EVAL_BM_ACTION_BASE(p
),
62 /*--------------------------------------------------------------------------*/
63 bool EVAL_BM_COMPLEX::operator==(const COMMON_COMPONENT
& x
)const
65 const EVAL_BM_COMPLEX
* p
= dynamic_cast<const EVAL_BM_COMPLEX
*>(&x
);
67 && _value
== p
->_value
68 && EVAL_BM_ACTION_BASE::operator==(x
);
74 /*--------------------------------------------------------------------------*/
75 void EVAL_BM_COMPLEX::print_common_obsolete_callback(OMSTREAM
& o
, LANGUAGE
* lang
)const
79 << _value
.real() << ',' << _value
.imag() << ')';
80 EVAL_BM_ACTION_BASE::print_common_obsolete_callback(o
, lang
);
82 /*--------------------------------------------------------------------------*/
83 void EVAL_BM_COMPLEX::tr_eval(ELEMENT
* d
)const
85 tr_finish_tdv(d
, _value
.real());
87 /*--------------------------------------------------------------------------*/
88 void EVAL_BM_COMPLEX::ac_eval(ELEMENT
* d
)const
91 ac_final_adjust_with_temp(&(d
->_ev
));
93 /*--------------------------------------------------------------------------*/
94 bool EVAL_BM_COMPLEX::parse_numlist(CS
& cmd
)
96 unsigned here
= cmd
.cursor();
97 double real
= NOT_VALID
;
100 if (cmd
.gotit(here
)) {
101 _value
= COMPLEX(real
,imag
);
108 /*--------------------------------------------------------------------------*/
109 /*--------------------------------------------------------------------------*/
110 EVAL_BM_COMPLEX
p1(CC_STATIC
);
111 DISPATCHER
<COMMON_COMPONENT
>::INSTALL
d1(&bm_dispatcher
, "complex", &p1
);
113 /*--------------------------------------------------------------------------*/
114 /*--------------------------------------------------------------------------*/
115 // vim:ts=8:sw=2:noet: