40 template <
class nr_type_t>
49 template <
class nr_type_t>
54 data =
new nr_type_t[
s];
55 memset (
data, 0,
sizeof (nr_type_t) * s);
62 template <
class nr_type_t>
66 capacity = v.capacity;
71 data =
new nr_type_t[size];
72 memcpy (
data, v.data, sizeof (nr_type_t) * size);
78 template <
class nr_type_t>
83 capacity = v.capacity;
87 data =
new nr_type_t[size];
88 memcpy (
data, v.data, sizeof (nr_type_t) * size);
95 template <
class nr_type_t>
97 if (
data && !external)
delete[]
data;
101 template <
class nr_type_t>
103 assert (i >= 0 && i < size);
108 template <
class nr_type_t>
110 assert (i >= 0 && i < size);
115 template <
class nr_type_t>
117 for (
int i = 0;
i < size;
i++)
data[
i] = z;
121 template <
class nr_type_t>
123 for (
int i = start;
i < stop;
i++)
data[
i] = z;
127 template <
class nr_type_t>
129 if (size >= capacity) {
133 data = (nr_type_t *) realloc (
data, capacity *
sizeof (nr_type_t));
138 data = (nr_type_t *) malloc (capacity *
sizeof (nr_type_t));
145 template <
class nr_type_t>
155 template <
class nr_type_t>
162 template <
class nr_type_t>
165 for (
int i = 0;
i < size;
i++)
if (
abs (
data[
i] - val) <= eps) count++;
170 template <
class nr_type_t>
176 template <
class nr_type_t>
178 if (
data && !external)
delete[]
data;
181 capacity = size = len;
185 template <
class nr_type_t>
187 assert (r1 >= 0 && r2 >= 0 && r1 < size && r2 < size);
188 nr_type_t
s =
data[r1];
194 template <
class nr_type_t>
204 template <
class nr_type_t>
207 nr_type_t * src = a.
getData ();
208 nr_type_t * dst =
data;
209 for (
int i = 0;
i < size;
i++) *dst++ += *src++;
214 template <
class nr_type_t>
224 template <
class nr_type_t>
227 nr_type_t * src = a.
getData ();
228 nr_type_t * dst =
data;
229 for (
int i = 0;
i < size;
i++) *dst++ -= *src++;
234 template <
class nr_type_t>
236 nr_type_t * dst =
data;
237 for (
int i = 0;
i < size;
i++) *dst++ *= s;
242 template <
class nr_type_t>
244 nr_type_t * dst =
data;
245 for (
int i = 0;
i < size;
i++) *dst++ /= s;
250 template <
class nr_type_t>
258 template <
class nr_type_t>
264 template <
class nr_type_t>
274 template <
class nr_type_t>
283 template <
class nr_type_t>
285 for (
int i = 0;
i < size;
i++)
data[
i] = val;
290 template <
class nr_type_t>
298 template <
class nr_type_t>
307 template <
class nr_type_t>
309 assert (a.getSize () ==
b.getSize ());
310 int n = a.getSize ();
311 for (
int i = 0;
i <
n;
i++)
if (a.get (
i) >=
b.get (
i))
return false;
316 template <
class nr_type_t>
320 for (
int i = 0;
i <
n;
i++)
if (a.
get (
i) <= b.
get (
i))
return false;
325 template <
class nr_type_t>
333 template <
class nr_type_t>
339 template <
class nr_type_t>
346 nr_double_t scale = 0,
n = 1,
x, ax;
348 if ((
x =
real (a (
i))) != 0) {
360 if ((
x =
imag (a (
i))) != 0) {
373 return scale * scale *
n;
378 template <
class nr_type_t>
380 nr_double_t nMax = 0,
n;
383 if (
n > nMax) nMax =
n;
389 template <
class nr_type_t>
398 template <
class nr_type_t>
400 for (
int i = 0;
i < size;
i++)
406 template <
class nr_type_t>
409 for (
int i = 0;
i < size;
i++)
data[
i] = old.
get (idx[
i]);
414 template <
class nr_type_t>
416 for (
int r = 0; r < size; r++) {
417 fprintf (stderr,
"%+.2e%+.2ei\n", (
double)
real (
get (r)),
418 (
double)
imag (
get (r)));