My Project
0.0.16
QUCS Mapping
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
DownLoad
QUCS-src
qucs-0.0.16
qucs-core
src
analysis.cpp
Go to the documentation of this file.
1
/*
2
* analysis.cpp - analysis class implementation
3
*
4
* Copyright (C) 2003-2008 Stefan Jahn <stefan@lkcc.org>
5
*
6
* This is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* This software is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this package; see the file COPYING. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19
* Boston, MA 02110-1301, USA.
20
*
21
* $Id: analysis.cpp 1825 2011-03-11 20:42:14Z ela $
22
*
23
*/
24
25
#if HAVE_CONFIG_H
26
# include <config.h>
27
#endif
28
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <string.h>
32
33
#include "
object.h
"
34
#include "
complex.h
"
35
#include "
sweep.h
"
36
#include "
vector.h
"
37
#include "
strlist.h
"
38
#include "
dataset.h
"
39
#include "
ptrlist.h
"
40
#include "
analysis.h
"
41
42
// Constructor creates an unnamed instance of the analysis class.
43
analysis::analysis
() :
object
() {
44
data
= NULL;
45
subnet
= NULL;
46
env
= NULL;
47
actions
= NULL;
48
type
=
ANALYSIS_UNKNOWN
;
49
runs
= 0;
50
progress
=
true
;
51
}
52
53
// Constructor creates a named instance of the analysis class.
54
analysis::analysis
(
char
*
n
) :
object
(n) {
55
data
= NULL;
56
subnet
= NULL;
57
env
= NULL;
58
actions
= NULL;
59
type
=
ANALYSIS_UNKNOWN
;
60
runs
= 0;
61
progress
=
true
;
62
}
63
64
// Destructor deletes the analysis class object.
65
analysis::~analysis
() {
66
if
(
actions
)
delete
actions
;
67
}
68
69
/* The copy constructor creates a new instance of the analysis class
70
based on the given analysis object. */
71
analysis::analysis
(
analysis
& a) :
object
(a) {
72
data
= a.
data
;
73
subnet
= a.
subnet
;
74
env
= a.
env
;
75
actions
= a.
actions
?
new
ptrlist<analysis>
(*a.
actions
) : NULL;
76
type
= a.
type
;
77
runs
= a.
runs
;
78
progress
= a.
progress
;
79
}
80
81
/* This function adds the given analysis to the actions being
82
associated with the current analysis object. */
83
void
analysis::addAnalysis
(
analysis
* a) {
84
if
(!
actions
)
actions
=
new
ptrlist<analysis>
();
85
actions
->
add
(a);
86
}
87
88
/* This function deletes the given analysis from the actions being
89
associated with the current analysis object. */
90
void
analysis::delAnalysis
(
analysis
* a) {
91
if
(
actions
)
actions
->
del
(a);
92
}
93
94
/* The following function creates a sweep object depending on the
95
analysis's properties. Supported sweep types are: linear,
96
logarithmic, lists and constants. */
97
sweep
*
analysis::createSweep
(
const
char
*
n
) {
98
sweep
* swp = NULL;
99
// get type of sweep
100
char
*
type
=
getPropertyString
(
"Type"
);
101
102
// linearly or logarithmically stepped sweeps
103
if
(!strcmp (type,
"lin"
) || !strcmp (type,
"log"
)) {
104
nr_double_t start =
getPropertyDouble
(
"Start"
);
105
nr_double_t stop =
getPropertyDouble
(
"Stop"
);
106
int
points =
getPropertyInteger
(
"Points"
);
107
if
(!strcmp (type,
"lin"
)) {
108
swp =
new
linsweep
(n);
109
((
linsweep
*) swp)->create (start, stop, points);
110
}
111
else
if
(!strcmp (type,
"log"
)) {
112
swp =
new
logsweep
(n);
113
((
logsweep
*) swp)->create (start, stop, points);
114
}
115
}
116
117
// lists of values
118
else
if
(!strcmp (type,
"list"
)) {
119
vector
* values =
getPropertyVector
(
"Values"
);
120
int
points = values->
getSize
();
121
swp =
new
lstsweep
(n);
122
((
lstsweep
*) swp)->create (points);
123
for
(
int
i
= 0;
i
< values->
getSize
();
i
++)
124
swp->
set
(
i
,
real
(values->
get
(
i
)));
125
}
126
127
// constant value
128
else
if
(!strcmp (type,
"const"
)) {
129
nr_double_t val =
getPropertyDouble
(
"Values"
);
130
swp =
new
consweep
(n);
131
((
consweep
*) swp)->create (1);
132
swp->
set
(0, val);
133
}
134
135
swp->
setParent
(
this
);
136
return
swp;
137
}
138
139
/* Saves the given variable into the dataset. Creates the dataset
140
vector if necessary. */
141
void
analysis::saveVariable
(
const
char
*
n
,
nr_complex_t
z,
vector
* f) {
142
vector
* d;
143
if
((d =
data
->
findVariable
(n)) == NULL) {
144
d =
new
vector
(n);
145
if
(f != NULL) {
146
d->
setDependencies
(
new
strlist
());
147
d->
getDependencies
()->
add
(f->
getName
());
148
}
149
d->
setOrigin
(
getName
());
150
data
->
addVariable
(d);
151
}
152
d->
add
(z);
153
}
Generated on Tue Dec 25 2012 14:28:05 for My Project by
1.8.2