75 for (
int i = 0;
i <
s;
i++)
data[
i] = val;
210 nr_double_t
d, max_D = -NR_MAX;
214 if (d > max_D) max_D =
d;
224 nr_double_t
d, min_D = +NR_MAX;
228 if (d < min_D) min_D =
d;
236 vector
result (v.getSize ());
239 for (
int i = 1;
i < v.getSize ();
i++) {
243 }
else if (diff < -tol) {
253 for (
int i = 0;
i < v.getSize ();
i++) result += v.get (
i);
259 for (
int i = 0;
i < v.getSize ();
i++) result *= v.get (
i);
265 for (
int i = 0;
i < v.getSize ();
i++) result += v.get (
i);
266 return result / (nr_double_t) v.getSize ();
271 for (
int i = 0;
i < v.getSize ();
i++) result.set (
signum (v.get (
i)),
i);
277 for (
int i = 0;
i < v.getSize ();
i++) result.set (
sign (v.get (
i)),
i);
283 for (
int i = 0;
i < v.getSize ();
i++) result.set (
xhypot (v.get(
i), z),
i);
289 for (
int i = 0;
i < v.getSize ();
i++) result.set (
xhypot (v.get(
i),
d),
i);
295 for (
int i = 0;
i < v.getSize ();
i++) result.set (
xhypot (z, v.get (
i)),
i);
301 for (
int i = 0;
i < v.getSize ();
i++) result.set (
xhypot (d, v.get (
i)),
i);
306 int j,
i,
n, len, len1 = v1.getSize (), len2 = v2.getSize ();
308 assert (len1 % len2 == 0);
311 assert (len2 % len1 == 0);
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;
324 for (
int i = 0;
i < v.getSize ();
i++) result.set (
sinc (v.get (
i)),
i);
330 for (
int i = 0;
i < v.getSize ();
i++) result.set (
abs (v.get (
i)),
i);
336 for (
int i = 0;
i < v.getSize ();
i++) result.set (
norm (v.get (
i)),
i);
342 for (
int i = 0;
i < v.getSize ();
i++) result.set (
arg (v.get (
i)),
i);
348 for (
int i = 0;
i < v.getSize ();
i++) result.set (
real (v.get (
i)),
i);
354 for (
int i = 0;
i < v.getSize ();
i++) result.set (
imag (v.get (
i)),
i);
360 for (
int i = 0;
i < v.getSize ();
i++) result.set (
conj (v.get (
i)),
i);
366 for (
int i = 0;
i < v.getSize ();
i++)
373 for (
int i = 0;
i < v.getSize ();
i++) result.set (
sqrt (v.get (
i)),
i);
379 for (
int i = 0;
i < v.getSize ();
i++) result.set (
exp (v.get (
i)),
i);
385 for (
int i = 0;
i < v.getSize ();
i++) result.set (
limexp (v.get (
i)),
i);
391 for (
int i = 0;
i < v.getSize ();
i++) result.set (
log (v.get (
i)),
i);
397 for (
int i = 0;
i < v.getSize ();
i++) result.set (
log10 (v.get (
i)),
i);
403 for (
int i = 0;
i < v.getSize ();
i++) result.set (
log2 (v.get (
i)),
i);
409 for (
int i = 0;
i < v.getSize ();
i++) result.set (
pow (v.get(
i), z),
i);
413 vector
pow (vector
v,
const nr_double_t
d) {
415 for (
int i = 0;
i < v.getSize ();
i++) result.set (
pow (v.get(
i),
d),
i);
421 for (
int i = 0;
i < v.getSize ();
i++) result.set (
pow (z, v.get (
i)),
i);
425 vector
pow (
const nr_double_t
d, vector
v) {
427 for (
int i = 0;
i < v.getSize ();
i++) result.set (
pow (d, v.get (
i)),
i);
431 vector
pow (vector v1, vector v2) {
432 int j,
i,
n, len, len1 = v1.getSize (), len2 = v2.getSize ();
434 assert (len1 % len2 == 0);
437 assert (len2 % len1 == 0);
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;
450 for (
int i = 0;
i < v.getSize ();
i++) result.set (
sin (v.get (
i)),
i);
456 for (
int i = 0;
i < v.getSize ();
i++) result.set (
asin (v.get (
i)),
i);
462 for (
int i = 0;
i < v.getSize ();
i++) result.set (
acos (v.get (
i)),
i);
468 for (
int i = 0;
i < v.getSize ();
i++) result.set (
cos (v.get (
i)),
i);
474 for (
int i = 0;
i < v.getSize ();
i++) result.set (
tan (v.get (
i)),
i);
480 for (
int i = 0;
i < v.getSize ();
i++) result.set (
atan (v.get (
i)),
i);
486 for (
int i = 0;
i < v.getSize ();
i++) result.set (
cot (v.get (
i)),
i);
492 for (
int i = 0;
i < v.getSize ();
i++) result.set (
acot (v.get (
i)),
i);
498 for (
int i = 0;
i < v.getSize ();
i++) result.set (
sinh (v.get (
i)),
i);
504 for (
int i = 0;
i < v.getSize ();
i++) result.set (
asinh (v.get (
i)),
i);
510 for (
int i = 0;
i < v.getSize ();
i++) result.set (
cosh (v.get (
i)),
i);
516 for (
int i = 0;
i < v.getSize ();
i++) result.set (
sech (v.get (
i)),
i);
522 for (
int i = 0;
i < v.getSize ();
i++) result.set (
cosech (v.get (
i)),
i);
528 for (
int i = 0;
i < v.getSize ();
i++) result.set (
acosh (v.get (
i)),
i);
534 for (
int i = 0;
i < v.getSize ();
i++) result.set (
asech (v.get (
i)),
i);
540 for (
int i = 0;
i < v.getSize ();
i++) result.set (
tanh (v.get (
i)),
i);
546 for (
int i = 0;
i < v.getSize ();
i++) result.set (
atanh (v.get (
i)),
i);
552 for (
int i = 0;
i < v.getSize ();
i++) result.set (
coth (v.get (
i)),
i);
558 for (
int i = 0;
i < v.getSize ();
i++) result.set (
acoth (v.get (
i)),
i);
565 for (
int i = 0;
i < v.getSize ();
i++) result (
i) =
ztor (v (
i), zref);
572 for (
int i = 0;
i < v.getSize ();
i++) result (
i) =
ytor (v (
i), zref);
579 for (
int i = 0;
i < v.getSize ();
i++) result (
i) =
rtoz (v (
i), zref);
586 for (
int i = 0;
i < v.getSize ();
i++) result (
i) =
rtoy (v (
i), zref);
592 int k, xi, yi, exchange = 0;
595 if (var.getSize () < dep.getSize ()) {
604 assert (y.getSize () % x.getSize () == 0 && x.getSize () >= 2);
608 for (k = 0; k <
n; k++) {
609 for (yi = xi = 0; yi < y.getSize (); yi++, xi++) {
610 if (xi == x.getSize ()) 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));
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))) /
622 result.set (exchange ? 1.0 / c : c, yi);
641 assert (
size % len == 0);
642 for (i = n = 0; i <
size; i++) {
data[
i] +=
v (n);
if (++n >= len) n = 0; }
657 int len1 = v1.getSize (), len2 = v2.getSize ();
697 assert (
size % len == 0);
698 for (i = n = 0; i <
size; i++) {
data[
i] -=
v (n);
if (++n >= len) n = 0; }
713 int len1 = v1.getSize (), len2 = v2.getSize ();
751 assert (
size % len == 0);
752 for (i = n = 0; i <
size; i++) {
data[
i] *=
v (n);
if (++n >= len) n = 0; }
767 int len1 = v1.getSize (), len2 = v2.getSize ();
801 assert (
size % len == 0);
802 for (i = n = 0; i <
size; i++) {
data[
i] /=
v (n);
if (++n >= len) n = 0; }
817 int len1 = v1.getSize (), len2 = v2.getSize ();
820 assert (len1 % len2 == 0);
824 assert (len2 % len1 == 0);
858 int len = v.getSize ();
860 for (
int i = 0;
i < len;
i++) result (
i) =
v (
i) % z;
865 int len = v.getSize ();
867 for (
int i = 0;
i < len;
i++) result (
i) =
v (
i) %
d;
872 int len = v.getSize ();
874 for (
int i = 0;
i < len;
i++) result (
i) = z %
v (
i);
879 int len = v.getSize ();
881 for (
int i = 0;
i < len;
i++) result (
i) = d %
v (
i);
886 int j,
i,
n, len, len1 = v1.getSize (), len2 = v2.getSize ();
888 assert (len1 % len2 == 0);
891 assert (len2 % len1 == 0);
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;
906 for (
int i = 0;
i <
size;
i++) buffer[
i] =
data[size - 1 -
i];
915 origin = n ? strdup (n) : NULL;
927 for (
int i = 0;
i <
size;
i++) {
928 if (
abs (
data[
i] - val) <= eps) count++;
936 for (
int i = 0;
i <
size;
i++) {
937 for (
int n = 0;
n < size - 1;
n++) {
952 nr_double_t val,
step = (stop -
start) / (points - 1);
954 val = start + (
i *
step);
955 if (
i != 0 && fabs (val) < fabs (step) / 4 && fabs (val) < NR_EPSI)
966 assert (start * stop > 0);
968 nr_double_t
step, first, last,
d;
971 if (fabs (start) > fabs (stop)) {
976 first = fabs (start);
980 d = fabs (start) > fabs (stop) ? -1 : 1;
982 step = (
::log (last) -
::log (first)) / (points - 1);
983 for (
int i = 0, j = points - 1;
i <
points;
i++, j--) {
985 result.set (start * ::
exp (step *
i), i);
987 result.set (stop * ::
exp (step * i), j);
995 for (
int i = 0;
i < v.getSize ();
i++) {
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);
1015 for (
int i = 0;
i < v.getSize ();
i++) {
1017 result.set (val,
i);
1024 for (
int i = 0;
i < v.getSize ();
i++) result.set (
ceil (v.get (
i)),
i);
1030 for (
int i = 0;
i < v.getSize ();
i++) result.set (
fix (v.get (
i)),
i);
1036 for (
int i = 0;
i < v.getSize ();
i++) result.set (
floor (v.get (
i)),
i);
1042 for (
int i = 0;
i < v.getSize ();
i++) result.set (
round (v.get (
i)),
i);
1048 for (
int i = 0;
i < v.getSize ();
i++) result.set (
sqr (v.get (
i)),
i);
1054 for (
int i = 0;
i < v.getSize ();
i++) result.set (
step (v.get (
i)),
i);
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));
1072 nr_double_t
result = 0.0;
1074 for (
int i = 0;
i <
getSize ();
i++) result +=
norm (
get (
i) - average);
1076 return result / (getSize () - 1);
1086 for (
int i = 0;
i < v.getSize ();
i++) result.set (
erf (v.get (
i)),
i);
1092 for (
int i = 0;
i < v.getSize ();
i++) result.set (
erfc (v.get (
i)),
i);
1098 for (
int i = 0;
i < v.getSize ();
i++) result.set (
erfinv (v.get (
i)),
i);
1104 for (
int i = 0;
i < v.getSize ();
i++) result.set (
erfcinv (v.get (
i)),
i);
1110 for (
int i = 0;
i < v.getSize ();
i++) result.set (
i0 (v.get (
i)),
i);
1114 vector
jn (
const int n, vector
v) {
1116 for (
int i = 0;
i < v.getSize ();
i++) result.set (
jn (n, v.get (
i)),
i);
1120 vector
yn (
const int n, vector
v) {
1122 for (
int i = 0;
i < v.getSize ();
i++) result.set (
yn (n, v.get (
i)),
i);
1128 for (
int i = 0;
i < v.getSize ();
i++) result.set (
qucs::polar (a, v.get (
i)),
i);
1134 for (
int i = 0;
i < v.getSize ();
i++) result.set (
qucs::polar (v.get (
i), p),
i);
1139 int j,
i,
n, len, len1 = a.getSize (), len2 = p.getSize ();
1141 assert (len1 % len2 == 0);
1144 assert (len2 % len1 == 0);
1148 for (j = i = n = 0; n < len; n++) {
1150 if (++i >= len1) i = 0;
if (++j >= len2) j = 0;
1157 for (
int i = 0;
i < v.getSize ();
i++)
1158 result.set (
atan2 (y, v.get (
i)),
i);
1164 for (
int i = 0;
i < v.getSize ();
i++)
1165 result.set (
atan2 (v.get (
i),
x) ,
i);
1170 int j,
i,
n, len, len1 = y.getSize (), len2 = x.getSize ();
1172 assert (len1 % len2 == 0);
1175 assert (len2 % len1 == 0);
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;
1188 for (
int i = 0;
i < v.getSize ();
i++)
1189 result.set (10.0 *
log10 (v.get (
i) / 0.001),
i);
1195 for (
int i = 0;
i < v.getSize ();
i++)
1196 result.set (0.001 *
pow (10.0 , v.get (
i) / 10.0),
i);
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;
1209 s = v.get (0) / 2.0;
1210 for (
int i = 1;
i < v.getSize () - 1;
i++)
1212 return (s + v.get (v.getSize () - 1) / 2.0) *
h;
1217 for (
int i = 0;
i < v.getSize ();
i++)
1224 for (
int i = 0;
i <
n;
i++) result.set (x,
i);
1230 int len = v.getSize () - n + 1,
i;
1232 for (i = 0; i <
n; i++)
s += v.get (i);
1233 y =
s / (nr_double_t) n;
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);
1245 for (
int r = 0;
r <
size;
r++) {
1246 fprintf (stderr,
"%+.2e%+.2ei\n", (
double)
real (
get (
r)),
1247 (
double)
imag (
get (
r)));
std::complex< nr_double_t > nr_complex_t
matrix real(matrix a)
Real part matrix.
matrix abs(matrix a)
Computes magnitude of each matrix element.
nr_complex_t erf(const nr_complex_t z)
Error function.
friend vector norm(vector)
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...
matrix operator*(matrix a, nr_complex_t z)
Matrix scaling complex version.
nr_complex_t coth(const nr_complex_t z)
Compute complex hyperbolic cotangent.
qucs::vector runavg(qucs::vector, const int)
nr_complex_t pow(const nr_complex_t z, const nr_double_t d)
Compute power function with real exponent.
nr_complex_t cos(const nr_complex_t z)
Compute complex cosine.
void sort(bool ascending=true)
nr_complex_t step(const nr_complex_t z)
Heaviside step function for complex number.
friend vector arg(vector)
nr_complex_t signum(const nr_complex_t z)
complex signum function
qucs::vector logspace(nr_double_t, nr_double_t, int)
nr_complex_t atan(const nr_complex_t z)
Compute complex arc tangent.
nr_complex_t cot(const nr_complex_t z)
Compute complex cotangent.
nr_complex_t asech(const nr_complex_t z)
Compute complex argument hyperbolic secant.
nr_complex_t acot(const nr_complex_t z)
Compute complex arc cotangent.
nr_complex_t acosh(const nr_complex_t z)
Compute complex arc hyperbolic cosine.
nr_complex_t rtoz(const nr_complex_t r, nr_complex_t zref)
Converts reflexion coefficient to impedance.
nr_complex_t sign(const nr_complex_t z)
complex sign function
int checkSizes(vector, vector)
nr_complex_t asinh(const nr_complex_t z)
Compute complex arc hyperbolic sine.
nr_complex_t cosh(const nr_complex_t z)
Compute complex hyperbolic cosine.
vector operator/=(vector)
void setDependencies(strlist *)
friend nr_complex_t avg(vector)
nr_complex_t sqr(const nr_complex_t z)
Square of complex number.
friend vector real(vector)
#define M_PI_2
Half of Archimedes' constant ( )
matrix imag(matrix a)
Imaginary part matrix.
vector operator*=(vector)
matrix operator-(matrix a, matrix b)
Matrix subtraction.
nr_complex_t fix(const nr_complex_t z)
Complex fix.
nr_complex_t sqrt(const nr_complex_t z)
Compute principal value of square root.
nr_double_t xhypot(const nr_complex_t a, const nr_complex_t b)
Euclidean distance function for complex argument.
nr_double_t variance(void)
nr_complex_t acos(const nr_complex_t z)
Compute complex arc cosine.
nr_complex_t log2(const nr_complex_t z)
Compute principal value of binary logarithm of z.
nr_complex_t cosech(const nr_complex_t z)
Compute complex argument hyperbolic cosec.
nr_complex_t yn(const int n, const nr_complex_t z)
Bessel function of second kind.
nr_complex_t tanh(const nr_complex_t z)
Compute complex hyperbolic tangent.
nr_complex_t sin(const nr_complex_t z)
Compute complex sine.
const vector & operator=(const vector &)
nr_complex_t ztor(const nr_complex_t z, nr_complex_t zref)
Converts impedance to reflexion coefficient.
nr_double_t dB(const nr_complex_t z)
Magnitude in dB Compute .
nr_complex_t asin(const nr_complex_t z)
Compute complex arc sine.
friend vector imag(vector)
nr_double_t maximum(void)
nr_complex_t acoth(const nr_complex_t z)
Compute complex argument hyperbolic cotangent.
matrix operator/(matrix a, nr_complex_t z)
Matrix scaling division by complex version.
qucs::vector linspace(nr_double_t, nr_double_t, int)
Global math constants header file.
vector operator+=(vector)
void set(nr_double_t, int)
nr_complex_t log10(const nr_complex_t z)
Compute principal value of decimal logarithm of z.
nr_complex_t floor(const nr_complex_t z)
Complex floor.
nr_complex_t sech(const nr_complex_t z)
Compute complex hyperbolic secant.
friend vector abs(vector)
Declaration sizeof(struct vcd_scope))
nr_complex_t integrate(vector v, const nr_complex_t)
nr_complex_t erfc(const nr_complex_t z)
Complementart error function.
vector operator-=(vector)
matrix operator+(matrix a, matrix b)
Matrix addition.
nr_complex_t ytor(const nr_complex_t y, nr_complex_t zref)
Converts admittance to reflexion coefficient.
nr_complex_t erfinv(const nr_complex_t z)
Inverse of error function.
vector diff(vector, vector, int n=1)
nr_complex_t rtoy(const nr_complex_t r, nr_complex_t zref)
Converts reflexion coefficient to admittance.
int contains(nr_complex_t, nr_double_t eps=NR_EPSI)
nr_complex_t i0(const nr_complex_t z)
Modified Bessel function of first kind.
nr_complex_t atan2(const nr_complex_t y, const nr_complex_t x)
Compute complex arc tangent fortran like function.
nr_complex_t sinc(const nr_complex_t z)
Cardinal sine.
nr_complex_t erfcinv(const nr_complex_t z)
Inverse of complementart error function.
nr_complex_t limexp(const nr_complex_t z)
Compute limited complex exponential.
nr_double_t norm(const nr_complex_t z)
Compute euclidian norm of complex number.
nr_complex_t sinh(const nr_complex_t z)
Compute complex hyperbolic sine.
nr_complex_t jn(const int n, const nr_complex_t z)
Bessel function of first kind.
nr_complex_t tan(const nr_complex_t z)
Compute complex tangent.
nr_complex_t exp(const nr_complex_t z)
Compute complex exponential.
nr_complex_t operator%(const nr_complex_t z1, const nr_complex_t z2)
Modulo.
nr_complex_t polar(const nr_double_t mag, const nr_double_t ang)
Construct a complex number using polar notation.
matrix conj(matrix a)
Conjugate complex matrix.
nr_complex_t prod(vector)
nr_double_t minimum(void)
static nr_double_t integrate_n(vector v)
vector dbm(vector, const nr_complex_t z=50.0)
void logprint(int level, const char *format,...)
nr_complex_t log(const nr_complex_t z)
Compute principal value of natural logarithm of z.
strlist * getDependencies(void)
nr_complex_t round(const nr_complex_t z)
Complex round Round is the nearest integral value Apply round to real and imaginary part...
matrix arg(matrix a)
Computes the argument of each matrix element.
nr_complex_t atanh(const nr_complex_t z)
Compute complex arc hyperbolic tangent.
vector unwrap(vector, nr_double_t tol=M_PI, nr_double_t step=2 *M_PI)