turn {DEV,MODEL}_SUBCKT into base class
[gnucap-felix.git] / include / m_phase.h
bloba4ba34cb7c18661d8986318f85193fe7870d1abe
1 /*$Id: m_phase.h,v 26.118 2009/08/22 21:08:57 al Exp $ -*- C++ -*-
2 * Copyright (C) 2008 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.
22 //testing=script 2008.06.06
23 #ifndef M_PHASE_H
24 #define M_PHASE_H
25 #include "constant.h"
26 #include "u_opt.h"
27 /*--------------------------------------------------------------------------*/
28 /* phase: extract phase (degrees) from COMPLEX number
29 * rotates 90 degrees! (ref to sine instead of cosine)
31 inline double phase(COMPLEX x)
33 double rv = NOT_VALID;
34 switch (OPT::phase) {
35 case pDEGREES:
36 rv = arg(x)*RTOD;
37 break;
38 case pP_DEGREES:untested();
39 rv = arg(x)*RTOD;
40 if (rv < 0) {untested();
41 rv += 360;
42 }else{untested();
44 break;
45 case pN_DEGREES:itested();
46 rv = arg(x)*RTOD;
47 if (rv > 0) {itested();
48 rv -= 360;
49 }else{itested();
51 break;
52 case pRADIANS:
53 rv = arg(x);
54 break;
56 return rv;
58 /*--------------------------------------------------------------------------*/
59 /*--------------------------------------------------------------------------*/
60 #endif
61 // vim:ts=8:sw=2:noet: