testing
[gnucap-felix.git] / src / bm_complex.cc
blob1a3159f085f75178ff0a6e25fd0feb745b8df7e9
1 /*$Id: bm_complex.cc,v 1.2 2009-12-13 17:55:01 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)
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 * behavioral modeling complex value
23 * used with tc, etc, and conditionals
25 //testing=script 2006.07.13
26 #include "e_elemnt.h"
27 #include "bm.h"
28 /*--------------------------------------------------------------------------*/
29 namespace {
30 /*--------------------------------------------------------------------------*/
31 class EVAL_BM_COMPLEX : public EVAL_BM_ACTION_BASE {
32 private:
33 COMPLEX _value;
34 void set_param_by_name(string /*Name*/, string /*Value*/){incomplete();}
35 // static map<string, PARA_BASE EVAL_BM_SIN::*> param_dict;
36 explicit EVAL_BM_COMPLEX(const EVAL_BM_COMPLEX& p);
37 public:
38 explicit EVAL_BM_COMPLEX(int c=0);
39 ~EVAL_BM_COMPLEX() {}
40 private: // override virtual
41 bool operator==(const COMMON_COMPONENT&)const;
42 COMMON_COMPONENT* clone()const {return new EVAL_BM_COMPLEX(*this);}
43 void print_common_obsolete_callback(OMSTREAM&, LANGUAGE*)const;
44 void tr_eval(ELEMENT*)const;
45 void ac_eval(ELEMENT*)const;
46 std::string name()const {return "complex";}
47 bool ac_too()const {untested();return true;}
48 bool parse_numlist(CS&);
50 /*--------------------------------------------------------------------------*/
51 /*--------------------------------------------------------------------------*/
52 EVAL_BM_COMPLEX::EVAL_BM_COMPLEX(int c)
53 :EVAL_BM_ACTION_BASE(c),
54 _value(NOT_INPUT)
57 /*--------------------------------------------------------------------------*/
58 EVAL_BM_COMPLEX::EVAL_BM_COMPLEX(const EVAL_BM_COMPLEX& p)
59 :EVAL_BM_ACTION_BASE(p),
60 _value(p._value)
63 /*--------------------------------------------------------------------------*/
64 bool EVAL_BM_COMPLEX::operator==(const COMMON_COMPONENT& x)const
66 const EVAL_BM_COMPLEX* p = dynamic_cast<const EVAL_BM_COMPLEX*>(&x);
67 bool rv = p
68 && _value == p->_value
69 && EVAL_BM_ACTION_BASE::operator==(x);
70 return rv;
72 /*--------------------------------------------------------------------------*/
73 void EVAL_BM_COMPLEX::print_common_obsolete_callback(OMSTREAM& o, LANGUAGE* lang)const
75 assert(lang);
76 o << name() << '('
77 << _value.real() << ',' << _value.imag() << ')';
78 EVAL_BM_ACTION_BASE::print_common_obsolete_callback(o, lang);
80 /*--------------------------------------------------------------------------*/
81 void EVAL_BM_COMPLEX::tr_eval(ELEMENT* d)const
83 tr_finish_tdv(d, _value.real());
85 /*--------------------------------------------------------------------------*/
86 void EVAL_BM_COMPLEX::ac_eval(ELEMENT* d)const
88 d->_ev = _value;
89 ac_final_adjust_with_temp(&(d->_ev));
91 /*--------------------------------------------------------------------------*/
92 bool EVAL_BM_COMPLEX::parse_numlist(CS& cmd)
94 unsigned here = cmd.cursor();
95 double real = NOT_VALID;
96 double imag = 0.;
97 cmd >> real >> imag;
98 if (cmd.gotit(here)) {
99 _value = COMPLEX(real,imag);
100 return true;
101 }else{
102 untested();
103 return false;
106 /*--------------------------------------------------------------------------*/
107 /*--------------------------------------------------------------------------*/
108 EVAL_BM_COMPLEX p1(CC_STATIC);
109 DISPATCHER<COMMON_COMPONENT>::INSTALL d1(&bm_dispatcher, "complex", &p1);
111 /*--------------------------------------------------------------------------*/
112 /*--------------------------------------------------------------------------*/
113 // vim:ts=8:sw=2:noet: