72 for (
int i = 0;
i <
s;
i++) data[
i] = val;
103 capacity = v.capacity;
106 dependencies = v.dependencies ?
new strlist (*v.dependencies) : NULL;
107 origin = v.origin ? strdup (v.origin) : NULL;
108 requested = v.requested;
117 capacity = v.capacity;
118 if (data) { free (data); data = NULL; }
121 if (size > 0) memcpy (data, v.data, sizeof (
nr_complex_t) * size);
129 if (data) free (data);
130 if (dependencies)
delete dependencies;
131 if (origin) free (origin);
141 if (dependencies)
delete dependencies;
150 size = 0; capacity = 64;
153 else if (size >= capacity) {
164 size = 0; capacity = v->
getSize ();
167 else if (size + v->
getSize () > capacity) {
171 for (
int i = 0;
i < v->
getSize ();
i++) data[size++] = v->
get (
i);
207 nr_double_t d, max_D = -NR_MAX;
211 if (d > max_D) max_D = d;
221 nr_double_t d, min_D = +NR_MAX;
225 if (d < min_D) min_D = d;
240 }
else if (diff < -tol) {
243 result (
i) = v (
i) + add;
263 return result / (nr_double_t) v.
getSize ();
305 assert (len1 % len2 == 0);
308 assert (len2 % len1 == 0);
312 for (j = i = n = 0; n < len; n++) {
313 res (n) =
xhypot (v1 (i), v2 (j));
314 if (++i >= len1) i = 0;
if (++j >= len2) j = 0;
431 assert (len1 % len2 == 0);
434 assert (len2 % len1 == 0);
438 for (j = i = n = 0; n < len; n++) {
439 res (n) =
pow (v1 (i), v2 (j));
440 if (++i >= len1) i = 0;
if (++j >= len2) j = 0;
577 int k, xi, yi, exchange = 0;
593 for (k = 0; k <
n; k++) {
594 for (yi = xi = 0; yi < y.
getSize (); yi++, xi++) {
595 if (xi == x.
getSize ()) xi = 0;
597 c = (y.
get (yi + 1) - y.
get (yi)) / (x.
get (xi + 1) - x.
get (xi));
598 }
else if (xi == x.
getSize () - 1) {
599 c = (y.
get (yi) - y.
get (yi - 1)) / (x.
get (xi) - x.
get (xi - 1));
603 ((y.
get (yi) - y.
get (yi - 1)) / (x.
get (xi) - x.
get (xi - 1)) +
604 (y.
get (yi + 1) - y.
get (yi)) / (x.
get (xi + 1) - x.
get (xi))) /
607 result.set (exchange ? 1.0 / c : c, yi);
615 for (
int i = 0;
i < size;
i++) data[
i] = c;
620 for (
int i = 0;
i < size;
i++) data[
i] = d;
626 assert (size % len == 0);
627 for (i = n = 0; i < size; i++) { data[
i] += v (n);
if (++n >= len) n = 0; }
632 for (
int i = 0;
i < size;
i++) data[
i] += c;
637 for (
int i = 0;
i < size;
i++) data[
i] += d;
676 for (
int i = 0;
i < size;
i++) result (
i) = -data[
i];
682 assert (size % len == 0);
683 for (i = n = 0; i < size; i++) { data[
i] -= v (n);
if (++n >= len) n = 0; }
688 for (
int i = 0;
i < size;
i++) data[
i] -= c;
693 for (
int i = 0;
i < size;
i++) data[
i] -= d;
736 assert (size % len == 0);
737 for (i = n = 0; i < size; i++) { data[
i] *= v (n);
if (++n >= len) n = 0; }
742 for (
int i = 0;
i < size;
i++) data[
i] *= c;
747 for (
int i = 0;
i < size;
i++) data[
i] *= d;
786 assert (size % len == 0);
787 for (i = n = 0; i < size; i++) { data[
i] /= v (n);
if (++n >= len) n = 0; }
792 for (
int i = 0;
i < size;
i++) data[
i] /= c;
797 for (
int i = 0;
i < size;
i++) data[
i] /= d;
805 assert (len1 % len2 == 0);
809 assert (len2 % len1 == 0);
845 for (
int i = 0;
i < len;
i++) result (
i) = v (
i) % z;
852 for (
int i = 0;
i < len;
i++) result (
i) = v (
i) % d;
859 for (
int i = 0;
i < len;
i++) result (
i) = z % v (
i);
866 for (
int i = 0;
i < len;
i++) result (
i) = d % v (
i);
873 assert (len1 % len2 == 0);
876 assert (len2 % len1 == 0);
880 for (j = i = n = 0; n < len; n++) {
881 res (n) = v1 (i) % v2 (j);
882 if (++i >= len1) i = 0;
if (++j >= len2) j = 0;
891 for (
int i = 0;
i < size;
i++) buffer[
i] = data[size - 1 -
i];
899 if (origin) free (origin);
900 origin = n ? strdup (n) : NULL;
912 for (
int i = 0;
i < size;
i++) {
913 if (
abs (data[
i] - val) <= eps) count++;
921 for (
int i = 0;
i < size;
i++) {
922 for (
int n = 0;
n < size - 1;
n++) {
923 if (ascending ? data[
n] > data[
n+1] : data[
n] < data[
n+1]) {
937 nr_double_t val,
step = (stop - start) / (points - 1);
938 for (
int i = 0;
i < points;
i++) {
939 val = start + (
i *
step);
940 if (
i != 0 && fabs (val) < fabs (step) / 4 && fabs (val) <
NR_EPSI)
951 assert (start * stop > 0);
953 nr_double_t
step, first, last, d;
956 if (fabs (start) > fabs (stop)) {
961 first = fabs (start);
965 d = fabs (start) > fabs (stop) ? -1 : 1;
967 step = (
log (last) -
log (first)) / (points - 1);
968 for (
int i = 0, j = points - 1;
i < points;
i++, j--) {
970 result.
set (start *
exp (step *
i), i);
972 result.
set (stop *
exp (step * i), j);
991 val = (val * (nr_double_t)
i + v.
get (
i)) / (
i + 1.0);
1002 result.
set (val,
i);
1043 static nr_double_t integrate_n (
vector v) {
1044 nr_double_t result = 0.0;
1046 result += 0.5 *
norm (v.
get (0));
1052 nr_double_t result =
sqrt (integrate_n (*
this) /
getSize ());
1057 nr_double_t result = 0.0;
1059 for (
int i = 0;
i <
getSize ();
i++) result +=
norm (
get (
i) - average);
1061 return result / (getSize () - 1);
1126 assert (len1 % len2 == 0);
1129 assert (len2 % len1 == 0);
1133 for (j = i = n = 0; n < len; n++) {
1134 res (n) =
polar (a (i), p (j));
1135 if (++i >= len1) i = 0;
if (++j >= len2) j = 0;
1157 assert (len1 % len2 == 0);
1160 assert (len2 % len1 == 0);
1164 for (j = i = n = 0; n < len; n++) {
1165 res (n) =
atan2 (y (i), x (j));
1166 if (++i >= len1) i = 0;
if (++j >= len2) j = 0;
1181 result.
set (0.001 *
pow (10.0 , v.
get (
i) / 10.0),
i);
1186 nr_double_t
s =
real (v.
get (0) ) / 2;
1194 s = v.
get (0) / 2.0;
1197 return (s + v.
get (v.
getSize () - 1) / 2.0) * h;
1209 for (
int i = 0;
i <
n;
i++) result.
set (x,
i);
1217 for (i = 0; i <
n; i++)
s += v.
get (i);
1218 y =
s / (nr_double_t) n;
1220 for (i = 0; i < len - 1; i++) {
1221 y += (v.
get (i + n) - v.
get (i)) / (nr_double_t)
n;
1222 result.
set (y, i + 1);
1230 for (
int r = 0; r < size; r++) {
1231 fprintf (stderr,
"%+.2e%+.2ei\n", (
double)
real (
get (r)),
1232 (
double)
imag (
get (r)));