Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vector.cpp
Go to the documentation of this file.
1 /*
2  * vector.cpp - vector class implementation
3  *
4  * Copyright (C) 2003, 2004, 2005, 2006, 2007 Stefan Jahn <stefan@lkcc.org>
5  * Copyright (C) 2006, 2007 Gunther Kraut <gn.kraut@t-online.de>
6  *
7  * This 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 2, or (at your option)
10  * any later version.
11  *
12  * This software 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.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this package; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  * $Id$
23  *
24  */
25 
26 #if HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29 
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <cmath>
34 #include <float.h>
35 #include <assert.h>
36 
37 #include "real.h"
38 #include "complex.h"
39 #include "object.h"
40 #include "logging.h"
41 #include "strlist.h"
42 #include "vector.h"
43 #include "consts.h"
44 
45 namespace qucs {
46 
47 // Constructor creates an unnamed instance of the vector class.
49  capacity = size = 0;
50  data = NULL;
51  dependencies = NULL;
52  origin = NULL;
53  requested = 0;
54 }
55 
56 /* Constructor creates an unnamed instance of the vector class with a
57  given initial size. */
58 vector::vector (int s) : object () {
59  assert (s >= 0);
60  capacity = size = s;
61  data = s > 0 ? (nr_complex_t *)
62  calloc (capacity, sizeof (nr_complex_t)) : NULL;
63  dependencies = NULL;
64  origin = NULL;
65  requested = 0;
66 }
67 
68 /* Constructor creates an unnamed instance of the vector class with a
69  given initial size and content. */
71  assert (s >= 0);
72  capacity = size = s;
73  data = s > 0 ? (nr_complex_t *)
74  calloc (capacity, sizeof (nr_complex_t)) : NULL;
75  for (int i = 0; i < s; i++) data[i] = val;
76  dependencies = NULL;
77  origin = NULL;
78  requested = 0;
79 }
80 
81 // Constructor creates an named instance of the vector class.
82 vector::vector (const char * n) : object (n) {
83  capacity = size = 0;
84  data = NULL;
85  dependencies = NULL;
86  origin = NULL;
87  requested = 0;
88 }
89 
90 /* This constructor creates a named instance of the vector class with
91  a given initial size. */
92 vector::vector (const char * n, int s) : object (n) {
93  assert (s >= 0);
94  capacity = size = s;
95  data = s > 0 ? (nr_complex_t *)
96  calloc (capacity, sizeof (nr_complex_t)) : NULL;
97  dependencies = NULL;
98  origin = NULL;
99  requested = 0;
100 }
101 
102 /* The copy constructor creates a new instance based on the given
103  vector object. */
104 vector::vector (const vector & v) : object (v) {
105  size = v.size;
106  capacity = v.capacity;
107  data = (nr_complex_t *) malloc (sizeof (nr_complex_t) * capacity);
108  memcpy (data, v.data, sizeof (nr_complex_t) * size);
109  dependencies = v.dependencies ? new strlist (*v.dependencies) : NULL;
110  origin = v.origin ? strdup (v.origin) : NULL;
111  requested = v.requested;
112 }
113 
114 /* The assignment copy constructor creates a new instance based on the
115  given vector object. It copies the data only and leaves any other
116  properties untouched. */
117 const vector& vector::operator=(const vector & v) {
118  if (&v != this) {
119  size = v.size;
120  capacity = v.capacity;
121  if (data) { free (data); data = NULL; }
122  if (capacity > 0) {
123  data = (nr_complex_t *) malloc (sizeof (nr_complex_t) * capacity);
124  if (size > 0) memcpy (data, v.data, sizeof (nr_complex_t) * size);
125  }
126  }
127  return *this;
128 }
129 
130 // Destructor deletes a vector object.
132  if (data) free (data);
133  if (dependencies) delete dependencies;
134  if (origin) free (origin);
135 }
136 
137 // Returns data dependencies.
139  return dependencies;
140 }
141 
142 // Sets the data dependencies.
144  if (dependencies) delete dependencies;
145  dependencies = s;
146 }
147 
148 /* The function appends a new complex data item to the end of the
149  vector and ensures that the vector can hold the increasing number
150  of data items. */
152  if (data == NULL) {
153  size = 0; capacity = 64;
154  data = (nr_complex_t *) malloc (sizeof (nr_complex_t) * capacity);
155  }
156  else if (size >= capacity) {
157  capacity *= 2;
158  data = (nr_complex_t *) realloc (data, sizeof (nr_complex_t) * capacity);
159  }
160  data[size++] = c;
161 }
162 
163 /* This function appends the given vector to the vector. */
164 void vector::add (vector * v) {
165  if (v != NULL) {
166  if (data == NULL) {
167  size = 0; capacity = v->getSize ();
168  data = (nr_complex_t *) malloc (sizeof (nr_complex_t) * capacity);
169  }
170  else if (size + v->getSize () > capacity) {
171  capacity += v->getSize ();
172  data = (nr_complex_t *) realloc (data, sizeof (nr_complex_t) * capacity);
173  }
174  for (int i = 0; i < v->getSize (); i++) data[size++] = v->get (i);
175  }
176 }
177 
178 // Returns the complex data item at the given position.
180  return data[i];
181 }
182 
183 void vector::set (nr_double_t d, int i) {
184  data[i] = nr_complex_t (d);
185 }
186 
187 void vector::set (const nr_complex_t z, int i) {
188  data[i] = nr_complex_t (z);
189 }
190 
191 // The function returns the current size of the vector.
192 int vector::getSize (void) const {
193  return size;
194 }
195 
197  if (v1.getSize () != v2.getSize ()) {
198  logprint (LOG_ERROR, "vector '%s' and '%s' have different sizes\n",
199  v1.getName (), v2.getName ());
200  return 0;
201  }
202  return 1;
203 }
204 
205 // searches the maximum value of the vector elements.
206 // complex numbers in the 1. and 4. quadrant are counted as "abs(c)".
207 // complex numbers in the 2. and 3. quadrant are counted as "-abs(c)".
208 nr_double_t vector::maximum (void) {
209  nr_complex_t c;
210  nr_double_t d, max_D = -NR_MAX;
211  for (int i = 0; i < getSize (); i++) {
212  c = data[i];
213  d = fabs (arg (c)) < M_PI_2 ? abs (c) : -abs (c);
214  if (d > max_D) max_D = d;
215  }
216  return max_D;
217 }
218 
219 // searches the minimum value of the vector elements.
220 // complex numbers in the 1. and 4. quadrant are counted as "abs(c)".
221 // complex numbers in the 2. and 3. quadrant are counted as "-abs(c)".
222 nr_double_t vector::minimum (void) {
223  nr_complex_t c;
224  nr_double_t d, min_D = +NR_MAX;
225  for (int i = 0; i < getSize (); i++) {
226  c = data[i];
227  d = fabs (arg (c)) < M_PI_2 ? abs (c) : -abs (c);
228  if (d < min_D) min_D = d;
229  }
230  return min_D;
231 }
232 
233 /* Unwraps a phase vector in radians. Adds +/- 2*Pi if consecutive
234  values jump about |Pi|. */
235 vector unwrap (vector v, nr_double_t tol, nr_double_t step) {
236  vector result (v.getSize ());
237  nr_double_t add = 0;
238  result (0) = v (0);
239  for (int i = 1; i < v.getSize (); i++) {
240  nr_double_t diff = real (v (i) - v (i-1));
241  if (diff > +tol) {
242  add -= step;
243  } else if (diff < -tol) {
244  add += step;
245  }
246  result (i) = v (i) + add;
247  }
248  return result;
249 }
250 
251 nr_complex_t sum (vector v) {
252  nr_complex_t result (0.0);
253  for (int i = 0; i < v.getSize (); i++) result += v.get (i);
254  return result;
255 }
256 
257 nr_complex_t prod (vector v) {
258  nr_complex_t result (1.0);
259  for (int i = 0; i < v.getSize (); i++) result *= v.get (i);
260  return result;
261 }
262 
263 nr_complex_t avg (vector v) {
264  nr_complex_t result (0.0);
265  for (int i = 0; i < v.getSize (); i++) result += v.get (i);
266  return result / (nr_double_t) v.getSize ();
267 }
268 
269 vector signum (vector v) {
270  vector result (v);
271  for (int i = 0; i < v.getSize (); i++) result.set (signum (v.get (i)), i);
272  return result;
273 }
274 
275 vector sign (vector v) {
276  vector result (v);
277  for (int i = 0; i < v.getSize (); i++) result.set (sign (v.get (i)), i);
278  return result;
279 }
280 
281 vector xhypot (vector v, const nr_complex_t z) {
282  vector result (v);
283  for (int i = 0; i < v.getSize (); i++) result.set (xhypot (v.get(i), z), i);
284  return result;
285 }
286 
287 vector xhypot (vector v, const nr_double_t d) {
288  vector result (v);
289  for (int i = 0; i < v.getSize (); i++) result.set (xhypot (v.get(i), d), i);
290  return result;
291 }
292 
293 vector xhypot (const nr_complex_t z, vector v) {
294  vector result (v);
295  for (int i = 0; i < v.getSize (); i++) result.set (xhypot (z, v.get (i)), i);
296  return result;
297 }
298 
299 vector xhypot (const nr_double_t d, vector v) {
300  vector result (v);
301  for (int i = 0; i < v.getSize (); i++) result.set (xhypot (d, v.get (i)), i);
302  return result;
303 }
304 
305 vector xhypot (vector v1, vector v2) {
306  int j, i, n, len, len1 = v1.getSize (), len2 = v2.getSize ();
307  if (len1 >= len2) {
308  assert (len1 % len2 == 0);
309  len = len1;
310  } else {
311  assert (len2 % len1 == 0);
312  len = len2;
313  }
314  vector res (len);
315  for (j = i = n = 0; n < len; n++) {
316  res (n) = xhypot (v1 (i), v2 (j));
317  if (++i >= len1) i = 0; if (++j >= len2) j = 0;
318  }
319  return res;
320 }
321 
322 vector sinc (vector v) {
323  vector result (v);
324  for (int i = 0; i < v.getSize (); i++) result.set (sinc (v.get (i)), i);
325  return result;
326 }
327 
328 vector abs (vector v) {
329  vector result (v);
330  for (int i = 0; i < v.getSize (); i++) result.set (abs (v.get (i)), i);
331  return result;
332 }
333 
334 vector norm (vector v) {
335  vector result (v);
336  for (int i = 0; i < v.getSize (); i++) result.set (norm (v.get (i)), i);
337  return result;
338 }
339 
340 vector arg (vector v) {
341  vector result (v);
342  for (int i = 0; i < v.getSize (); i++) result.set (arg (v.get (i)), i);
343  return result;
344 }
345 
346 vector real (vector v) {
347  vector result (v);
348  for (int i = 0; i < v.getSize (); i++) result.set (real (v.get (i)), i);
349  return result;
350 }
351 
352 vector imag (vector v) {
353  vector result (v);
354  for (int i = 0; i < v.getSize (); i++) result.set (imag (v.get (i)), i);
355  return result;
356 }
357 
358 vector conj (vector v) {
359  vector result (v);
360  for (int i = 0; i < v.getSize (); i++) result.set (conj (v.get (i)), i);
361  return result;
362 }
363 
364 vector dB (vector v) {
365  vector result (v);
366  for (int i = 0; i < v.getSize (); i++)
367  result.set (10.0 * std::log10 (norm (v.get (i))), i);
368  return result;
369 }
370 
371 vector sqrt (vector v) {
372  vector result (v);
373  for (int i = 0; i < v.getSize (); i++) result.set (sqrt (v.get (i)), i);
374  return result;
375 }
376 
377 vector exp (vector v) {
378  vector result (v);
379  for (int i = 0; i < v.getSize (); i++) result.set (exp (v.get (i)), i);
380  return result;
381 }
382 
383 vector limexp (vector v) {
384  vector result (v);
385  for (int i = 0; i < v.getSize (); i++) result.set (limexp (v.get (i)), i);
386  return result;
387 }
388 
389 vector log (vector v) {
390  vector result (v);
391  for (int i = 0; i < v.getSize (); i++) result.set (log (v.get (i)), i);
392  return result;
393 }
394 
395 vector log10 (vector v) {
396  vector result (v);
397  for (int i = 0; i < v.getSize (); i++) result.set (log10 (v.get (i)), i);
398  return result;
399 }
400 
401 vector log2 (vector v) {
402  vector result (v);
403  for (int i = 0; i < v.getSize (); i++) result.set (log2 (v.get (i)), i);
404  return result;
405 }
406 
407 vector pow (vector v, const nr_complex_t z) {
408  vector result (v);
409  for (int i = 0; i < v.getSize (); i++) result.set (pow (v.get(i), z), i);
410  return result;
411 }
412 
413 vector pow (vector v, const nr_double_t d) {
414  vector result (v);
415  for (int i = 0; i < v.getSize (); i++) result.set (pow (v.get(i), d), i);
416  return result;
417 }
418 
419 vector pow (const nr_complex_t z, vector v) {
420  vector result (v);
421  for (int i = 0; i < v.getSize (); i++) result.set (pow (z, v.get (i)), i);
422  return result;
423 }
424 
425 vector pow (const nr_double_t d, vector v) {
426  vector result (v);
427  for (int i = 0; i < v.getSize (); i++) result.set (pow (d, v.get (i)), i);
428  return result;
429 }
430 
431 vector pow (vector v1, vector v2) {
432  int j, i, n, len, len1 = v1.getSize (), len2 = v2.getSize ();
433  if (len1 >= len2) {
434  assert (len1 % len2 == 0);
435  len = len1;
436  } else {
437  assert (len2 % len1 == 0);
438  len = len2;
439  }
440  vector res (len);
441  for (j = i = n = 0; n < len; n++) {
442  res (n) = pow (v1 (i), v2 (j));
443  if (++i >= len1) i = 0; if (++j >= len2) j = 0;
444  }
445  return res;
446 }
447 
448 vector sin (vector v) {
449  vector result (v);
450  for (int i = 0; i < v.getSize (); i++) result.set (sin (v.get (i)), i);
451  return result;
452 }
453 
454 vector asin (vector v) {
455  vector result (v);
456  for (int i = 0; i < v.getSize (); i++) result.set (asin (v.get (i)), i);
457  return result;
458 }
459 
460 vector acos (vector v) {
461  vector result (v);
462  for (int i = 0; i < v.getSize (); i++) result.set (acos (v.get (i)), i);
463  return result;
464 }
465 
466 vector cos (vector v) {
467  vector result (v);
468  for (int i = 0; i < v.getSize (); i++) result.set (cos (v.get (i)), i);
469  return result;
470 }
471 
472 vector tan (vector v) {
473  vector result (v);
474  for (int i = 0; i < v.getSize (); i++) result.set (tan (v.get (i)), i);
475  return result;
476 }
477 
478 vector atan (vector v) {
479  vector result (v);
480  for (int i = 0; i < v.getSize (); i++) result.set (atan (v.get (i)), i);
481  return result;
482 }
483 
484 vector cot (vector v) {
485  vector result (v);
486  for (int i = 0; i < v.getSize (); i++) result.set (cot (v.get (i)), i);
487  return result;
488 }
489 
490 vector acot (vector v) {
491  vector result (v);
492  for (int i = 0; i < v.getSize (); i++) result.set (acot (v.get (i)), i);
493  return result;
494 }
495 
496 vector sinh (vector v) {
497  vector result (v);
498  for (int i = 0; i < v.getSize (); i++) result.set (sinh (v.get (i)), i);
499  return result;
500 }
501 
502 vector asinh (vector v) {
503  vector result (v);
504  for (int i = 0; i < v.getSize (); i++) result.set (asinh (v.get (i)), i);
505  return result;
506 }
507 
508 vector cosh (vector v) {
509  vector result (v);
510  for (int i = 0; i < v.getSize (); i++) result.set (cosh (v.get (i)), i);
511  return result;
512 }
513 
514 vector sech (vector v) {
515  vector result (v);
516  for (int i = 0; i < v.getSize (); i++) result.set (sech (v.get (i)), i);
517  return result;
518 }
519 
520 vector cosech (vector v) {
521  vector result (v);
522  for (int i = 0; i < v.getSize (); i++) result.set (cosech (v.get (i)), i);
523  return result;
524 }
525 
526 vector acosh (vector v) {
527  vector result (v);
528  for (int i = 0; i < v.getSize (); i++) result.set (acosh (v.get (i)), i);
529  return result;
530 }
531 
532 vector asech (vector v) {
533  vector result (v);
534  for (int i = 0; i < v.getSize (); i++) result.set (asech (v.get (i)), i);
535  return result;
536 }
537 
538 vector tanh (vector v) {
539  vector result (v);
540  for (int i = 0; i < v.getSize (); i++) result.set (tanh (v.get (i)), i);
541  return result;
542 }
543 
544 vector atanh (vector v) {
545  vector result (v);
546  for (int i = 0; i < v.getSize (); i++) result.set (atanh (v.get (i)), i);
547  return result;
548 }
549 
550 vector coth (vector v) {
551  vector result (v);
552  for (int i = 0; i < v.getSize (); i++) result.set (coth (v.get (i)), i);
553  return result;
554 }
555 
556 vector acoth (vector v) {
557  vector result (v);
558  for (int i = 0; i < v.getSize (); i++) result.set (acoth (v.get (i)), i);
559  return result;
560 }
561 
562 // converts impedance to reflexion coefficient
563 vector ztor (vector v, nr_complex_t zref) {
564  vector result (v);
565  for (int i = 0; i < v.getSize (); i++) result (i) = ztor (v (i), zref);
566  return result;
567 }
568 
569 // converts admittance to reflexion coefficient
570 vector ytor (vector v, nr_complex_t zref) {
571  vector result (v);
572  for (int i = 0; i < v.getSize (); i++) result (i) = ytor (v (i), zref);
573  return result;
574 }
575 
576 // converts reflexion coefficient to impedance
577 vector rtoz (vector v, nr_complex_t zref) {
578  vector result (v);
579  for (int i = 0; i < v.getSize (); i++) result (i) = rtoz (v (i), zref);
580  return result;
581 }
582 
583 // converts reflexion coefficient to admittance
584 vector rtoy (vector v, nr_complex_t zref) {
585  vector result (v);
586  for (int i = 0; i < v.getSize (); i++) result (i) = rtoy (v (i), zref);
587  return result;
588 }
589 
590 // differentiates 'var' with respect to 'dep' exactly 'n' times
591 vector diff (vector var, vector dep, int n) {
592  int k, xi, yi, exchange = 0;
593  vector x, y;
594  // exchange dependent and independent variable if necessary
595  if (var.getSize () < dep.getSize ()) {
596  x = vector (var);
597  y = vector (dep);
598  exchange++;
599  }
600  else {
601  x = vector (dep);
602  y = vector (var);
603  }
604  assert (y.getSize () % x.getSize () == 0 && x.getSize () >= 2);
605  vector result (y);
606  nr_complex_t c;
607 
608  for (k = 0; k < n; k++) { // differentiate n times
609  for (yi = xi = 0; yi < y.getSize (); yi++, xi++) {
610  if (xi == x.getSize ()) xi = 0; // roll through independent vector
611  if (xi == 0) {
612  c = (y.get (yi + 1) - y.get (yi)) / (x.get (xi + 1) - x.get (xi));
613  } else if (xi == x.getSize () - 1) {
614  c = (y.get (yi) - y.get (yi - 1)) / (x.get (xi) - x.get (xi - 1));
615  }
616  else {
617  c =
618  ((y.get (yi) - y.get (yi - 1)) / (x.get (xi) - x.get (xi - 1)) +
619  (y.get (yi + 1) - y.get (yi)) / (x.get (xi + 1) - x.get (xi))) /
620  2.0;
621  }
622  result.set (exchange ? 1.0 / c : c, yi);
623  }
624  y = result;
625  }
626  return result;
627 }
628 
630  for (int i = 0; i < size; i++) data[i] = c;
631  return *this;
632 }
633 
634 vector vector::operator=(const nr_double_t d) {
635  for (int i = 0; i < size; i++) data[i] = d;
636  return *this;
637 }
638 
640  int i, n, len = v.getSize ();
641  assert (size % len == 0);
642  for (i = n = 0; i < size; i++) { data[i] += v (n); if (++n >= len) n = 0; }
643  return *this;
644 }
645 
647  for (int i = 0; i < size; i++) data[i] += c;
648  return *this;
649 }
650 
651 vector vector::operator+=(const nr_double_t d) {
652  for (int i = 0; i < size; i++) data[i] += d;
653  return *this;
654 }
655 
656 vector operator+(vector v1, vector v2) {
657  int len1 = v1.getSize (), len2 = v2.getSize ();
658  vector result;
659  if (len1 >= len2) {
660  result = v1;
661  result += v2;
662  } else {
663  result = v2;
664  result += v1;
665  }
666  return result;
667 }
668 
669 vector operator+(vector v, const nr_complex_t c) {
670  vector result (v);
671  result += c;
672  return result;
673 }
674 
675 vector operator+(const nr_complex_t c, vector v) {
676  return v + c;
677 }
678 
679 vector operator+(vector v, const nr_double_t d) {
680  vector result (v);
681  result += d;
682  return result;
683 }
684 
685 vector operator+(const nr_double_t d, vector v) {
686  return v + d;
687 }
688 
690  vector result (size);
691  for (int i = 0; i < size; i++) result (i) = -data[i];
692  return result;
693 }
694 
696  int i, n, len = v.getSize ();
697  assert (size % len == 0);
698  for (i = n = 0; i < size; i++) { data[i] -= v (n); if (++n >= len) n = 0; }
699  return *this;
700 }
701 
703  for (int i = 0; i < size; i++) data[i] -= c;
704  return *this;
705 }
706 
707 vector vector::operator-=(const nr_double_t d) {
708  for (int i = 0; i < size; i++) data[i] -= d;
709  return *this;
710 }
711 
712 vector operator-(vector v1, vector v2) {
713  int len1 = v1.getSize (), len2 = v2.getSize ();
714  vector result;
715  if (len1 >= len2) {
716  result = v1;
717  result -= v2;
718  } else {
719  result = -v2;
720  result += v1;
721  }
722  return result;
723 }
724 
725 vector operator-(vector v, const nr_complex_t c) {
726  vector result (v);
727  result -= c;
728  return result;
729 }
730 
731 vector operator-(vector v, const nr_double_t d) {
732  vector result (v);
733  result -= d;
734  return result;
735 }
736 
737 vector operator-(const nr_complex_t c, vector v) {
738  vector result (-v);
739  result += c;
740  return result;
741 }
742 
743 vector operator-(const nr_double_t d, vector v) {
744  vector result (-v);
745  result += d;
746  return result;
747 }
748 
750  int i, n, len = v.getSize ();
751  assert (size % len == 0);
752  for (i = n = 0; i < size; i++) { data[i] *= v (n); if (++n >= len) n = 0; }
753  return *this;
754 }
755 
757  for (int i = 0; i < size; i++) data[i] *= c;
758  return *this;
759 }
760 
761 vector vector::operator*=(const nr_double_t d) {
762  for (int i = 0; i < size; i++) data[i] *= d;
763  return *this;
764 }
765 
766 vector operator*(vector v1, vector v2) {
767  int len1 = v1.getSize (), len2 = v2.getSize ();
768  vector result;
769  if (len1 >= len2) {
770  result = v1;
771  result *= v2;
772  } else {
773  result = v2;
774  result *= v1;
775  }
776  return result;
777 }
778 
779 vector operator*(vector v, const nr_complex_t c) {
780  vector result (v);
781  result *= c;
782  return result;
783 }
784 
785 vector operator*(vector v, const nr_double_t d) {
786  vector result (v);
787  result *= d;
788  return result;
789 }
790 
791 vector operator*(const nr_complex_t c, vector v) {
792  return v * c;
793 }
794 
795 vector operator*(const nr_double_t d, vector v) {
796  return v * d;
797 }
798 
800  int i, n, len = v.getSize ();
801  assert (size % len == 0);
802  for (i = n = 0; i < size; i++) { data[i] /= v (n); if (++n >= len) n = 0; }
803  return *this;
804 }
805 
807  for (int i = 0; i < size; i++) data[i] /= c;
808  return *this;
809 }
810 
811 vector vector::operator/=(const nr_double_t d) {
812  for (int i = 0; i < size; i++) data[i] /= d;
813  return *this;
814 }
815 
816 vector operator/(vector v1, vector v2) {
817  int len1 = v1.getSize (), len2 = v2.getSize ();
818  vector result;
819  if (len1 >= len2) {
820  assert (len1 % len2 == 0);
821  result = v1;
822  result /= v2;
823  } else {
824  assert (len2 % len1 == 0);
825  result = 1 / v2;
826  result *= v1;
827  }
828  return result;
829 }
830 
831 vector operator/(vector v, const nr_complex_t c) {
832  vector result (v);
833  result /= c;
834  return result;
835 }
836 
837 vector operator/(vector v, const nr_double_t d) {
838  vector result (v);
839  result /= d;
840  return result;
841 }
842 
843 vector operator/(const nr_complex_t c, vector v) {
844  vector result (v);
845  result = c;
846  result /= v;
847  return result;
848 }
849 
850 vector operator/(const nr_double_t d, vector v) {
851  vector result (v);
852  result = d;
853  result /= v;
854  return result;
855 }
856 
857 vector operator%(vector v, const nr_complex_t z) {
858  int len = v.getSize ();
859  vector result (len);
860  for (int i = 0; i < len; i++) result (i) = v (i) % z;
861  return result;
862 }
863 
864 vector operator%(vector v, const nr_double_t d) {
865  int len = v.getSize ();
866  vector result (len);
867  for (int i = 0; i < len; i++) result (i) = v (i) % d;
868  return result;
869 }
870 
871 vector operator%(const nr_complex_t z, vector v) {
872  int len = v.getSize ();
873  vector result (len);
874  for (int i = 0; i < len; i++) result (i) = z % v (i);
875  return result;
876 }
877 
878 vector operator%(const nr_double_t d, vector v) {
879  int len = v.getSize ();
880  vector result (len);
881  for (int i = 0; i < len; i++) result (i) = d % v (i);
882  return result;
883 }
884 
885 vector operator%(vector v1, vector v2) {
886  int j, i, n, len, len1 = v1.getSize (), len2 = v2.getSize ();
887  if (len1 >= len2) {
888  assert (len1 % len2 == 0);
889  len = len1;
890  } else {
891  assert (len2 % len1 == 0);
892  len = len2;
893  }
894  vector res (len);
895  for (j = i = n = 0; n < len; n++) {
896  res (n) = v1 (i) % v2 (j);
897  if (++i >= len1) i = 0; if (++j >= len2) j = 0;
898  }
899  return res;
900 }
901 
902 /* This function reverses the order of the data list. */
903 void vector::reverse (void) {
905  malloc (sizeof (nr_complex_t) * size);
906  for (int i = 0; i < size; i++) buffer[i] = data[size - 1 - i];
907  free (data);
908  data = buffer;
909  capacity = size;
910 }
911 
912 // Sets the origin (the analysis) of the vector.
913 void vector::setOrigin (char * n) {
914  if (origin) free (origin);
915  origin = n ? strdup (n) : NULL;
916 }
917 
918 // Returns the origin (the analysis) of the vector.
919 char * vector::getOrigin (void) {
920  return origin;
921 }
922 
923 /* The function returns the number of entries with the given value
924  deviating no more than the given epsilon. */
925 int vector::contains (nr_complex_t val, nr_double_t eps) {
926  int count = 0;
927  for (int i = 0; i < size; i++) {
928  if (abs (data[i] - val) <= eps) count++;
929  }
930  return count;
931 }
932 
933 // Sorts the vector either in ascending or descending order.
934 void vector::sort (bool ascending) {
935  nr_complex_t t;
936  for (int i = 0; i < size; i++) {
937  for (int n = 0; n < size - 1; n++) {
938  if (ascending ? data[n] > data[n+1] : data[n] < data[n+1]) {
939  t = data[n];
940  data[n] = data[n+1];
941  data[n+1] = t;
942  }
943  }
944  }
945 }
946 
947 /* The function creates a linear stepped vector of values starting at
948  the given start value, ending with the given stop value and
949  containing points elements. */
950 vector linspace (nr_double_t start, nr_double_t stop, int points) {
951  vector result (points);
952  nr_double_t val, step = (stop - start) / (points - 1);
953  for (int i = 0; i < points; i++) {
954  val = start + (i * step);
955  if (i != 0 && fabs (val) < fabs (step) / 4 && fabs (val) < NR_EPSI)
956  val = 0.0;
957  result.set (val, i);
958  }
959  return result;
960 }
961 
962 /* The function creates a logarithmic stepped vector of values
963  starting at the given start value, ending with the given stop value
964  and containing points elements. */
965 vector logspace (nr_double_t start, nr_double_t stop, int points) {
966  assert (start * stop > 0);
967  vector result (points);
968  nr_double_t step, first, last, d;
969 
970  // ensure the last value being larger than the first
971  if (fabs (start) > fabs (stop)) {
972  first = fabs (stop);
973  last = fabs (start);
974  }
975  else {
976  first = fabs (start);
977  last = fabs (stop);
978  }
979  // check direction and sign of values
980  d = fabs (start) > fabs (stop) ? -1 : 1;
981  // compute logarithmic step size
982  step = (::log (last) - ::log (first)) / (points - 1);
983  for (int i = 0, j = points - 1; i < points; i++, j--) {
984  if (d > 0)
985  result.set (start * ::exp (step * i), i);
986  else
987  result.set (stop * ::exp (step * i), j);
988  }
989  return result;
990 }
991 
992 vector cumsum (vector v) {
993  vector result (v);
994  nr_complex_t val (0.0);
995  for (int i = 0; i < v.getSize (); i++) {
996  val += v.get (i);
997  result.set (val, i);
998  }
999  return result;
1000 }
1001 
1002 vector cumavg (vector v) {
1003  vector result (v);
1004  nr_complex_t val (0.0);
1005  for (int i = 0; i < v.getSize (); i++) {
1006  val = (val * (nr_double_t) i + v.get (i)) / (i + 1.0);
1007  result.set (val, i);
1008  }
1009  return result;
1010 }
1011 
1012 vector cumprod (vector v) {
1013  vector result (v);
1014  nr_complex_t val (1.0);
1015  for (int i = 0; i < v.getSize (); i++) {
1016  val *= v.get (i);
1017  result.set (val, i);
1018  }
1019  return result;
1020 }
1021 
1022 vector ceil (vector v) {
1023  vector result (v);
1024  for (int i = 0; i < v.getSize (); i++) result.set (ceil (v.get (i)), i);
1025  return result;
1026 }
1027 
1028 vector fix (vector v) {
1029  vector result (v);
1030  for (int i = 0; i < v.getSize (); i++) result.set (fix (v.get (i)), i);
1031  return result;
1032 }
1033 
1034 vector floor (vector v) {
1035  vector result (v);
1036  for (int i = 0; i < v.getSize (); i++) result.set (floor (v.get (i)), i);
1037  return result;
1038 }
1039 
1040 vector round (vector v) {
1041  vector result (v);
1042  for (int i = 0; i < v.getSize (); i++) result.set (round (v.get (i)), i);
1043  return result;
1044 }
1045 
1046 vector sqr (vector v) {
1047  vector result (v);
1048  for (int i = 0; i < v.getSize (); i++) result.set (sqr (v.get (i)), i);
1049  return result;
1050 }
1051 
1052 vector step (vector v) {
1053  vector result (v);
1054  for (int i = 0; i < v.getSize (); i++) result.set (step (v.get (i)), i);
1055  return result;
1056 }
1057 
1058 static nr_double_t integrate_n (vector v) { /* using trapezoidal rule */
1059  nr_double_t result = 0.0;
1060  for (int i = 1; i < v.getSize () - 1; i++) result += norm (v.get (i));
1061  result += 0.5 * norm (v.get (0));
1062  result += 0.5 * norm (v.get (v.getSize () - 1));
1063  return result;
1064 }
1065 
1066 nr_double_t vector::rms (void) {
1067  nr_double_t result = std::sqrt (integrate_n (*this) / getSize ());
1068  return result;
1069 }
1070 
1071 nr_double_t vector::variance (void) {
1072  nr_double_t result = 0.0;
1073  nr_complex_t average = avg (*this);
1074  for (int i = 0; i < getSize (); i++) result += norm (get (i) - average);
1075  if (getSize () > 1)
1076  return result / (getSize () - 1);
1077  return 0.0;
1078 }
1079 
1080 nr_double_t vector::stddev (void) {
1081  return std::sqrt (variance ());
1082 }
1083 
1084 vector erf (vector v) {
1085  vector result (v);
1086  for (int i = 0; i < v.getSize (); i++) result.set (erf (v.get (i)), i);
1087  return result;
1088 }
1089 
1090 vector erfc (vector v) {
1091  vector result (v);
1092  for (int i = 0; i < v.getSize (); i++) result.set (erfc (v.get (i)), i);
1093  return result;
1094 }
1095 
1096 vector erfinv (vector v) {
1097  vector result (v);
1098  for (int i = 0; i < v.getSize (); i++) result.set (erfinv (v.get (i)), i);
1099  return result;
1100 }
1101 
1102 vector erfcinv (vector v) {
1103  vector result (v);
1104  for (int i = 0; i < v.getSize (); i++) result.set (erfcinv (v.get (i)), i);
1105  return result;
1106 }
1107 
1108 vector i0 (vector v) {
1109  vector result (v);
1110  for (int i = 0; i < v.getSize (); i++) result.set (i0 (v.get (i)), i);
1111  return result;
1112 }
1113 
1114 vector jn (const int n, vector v) {
1115  vector result (v);
1116  for (int i = 0; i < v.getSize (); i++) result.set (jn (n, v.get (i)), i);
1117  return result;
1118 }
1119 
1120 vector yn (const int n, vector v) {
1121  vector result (v);
1122  for (int i = 0; i < v.getSize (); i++) result.set (yn (n, v.get (i)), i);
1123  return result;
1124 }
1125 
1126 vector polar (const nr_complex_t a, vector v) {
1127  vector result (v);
1128  for (int i = 0; i < v.getSize (); i++) result.set (qucs::polar (a, v.get (i)), i);
1129  return result;
1130 }
1131 
1132 vector polar (vector v, const nr_complex_t p) {
1133  vector result (v);
1134  for (int i = 0; i < v.getSize (); i++) result.set (qucs::polar (v.get (i), p), i);
1135  return result;
1136 }
1137 
1138 vector polar (vector a, vector p) {
1139  int j, i, n, len, len1 = a.getSize (), len2 = p.getSize ();
1140  if (len1 >= len2) {
1141  assert (len1 % len2 == 0);
1142  len = len1;
1143  } else {
1144  assert (len2 % len1 == 0);
1145  len = len2;
1146  }
1147  vector res (len);
1148  for (j = i = n = 0; n < len; n++) {
1149  res (n) = qucs::polar (a (i), p (j));
1150  if (++i >= len1) i = 0; if (++j >= len2) j = 0;
1151  }
1152  return res;
1153 }
1154 
1155 vector atan2 (const nr_double_t y, vector v) {
1156  vector result (v);
1157  for (int i = 0; i < v.getSize (); i++)
1158  result.set (atan2 (y, v.get (i)), i);
1159  return result;
1160 }
1161 
1162 vector atan2 (vector v, const nr_double_t x) {
1163  vector result (v);
1164  for (int i = 0; i < v.getSize (); i++)
1165  result.set (atan2 (v.get (i), x) , i);
1166  return result;
1167 }
1168 
1169 vector atan2 (vector y, vector x) {
1170  int j, i, n, len, len1 = y.getSize (), len2 = x.getSize ();
1171  if (len1 >= len2) {
1172  assert (len1 % len2 == 0);
1173  len = len1;
1174  } else {
1175  assert (len2 % len1 == 0);
1176  len = len2;
1177  }
1178  vector res (len);
1179  for (j = i = n = 0; n < len; n++) {
1180  res (n) = atan2 (y (i), x (j));
1181  if (++i >= len1) i = 0; if (++j >= len2) j = 0;
1182  }
1183  return res;
1184 }
1185 
1186 vector w2dbm (vector v) {
1187  vector result (v);
1188  for (int i = 0; i < v.getSize (); i++)
1189  result.set (10.0 * log10 (v.get (i) / 0.001), i);
1190  return result;
1191 }
1192 
1193 vector dbm2w (vector v) {
1194  vector result (v);
1195  for (int i = 0; i < v.getSize (); i++)
1196  result.set (0.001 * pow (10.0 , v.get (i) / 10.0), i);
1197  return result;
1198 }
1199 
1200 nr_double_t integrate (vector v, const nr_double_t h) {
1201  nr_double_t s = real (v.get (0) ) / 2;
1202  for (int i = 1; i < v.getSize () - 1; i++)
1203  s += real (v.get (i));
1204  return (s + real (v.get (v.getSize () - 1) ) / 2) * h;
1205 }
1206 
1208  nr_complex_t s;
1209  s = v.get (0) / 2.0;
1210  for (int i = 1; i < v.getSize () - 1; i++)
1211  s += v.get (i);
1212  return (s + v.get (v.getSize () - 1) / 2.0) * h;
1213 }
1214 
1215 vector dbm (vector v, const nr_complex_t z) {
1216  vector result (v);
1217  for (int i = 0; i < v.getSize (); i++)
1218  result.set (10.0 * log10 (norm (v.get (i)) / conj (z) / 0.001), i);
1219  return result;
1220 }
1221 
1222 vector runavg (const nr_complex_t x, const int n) {
1223  vector result (n);
1224  for (int i = 0; i < n; i++) result.set (x, i);
1225  return result;
1226 }
1227 
1228 vector runavg (vector v, const int n) {
1229  nr_complex_t s (0.0), y;
1230  int len = v.getSize () - n + 1, i;
1231  vector result (len);
1232  for (i = 0; i < n; i++) s += v.get (i);
1233  y = s / (nr_double_t) n; // first running average value
1234  result.set (y, 0);
1235  for (i = 0; i < len - 1; i++) {
1236  y += (v.get (i + n) - v.get (i)) / (nr_double_t) n;
1237  result.set (y, i + 1);
1238  }
1239  return result;
1240 }
1241 
1242 #ifdef DEBUG
1243 // Debug function: Prints the vector object.
1244 void vector::print (void) {
1245  for (int r = 0; r < size; r++) {
1246  fprintf (stderr, "%+.2e%+.2ei\n", (double) real (get (r)),
1247  (double) imag (get (r)));
1248  }
1249 }
1250 #endif /* DEBUG */
1251 
1252 } // namespace qucs
start
Definition: parse_zvr.y:126
std::complex< nr_double_t > nr_complex_t
Definition: complex.h:31
vector w2dbm(vector)
Definition: vector.cpp:1186
vector cumavg(vector)
Definition: vector.cpp:1002
matrix real(matrix a)
Real part matrix.
Definition: matrix.cpp:568
matrix abs(matrix a)
Computes magnitude of each matrix element.
Definition: matrix.cpp:531
nr_complex_t erf(const nr_complex_t z)
Error function.
Definition: complex.cpp:766
friend vector norm(vector)
vector operator-()
Definition: vector.cpp:689
void setOrigin(char *)
Definition: vector.cpp:913
int getSize(void) const
Definition: vector.cpp:192
nr_complex_t ceil(const nr_complex_t z)
Complex ceil Ceil is the smallest integral value not less than argument Apply ceil to real and imagin...
Definition: complex.cpp:634
matrix operator*(matrix a, nr_complex_t z)
Matrix scaling complex version.
Definition: matrix.cpp:298
nr_complex_t coth(const nr_complex_t z)
Compute complex hyperbolic cotangent.
Definition: complex.cpp:320
qucs::vector runavg(qucs::vector, const int)
vector cumsum(vector)
Definition: vector.cpp:992
void reverse(void)
Definition: vector.cpp:903
nr_complex_t pow(const nr_complex_t z, const nr_double_t d)
Compute power function with real exponent.
Definition: complex.cpp:238
nr_complex_t cos(const nr_complex_t z)
Compute complex cosine.
Definition: complex.cpp:57
void sort(bool ascending=true)
Definition: vector.cpp:934
nr_complex_t sum(vector)
Definition: vector.cpp:251
nr_complex_t step(const nr_complex_t z)
Heaviside step function for complex number.
Definition: complex.cpp:691
t
Definition: parse_vcd.y:290
nr_complex_t avg(vector)
Definition: vector.cpp:263
friend vector arg(vector)
nr_complex_t signum(const nr_complex_t z)
complex signum function
Definition: complex.cpp:416
qucs::vector logspace(nr_double_t, nr_double_t, int)
Definition: vector.cpp:965
nr_complex_t atan(const nr_complex_t z)
Compute complex arc tangent.
Definition: complex.cpp:117
nr_complex_t cot(const nr_complex_t z)
Compute complex cotangent.
Definition: complex.cpp:298
nr_complex_t asech(const nr_complex_t z)
Compute complex argument hyperbolic secant.
Definition: complex.cpp:354
strlist * dependencies
Definition: parse_citi.y:225
nr_complex_t acot(const nr_complex_t z)
Compute complex arc cotangent.
Definition: complex.cpp:310
n
Definition: parse_citi.y:147
h
Definition: parse_vcd.y:214
r
Definition: parse_mdl.y:515
nr_complex_t acosh(const nr_complex_t z)
Compute complex arc hyperbolic cosine.
Definition: complex.cpp:162
nr_complex_t rtoz(const nr_complex_t r, nr_complex_t zref)
Converts reflexion coefficient to impedance.
Definition: complex.cpp:590
nr_complex_t sign(const nr_complex_t z)
complex sign function
Definition: complex.cpp:435
int checkSizes(vector, vector)
Definition: vector.cpp:196
nr_complex_t asinh(const nr_complex_t z)
Compute complex arc hyperbolic sine.
Definition: complex.cpp:175
nr_complex_t cosh(const nr_complex_t z)
Compute complex hyperbolic cosine.
Definition: complex.cpp:135
char * getOrigin(void)
Definition: vector.cpp:919
vector operator/=(vector)
Definition: vector.cpp:799
void setDependencies(strlist *)
Definition: vector.cpp:143
i
Definition: parse_mdl.y:516
vector cumprod(vector)
Definition: vector.cpp:1012
friend nr_complex_t avg(vector)
nr_complex_t sqr(const nr_complex_t z)
Square of complex number.
Definition: complex.cpp:673
friend vector real(vector)
#define M_PI_2
Half of Archimedes' constant ( )
Definition: consts.h:51
matrix imag(matrix a)
Imaginary part matrix.
Definition: matrix.cpp:581
vector operator*=(vector)
Definition: vector.cpp:749
matrix operator-(matrix a, matrix b)
Matrix subtraction.
Definition: matrix.cpp:259
nr_complex_t fix(const nr_complex_t z)
Complex fix.
Definition: complex.cpp:645
nr_complex_t sqrt(const nr_complex_t z)
Compute principal value of square root.
Definition: complex.cpp:271
nr_double_t xhypot(const nr_complex_t a, const nr_complex_t b)
Euclidean distance function for complex argument.
Definition: complex.cpp:465
nr_double_t variance(void)
Definition: vector.cpp:1071
nr_complex_t acos(const nr_complex_t z)
Compute complex arc cosine.
Definition: complex.cpp:84
stop
Definition: parse_zvr.y:127
nr_complex_t log2(const nr_complex_t z)
Compute principal value of binary logarithm of z.
Definition: complex.cpp:393
points
Definition: parse_zvr.y:129
double tol
nr_complex_t cosech(const nr_complex_t z)
Compute complex argument hyperbolic cosec.
Definition: complex.cpp:364
nr_complex_t yn(const int n, const nr_complex_t z)
Bessel function of second kind.
Definition: complex.cpp:742
nr_complex_t tanh(const nr_complex_t z)
Compute complex hyperbolic tangent.
Definition: complex.cpp:153
nr_complex_t sin(const nr_complex_t z)
Compute complex sine.
Definition: complex.cpp:66
const vector & operator=(const vector &)
Definition: vector.cpp:117
nr_complex_t ztor(const nr_complex_t z, nr_complex_t zref)
Converts impedance to reflexion coefficient.
Definition: complex.cpp:581
nr_double_t dB(const nr_complex_t z)
Magnitude in dB Compute .
Definition: complex.cpp:528
free($1)
nr_complex_t asin(const nr_complex_t z)
Compute complex arc sine.
Definition: complex.cpp:102
friend vector imag(vector)
void add(nr_complex_t)
Definition: vector.cpp:151
nr_double_t maximum(void)
Definition: vector.cpp:208
add($1)
nr_complex_t * data
Definition: parse_citi.y:226
nr_complex_t acoth(const nr_complex_t z)
Compute complex argument hyperbolic cotangent.
Definition: complex.cpp:332
matrix operator/(matrix a, nr_complex_t z)
Matrix scaling division by complex version.
Definition: matrix.cpp:348
qucs::vector linspace(nr_double_t, nr_double_t, int)
Definition: vector.cpp:950
Global math constants header file.
vector operator+=(vector)
Definition: vector.cpp:639
void set(nr_double_t, int)
Definition: vector.cpp:183
x
Definition: parse_mdl.y:498
nr_complex_t log10(const nr_complex_t z)
Compute principal value of decimal logarithm of z.
Definition: complex.cpp:225
nr_complex_t floor(const nr_complex_t z)
Complex floor.
Definition: complex.cpp:623
nr_complex_t sech(const nr_complex_t z)
Compute complex hyperbolic secant.
Definition: complex.cpp:343
friend vector abs(vector)
Declaration sizeof(struct vcd_scope))
nr_complex_t integrate(vector v, const nr_complex_t)
Definition: vector.cpp:1207
nr_complex_t erfc(const nr_complex_t z)
Complementart error function.
Definition: complex.cpp:784
vector operator-=(vector)
Definition: vector.cpp:695
matrix operator+(matrix a, matrix b)
Matrix addition.
Definition: matrix.cpp:228
nr_complex_t ytor(const nr_complex_t y, nr_complex_t zref)
Converts admittance to reflexion coefficient.
Definition: complex.cpp:599
generic object class.
Definition: object.h:52
nr_complex_t erfinv(const nr_complex_t z)
Inverse of error function.
Definition: complex.cpp:802
vector diff(vector, vector, int n=1)
Definition: vector.cpp:591
nr_complex_t rtoy(const nr_complex_t r, nr_complex_t zref)
Converts reflexion coefficient to admittance.
Definition: complex.cpp:608
int contains(nr_complex_t, nr_double_t eps=NR_EPSI)
Definition: vector.cpp:925
nr_complex_t i0(const nr_complex_t z)
Modified Bessel function of first kind.
Definition: complex.cpp:754
nr_double_t rms(void)
Definition: vector.cpp:1066
nr_complex_t atan2(const nr_complex_t y, const nr_complex_t x)
Compute complex arc tangent fortran like function.
Definition: complex.cpp:377
nr_complex_t sinc(const nr_complex_t z)
Cardinal sine.
Definition: complex.cpp:448
v
Definition: parse_zvr.y:141
nr_complex_t erfcinv(const nr_complex_t z)
Inverse of complementart error function.
Definition: complex.cpp:813
nr_complex_t limexp(const nr_complex_t z)
Compute limited complex exponential.
Definition: complex.cpp:539
nr_double_t norm(const nr_complex_t z)
Compute euclidian norm of complex number.
Definition: complex.cpp:283
nr_double_t stddev(void)
Definition: vector.cpp:1080
nr_complex_t sinh(const nr_complex_t z)
Compute complex hyperbolic sine.
Definition: complex.cpp:144
y
Definition: parse_mdl.y:499
nr_complex_t jn(const int n, const nr_complex_t z)
Bessel function of first kind.
Definition: complex.cpp:729
result
var
Definition: parse_citi.y:145
vector dbm2w(vector)
Definition: vector.cpp:1193
nr_complex_t tan(const nr_complex_t z)
Compute complex tangent.
Definition: complex.cpp:75
nr_complex_t exp(const nr_complex_t z)
Compute complex exponential.
Definition: complex.cpp:205
#define LOG_ERROR
Definition: logging.h:28
char * getName(void)
Definition: object.cpp:84
nr_complex_t operator%(const nr_complex_t z1, const nr_complex_t z2)
Modulo.
Definition: complex.cpp:826
nr_complex_t polar(const nr_double_t mag, const nr_double_t ang)
Construct a complex number using polar notation.
Definition: complex.cpp:551
matrix conj(matrix a)
Conjugate complex matrix.
Definition: matrix.cpp:505
nr_complex_t prod(vector)
Definition: vector.cpp:257
nr_double_t minimum(void)
Definition: vector.cpp:222
static nr_double_t integrate_n(vector v)
Definition: vector.cpp:1058
zref
Definition: parse_zvr.y:130
vector dbm(vector, const nr_complex_t z=50.0)
Definition: vector.cpp:1215
void logprint(int level, const char *format,...)
Definition: logging.c:37
nr_complex_t log(const nr_complex_t z)
Compute principal value of natural logarithm of z.
Definition: complex.cpp:215
strlist * getDependencies(void)
Definition: vector.cpp:138
nr_complex_t round(const nr_complex_t z)
Complex round Round is the nearest integral value Apply round to real and imaginary part...
Definition: complex.cpp:496
nr_complex_t get(int)
Definition: vector.cpp:179
char * origin
Definition: parse_citi.y:227
matrix arg(matrix a)
Computes the argument of each matrix element.
Definition: matrix.cpp:555
nr_complex_t atanh(const nr_complex_t z)
Compute complex arc hyperbolic tangent.
Definition: complex.cpp:188
vector unwrap(vector, nr_double_t tol=M_PI, nr_double_t step=2 *M_PI)
Definition: vector.cpp:235
void print(void)