testing
[gnucap-felix.git] / src / measure_at.cc
bloba75412f0f420ba4203ae95bf74b30ed9d05c092a
1 /*$Id: measure_at.cc,v 1.2 2009-12-13 17:55:01 felix Exp $ -*- C++ -*-
2 * vim:ts=8:sw=2:et:
3 * Copyright (C) 2008 Albert Davis
4 * Author: Albert Davis <aldavis@gnu.org>
6 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3, or (at your option)
11 * any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *------------------------------------------------------------------
24 #include "u_parameter.h"
25 #include "m_wave.h"
26 #include "u_function.h"
27 /*--------------------------------------------------------------------------*/
28 namespace {
29 /*--------------------------------------------------------------------------*/
30 class MEASURE : public WAVE_FUNCTION {
31 PARAMETER<double> x;
32 bool derivative;
33 public:
34 MEASURE() :
35 WAVE_FUNCTION(),
36 derivative(false)
38 virtual FUNCTION_BASE* clone()const { return new MEASURE(*this);}
39 string label() const{return "at";}
40 void expand(CS& Cmd, const CARD_LIST* Scope){
41 unsigned here = Cmd.cursor();
42 Cmd >> probe_name;
43 _w = find_wave(probe_name);
45 if (!_w) {
46 Cmd.reset(here);
47 }else{
49 x = BIGBIG;
50 derivative=false;
52 here = Cmd.cursor();
53 do {
54 ONE_OF
55 || Get(Cmd, "probe", &probe_name)
56 || Get(Cmd, "x", &x)
57 || Get(Cmd, "at", &x)
58 || Get(Cmd, "deriv{ative}", &derivative)
60 }while (Cmd.more() && !Cmd.stuck(&here));
62 if (!_w) {
63 _w = find_wave(probe_name);
64 }else{
66 x.e_val(BIGBIG, Scope);
68 /*--------------------------------------------------------------------------*/
69 fun_t wave_eval()const
71 if (_w) {
72 return to_fun_t((derivative) ? (_w->v_out(x).f1) : (_w->v_out(x).f0));
73 }else{
74 throw Exception_No_Match(probe_name);
77 } p1;
78 DISPATCHER<FUNCTION_BASE>::INSTALL d1(&measure_dispatcher, "at", &p1);
79 /*--------------------------------------------------------------------------*/
81 /*--------------------------------------------------------------------------*/
82 /*--------------------------------------------------------------------------*/
83 // vim:ts=8:sw=2:noet: