IT++ Logo
vec.cpp
Go to the documentation of this file.
1 
29 #ifndef _MSC_VER
30 # include <itpp/config.h>
31 #else
32 # include <itpp/config_msvc.h>
33 #endif
34 
35 #if defined (HAVE_BLAS)
36 # include <itpp/base/blas.h>
37 #endif
38 
39 #include <itpp/base/vec.h>
40 #include <itpp/base/converters.h>
41 #include <cstdio>
42 #include <limits>
44 
45 namespace itpp
46 {
47 
48 template<>
49 int Vec<int>::parse_token(const std::string &s) const
50 {
51  int out;
52  std::istringstream buffer(s);
53  if (s.find('x', 1) != std::string::npos) {
54  buffer >> std::hex >> out;
55  }
56  else if (((s[0] == '0')
57  || (((s[0] == '-') || (s[0] == '+')) && (s[1] == '0')))
58  && (s.find('8', 1) == std::string::npos)
59  && (s.find('9', 1) == std::string::npos)) {
60  buffer >> std::oct >> out;
61  }
62  else {
63  buffer >> std::dec >> out;
64  }
65  return out;
66 }
67 
68 template<>
69 double Vec<double>::parse_token(const std::string &s) const
70 {
71  double out;
72  if ((s == "NaN") || (s == "nan") || (s == "NAN")) {
73  if (std::numeric_limits<double>::has_quiet_NaN)
74  out = std::numeric_limits<double>::quiet_NaN();
75  else if (std::numeric_limits<double>::has_signaling_NaN)
76  out = std::numeric_limits<double>::signaling_NaN();
77  else
78  it_error("Vec<double>::set(): NaN not supported");
79  }
80  else if ((s =="-Inf") || (s =="-inf") || (s =="-INF")) {
81  out = -std::numeric_limits<double>::infinity();
82  }
83  else if ((s =="Inf") || (s =="inf") || (s =="INF") ||
84  (s =="+Inf") || (s =="+inf") || (s =="+INF")) {
85  out = std::numeric_limits<double>::infinity();
86  }
87  else {
88  std::istringstream buffer(s);
89  buffer >> out;
90  it_assert(!buffer.fail(), "Vec<double>::set(): Stream operation failed "
91  "(buffer >> out)");
92  }
93  return out;
94 }
95 
96 
97 template<>
98 void Vec<bin>::set(const std::string &str)
99 {
100  bool abc_format;
101  std::vector<std::string> tokens = tokenize(str, abc_format);
102  it_assert(!abc_format, "Vec<bin>::set(): \"a:b:c\" format string not "
103  "supported for binary vectors");
104  set_size(int(tokens.size()));
105  for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) {
106  std::istringstream buffer(tokens[i]);
107  buffer >> data[i];
108  it_assert(!buffer.fail(), "Vec<bin>::set(): Stream operation failed "
109  "(buffer >> data)");
110  }
111 }
112 
113 template<>
114 void Vec<short int>::set(const std::string &str)
115 {
116  // parser for "short int" is the same as for "int", so reuse it here
117  ivec iv(str);
118  this->operator=(to_svec(iv));
119 }
120 
121 template<>
122 void Vec<int>::set(const std::string &str)
123 {
124  bool abc_format;
125  std::vector<std::string> tokens = tokenize(str, abc_format);
126  // no "a:b:c" tokens, so the size of output vector is known
127  if (!abc_format) {
128  set_size(int(tokens.size()));
129  for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i)
130  data[i] = parse_token(tokens[i]);
131  }
132  else {
133  int pos = 0;
134  set_size((tokens.size() > 20) ? int(tokens.size()) : 20);
135  for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) {
136  // check if the current token is in "a:b[:c]" format
137  if (tokens[i].find(':', 1) == std::string::npos) {
138  if (++pos > datasize) {
139  set_size(2 * datasize, true);
140  }
141  data[pos-1] = parse_token(tokens[i]);
142  }
143  else {
144  int a, b, c;
145  parse_abc_token(tokens[i], a, b, c);
146  if (++pos > datasize) {
147  set_size(2 * datasize, true);
148  }
149  data[pos-1] = a;
150 
151  if ((b > 0) && (c >= a)) {
152  while ((data[pos-1] + b) <= c) {
153  if (++pos > datasize) {
154  set_size(2 * datasize, true);
155  }
156  data[pos-1] = data[pos-2] + b;
157  }
158  }
159  else if ((b < 0) && (c <= a)) {
160  while ((data[pos-1] + b) >= c) {
161  if (++pos > datasize) {
162  set_size(2 * datasize, true);
163  }
164  data[pos-1] = data[pos-2] + b;
165  }
166  }
167  else if (b == 0 && c == a) {
168  break;
169  }
170  else {
171  it_error("Vec<int>::set(): Improper data string (a:b:c)");
172  }
173  }
174  }
175  set_size(pos, true);
176  } // if (!abc_format)
177 }
178 
179 
180 template<>
181 void Vec<double>::set(const std::string &str)
182 {
183  bool abc_format;
184  std::vector<std::string> tokens = tokenize(str, abc_format);
185  // no "a:b:c" tokens, so the size of output vector is known
186  if (!abc_format) {
187  set_size(int(tokens.size()));
188  for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i)
189  data[i] = parse_token(tokens[i]);
190  }
191  else {
192  int pos = 0;
193  set_size((tokens.size() > 20) ? int(tokens.size()) : 20);
194  for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) {
195  // check if the current token is in "a:b[:c]" format
196  if (tokens[i].find(':', 1) == std::string::npos) {
197  if (++pos > datasize) {
198  set_size(2 * datasize, true);
199  }
200  data[pos-1] = parse_token(tokens[i]);
201  }
202  else {
203  double a, b, c;
204  parse_abc_token(tokens[i], a, b, c);
205  if (++pos > datasize) {
206  set_size(2 * datasize, true);
207  }
208  data[pos-1] = a;
209  // Adding this margin fixes precision problems in e.g. "0:0.2:3",
210  // where the last value was 2.8 instead of 3.
211  double eps_margin = std::fabs((c - a) / b) * eps;
212  if ((b > 0) && (c >= a)) {
213  while ((data[pos-1] + b) <= (c + eps_margin)) {
214  if (++pos > datasize) {
215  set_size(2 * datasize, true);
216  }
217  data[pos-1] = data[pos-2] + b;
218  }
219  }
220  else if ((b < 0) && (c <= a)) {
221  while ((data[pos-1] + b) >= (c - eps_margin)) {
222  if (++pos > datasize) {
223  set_size(2 * datasize, true);
224  }
225  data[pos-1] = data[pos-2] + b;
226  }
227  }
228  else if (b == 0 && c == a) {
229  break;
230  }
231  else {
232  it_error("Vec<double>::set(): Improper data string (a:b:c)");
233  }
234  }
235  }
236  set_size(pos, true);
237  } // if (!abc_format)
238 }
239 
240 template<>
241 void Vec<std::complex<double> >::set(const std::string &str)
242 {
243  bool abc_format;
244  std::vector<std::string> tokens = tokenize(str, abc_format);
245  it_assert(!abc_format, "Vec<bin>::set(): \"a:b:c\" format string not "
246  "supported for binary vectors");
247  set_size(int(tokens.size()));
248  for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) {
249  std::istringstream buffer(tokens[i]);
250  buffer >> data[i];
251  it_assert(!buffer.fail(), "Vec<complex>::set(): Stream operation failed "
252  "(buffer >> data)");
253  }
254 }
255 
256 #if defined(HAVE_BLAS)
257 template<>
258 double dot(const vec &v1, const vec &v2)
259 {
260  it_assert_debug(v1.length() == v2.length(), "vec::dot(): Wrong sizes");
261  int incr = 1; int v1_l = v1.length();
262  return blas::ddot_(&v1_l, v1._data(), &incr, v2._data(), &incr);
263 }
264 #else
265 template<>
266 double dot(const vec &v1, const vec &v2)
267 {
268  it_assert_debug(v1.length() == v2.length(), "vec::dot(): Wrong sizes");
269  double r = 0.0;
270  for (int i = 0; i < v1.length(); ++i)
271  r += v1._data()[i] * v2._data()[i];
272  return r;
273 }
274 #endif // HAVE_BLAS
275 
276 #if defined(HAVE_BLAS)
277 template<>
278 mat outer_product(const vec &v1, const vec &v2, bool)
279 {
280  it_assert_debug((v1.length() > 0) && (v2.length() > 0),
281  "Vec::outer_product:: Input vector of zero size");
282  int v1_l = v1.length(); int v2_l = v2.length();
283  mat out(v1_l, v2_l);
284  out.zeros();
285  double alpha = 1.0;
286  int incr = 1;
287  blas::dger_(&v1_l, &v2_l, &alpha, v1._data(), &incr,
288  v2._data(), &incr, out._data(), &v1_l);
289  return out;
290 }
291 
292 template<>
293 cmat outer_product(const cvec &v1, const cvec &v2, bool hermitian)
294 {
295  it_assert_debug((v1.length() > 0) && (v2.length() > 0),
296  "Vec::outer_product:: Input vector of zero size");
297  int v1_l = v1.length(); int v2_l = v2.length();
298  cmat out(v1_l, v2_l);
299  out.zeros();
300  std::complex<double> alpha(1.0);
301  int incr = 1;
302  if (hermitian) {
303  blas::zgerc_(&v1_l, &v2_l, &alpha, v1._data(), &incr,
304  v2._data(), &incr, out._data(), &v1_l);
305  }
306  else {
307  blas::zgeru_(&v1_l, &v2_l, &alpha, v1._data(), &incr,
308  v2._data(), &incr, out._data(), &v1_l);
309  }
310  return out;
311 }
312 #else
313 template<>
314 mat outer_product(const vec &v1, const vec &v2, bool)
315 {
316  it_assert_debug((v1.length() > 0) && (v2.length() > 0),
317  "Vec::outer_product:: Input vector of zero size");
318  int v1_l = v1.length(); int v2_l = v2.length();
319  mat out(v1_l, v2_l);
320  for (int i = 0; i < v1_l; ++i) {
321  for (int j = 0; j < v2_l; ++j) {
322  out(i, j) = v1._data()[i] * v2._data()[j];
323  }
324  }
325  return out;
326 }
327 
328 template<>
329 cmat outer_product(const cvec &v1, const cvec &v2, bool hermitian)
330 {
331  it_assert_debug((v1.length() > 0) && (v2.length() > 0),
332  "Vec::outer_product:: Input vector of zero size");
333  int v1_l = v1.length(); int v2_l = v2.length();
334  cmat out(v1_l, v2_l);
335  if (hermitian) {
336  for (int i = 0; i < v1_l; ++i) {
337  for (int j = 0; j < v2_l; ++j) {
338  out(i, j) = v1._data()[i] * conj(v2._data()[j]);
339  }
340  }
341  }
342  else {
343  for (int i = 0; i < v1_l; ++i) {
344  for (int j = 0; j < v2_l; ++j) {
345  out(i, j) = v1._data()[i] * v2._data()[j];
346  }
347  }
348  }
349  return out;
350 }
351 #endif // HAVE_BLAS
352 
353 
354 template<>
355 bvec Vec<std::complex<double> >::operator<=(std::complex<double>) const
356 {
357  it_error("operator<=: not implemented for complex");
358  bvec temp;
359  return temp;
360 }
361 
362 template<>
363 bvec Vec<std::complex<double> >::operator>(std::complex<double>) const
364 {
365  it_error("operator>: not implemented for complex");
366  bvec temp;
367  return temp;
368 }
369 
370 template<>
371 bvec Vec<std::complex<double> >::operator<(std::complex<double>) const
372 {
373  it_error("operator<: not implemented for complex");
374  bvec temp;
375  return temp;
376 }
377 
378 template<>
379 bvec Vec<std::complex<double> >::operator>=(std::complex<double>) const
380 {
381  it_error("operator>=: not implemented for complex");
382  bvec temp;
383  return temp;
384 }
385 
386 template<>
387 Mat<std::complex<double> > Vec<std::complex<double> >::hermitian_transpose() const
388 {
389  Mat<std::complex<double> > temp(1, datasize);
390  for (int i = 0; i < datasize; i++)
391  temp(i) = std::conj(data[i]);
392 
393  return temp;
394 }
395 
396 
397 //---------------------------------------------------------------------
398 // Instantiations
399 //---------------------------------------------------------------------
400 
401 template class ITPP_EXPORT Vec<double>;
402 template class ITPP_EXPORT Vec<int>;
403 template class ITPP_EXPORT Vec<short int>;
404 template class ITPP_EXPORT Vec<std::complex<double> >;
405 template class ITPP_EXPORT Vec<bin>;
406 
407 // addition operator
408 
409 template ITPP_EXPORT vec operator+(const vec &v1, const vec &v2);
410 template ITPP_EXPORT cvec operator+(const cvec &v1, const cvec &v2);
411 template ITPP_EXPORT ivec operator+(const ivec &v1, const ivec &v2);
412 template ITPP_EXPORT svec operator+(const svec &v1, const svec &v2);
413 template ITPP_EXPORT bvec operator+(const bvec &v1, const bvec &v2);
414 
415 template ITPP_EXPORT vec operator+(const vec &v1, double t);
416 template ITPP_EXPORT cvec operator+(const cvec &v1, std::complex<double> t);
417 template ITPP_EXPORT ivec operator+(const ivec &v1, int t);
418 template ITPP_EXPORT svec operator+(const svec &v1, short t);
419 template ITPP_EXPORT bvec operator+(const bvec &v1, bin t);
420 
421 template ITPP_EXPORT vec operator+(double t, const vec &v1);
422 template ITPP_EXPORT cvec operator+(std::complex<double> t, const cvec &v1);
423 template ITPP_EXPORT ivec operator+(int t, const ivec &v1);
424 template ITPP_EXPORT svec operator+(short t, const svec &v1);
425 template ITPP_EXPORT bvec operator+(bin t, const bvec &v1);
426 
427 // subraction operator
428 
429 template ITPP_EXPORT vec operator-(const vec &v1, const vec &v2);
430 template ITPP_EXPORT cvec operator-(const cvec &v1, const cvec &v2);
431 template ITPP_EXPORT ivec operator-(const ivec &v1, const ivec &v2);
432 template ITPP_EXPORT svec operator-(const svec &v1, const svec &v2);
433 template ITPP_EXPORT bvec operator-(const bvec &v1, const bvec &v2);
434 
435 template ITPP_EXPORT vec operator-(const vec &v, double t);
436 template ITPP_EXPORT cvec operator-(const cvec &v, std::complex<double> t);
437 template ITPP_EXPORT ivec operator-(const ivec &v, int t);
438 template ITPP_EXPORT svec operator-(const svec &v, short t);
439 template ITPP_EXPORT bvec operator-(const bvec &v, bin t);
440 
441 template ITPP_EXPORT vec operator-(double t, const vec &v);
442 template ITPP_EXPORT cvec operator-(std::complex<double> t, const cvec &v);
443 template ITPP_EXPORT ivec operator-(int t, const ivec &v);
444 template ITPP_EXPORT svec operator-(short t, const svec &v);
445 template ITPP_EXPORT bvec operator-(bin t, const bvec &v);
446 
447 // unary minus
448 
449 template ITPP_EXPORT vec operator-(const vec &v);
450 template ITPP_EXPORT cvec operator-(const cvec &v);
451 template ITPP_EXPORT ivec operator-(const ivec &v);
452 template ITPP_EXPORT svec operator-(const svec &v);
453 template ITPP_EXPORT bvec operator-(const bvec &v);
454 
455 // multiplication operator
456 template ITPP_EXPORT std::complex<double> dot(const cvec &v1, const cvec &v2);
457 template ITPP_EXPORT int dot(const ivec &v1, const ivec &v2);
458 template ITPP_EXPORT short dot(const svec &v1, const svec &v2);
459 template ITPP_EXPORT bin dot(const bvec &v1, const bvec &v2);
460 
461 template ITPP_EXPORT double operator*(const vec &v1, const vec &v2);
462 template ITPP_EXPORT std::complex<double> operator*(const cvec &v1, const cvec &v2);
463 template ITPP_EXPORT int operator*(const ivec &v1, const ivec &v2);
464 template ITPP_EXPORT short operator*(const svec &v1, const svec &v2);
465 template ITPP_EXPORT bin operator*(const bvec &v1, const bvec &v2);
466 
467 template ITPP_EXPORT imat outer_product(const ivec &v1, const ivec &v2, bool hermitian);
468 template ITPP_EXPORT smat outer_product(const svec &v1, const svec &v2, bool hermitian);
469 template ITPP_EXPORT bmat outer_product(const bvec &v1, const bvec &v2, bool hermitian);
470 
471 template ITPP_EXPORT vec operator*(const vec &v, double t);
472 template ITPP_EXPORT cvec operator*(const cvec &v, std::complex<double> t);
473 template ITPP_EXPORT ivec operator*(const ivec &v, int t);
474 template ITPP_EXPORT svec operator*(const svec &v, short t);
475 template ITPP_EXPORT bvec operator*(const bvec &v, bin t);
476 
477 template ITPP_EXPORT vec operator*(double t, const vec &v);
478 template ITPP_EXPORT cvec operator*(std::complex<double> t, const cvec &v);
479 template ITPP_EXPORT ivec operator*(int t, const ivec &v);
480 template ITPP_EXPORT svec operator*(short t, const svec &v);
481 template ITPP_EXPORT bvec operator*(bin t, const bvec &v);
482 
483 // elementwise multiplication
484 
485 template ITPP_EXPORT vec elem_mult(const vec &a, const vec &b);
486 template ITPP_EXPORT cvec elem_mult(const cvec &a, const cvec &b);
487 template ITPP_EXPORT ivec elem_mult(const ivec &a, const ivec &b);
488 template ITPP_EXPORT svec elem_mult(const svec &a, const svec &b);
489 template ITPP_EXPORT bvec elem_mult(const bvec &a, const bvec &b);
490 
491 template ITPP_EXPORT void elem_mult_out(const vec &a, const vec &b, vec &out);
492 template ITPP_EXPORT void elem_mult_out(const cvec &a, const cvec &b, cvec &out);
493 template ITPP_EXPORT void elem_mult_out(const ivec &a, const ivec &b, ivec &out);
494 template ITPP_EXPORT void elem_mult_out(const svec &a, const svec &b, svec &out);
495 template ITPP_EXPORT void elem_mult_out(const bvec &a, const bvec &b, bvec &out);
496 
497 template ITPP_EXPORT vec elem_mult(const vec &a, const vec &b, const vec &c);
498 template ITPP_EXPORT cvec elem_mult(const cvec &a, const cvec &b, const cvec &c);
499 template ITPP_EXPORT ivec elem_mult(const ivec &a, const ivec &b, const ivec &c);
500 template ITPP_EXPORT svec elem_mult(const svec &a, const svec &b, const svec &c);
501 template ITPP_EXPORT bvec elem_mult(const bvec &a, const bvec &b, const bvec &c);
502 
503 template ITPP_EXPORT void elem_mult_out(const vec &a, const vec &b, const vec &c,
504  vec &out);
505 template ITPP_EXPORT void elem_mult_out(const cvec &a, const cvec &b, const cvec &c,
506  cvec &out);
507 template ITPP_EXPORT void elem_mult_out(const ivec &a, const ivec &b, const ivec &c,
508  ivec &out);
509 template ITPP_EXPORT void elem_mult_out(const svec &a, const svec &b, const svec &c,
510  svec &out);
511 template ITPP_EXPORT void elem_mult_out(const bvec &a, const bvec &b, const bvec &c,
512  bvec &out);
513 
514 template ITPP_EXPORT vec elem_mult(const vec &a, const vec &b, const vec &c,
515  const vec &d);
516 template ITPP_EXPORT cvec elem_mult(const cvec &a, const cvec &b, const cvec &c,
517  const cvec &d);
518 template ITPP_EXPORT ivec elem_mult(const ivec &a, const ivec &b, const ivec &c,
519  const ivec &d);
520 template ITPP_EXPORT svec elem_mult(const svec &a, const svec &b, const svec &c,
521  const svec &d);
522 template ITPP_EXPORT bvec elem_mult(const bvec &a, const bvec &b, const bvec &c,
523  const bvec &d);
524 
525 template ITPP_EXPORT void elem_mult_out(const vec &a, const vec &b, const vec &c,
526  const vec &d, vec &out);
527 template ITPP_EXPORT void elem_mult_out(const cvec &a, const cvec &b, const cvec &c,
528  const cvec &d, cvec &out);
529 template ITPP_EXPORT void elem_mult_out(const ivec &a, const ivec &b, const ivec &c,
530  const ivec &d, ivec &out);
531 template ITPP_EXPORT void elem_mult_out(const svec &a, const svec &b, const svec &c,
532  const svec &d, svec &out);
533 template ITPP_EXPORT void elem_mult_out(const bvec &a, const bvec &b, const bvec &c,
534  const bvec &d, bvec &out);
535 
536 // in-place elementwise multiplication
537 
538 template ITPP_EXPORT void elem_mult_inplace(const vec &a, vec &b);
539 template ITPP_EXPORT void elem_mult_inplace(const cvec &a, cvec &b);
540 template ITPP_EXPORT void elem_mult_inplace(const ivec &a, ivec &b);
541 template ITPP_EXPORT void elem_mult_inplace(const svec &a, svec &b);
542 template ITPP_EXPORT void elem_mult_inplace(const bvec &a, bvec &b);
543 
544 // elementwise multiplication followed by summation
545 
546 template ITPP_EXPORT double elem_mult_sum(const vec &a, const vec &b);
547 template ITPP_EXPORT std::complex<double> elem_mult_sum(const cvec &a, const cvec &b);
548 template ITPP_EXPORT int elem_mult_sum(const ivec &a, const ivec &b);
549 template ITPP_EXPORT short elem_mult_sum(const svec &a, const svec &b);
550 template ITPP_EXPORT bin elem_mult_sum(const bvec &a, const bvec &b);
551 
552 // division operator
553 
554 template ITPP_EXPORT vec operator/(const vec &v, double t);
555 template ITPP_EXPORT cvec operator/(const cvec &v, std::complex<double> t);
556 template ITPP_EXPORT ivec operator/(const ivec &v, int t);
557 template ITPP_EXPORT svec operator/(const svec &v, short t);
558 template ITPP_EXPORT bvec operator/(const bvec &v, bin t);
559 
560 template ITPP_EXPORT vec operator/(double t, const vec &v);
561 template ITPP_EXPORT cvec operator/(std::complex<double> t, const cvec &v);
562 template ITPP_EXPORT ivec operator/(int t, const ivec &v);
563 template ITPP_EXPORT svec operator/(short t, const svec &v);
564 template ITPP_EXPORT bvec operator/(bin t, const bvec &v);
565 
566 // elementwise division operator
567 
568 template ITPP_EXPORT vec elem_div(const vec &a, const vec &b);
569 template ITPP_EXPORT cvec elem_div(const cvec &a, const cvec &b);
570 template ITPP_EXPORT ivec elem_div(const ivec &a, const ivec &b);
571 template ITPP_EXPORT svec elem_div(const svec &a, const svec &b);
572 template ITPP_EXPORT bvec elem_div(const bvec &a, const bvec &b);
573 
574 template ITPP_EXPORT vec elem_div(double t, const vec &v);
575 template ITPP_EXPORT cvec elem_div(std::complex<double> t, const cvec &v);
576 template ITPP_EXPORT ivec elem_div(int t, const ivec &v);
577 template ITPP_EXPORT svec elem_div(short t, const svec &v);
578 template ITPP_EXPORT bvec elem_div(bin t, const bvec &v);
579 
580 template ITPP_EXPORT void elem_div_out(const vec &a, const vec &b, vec &out);
581 template ITPP_EXPORT void elem_div_out(const cvec &a, const cvec &b, cvec &out);
582 template ITPP_EXPORT void elem_div_out(const ivec &a, const ivec &b, ivec &out);
583 template ITPP_EXPORT void elem_div_out(const svec &a, const svec &b, svec &out);
584 template ITPP_EXPORT void elem_div_out(const bvec &a, const bvec &b, bvec &out);
585 
586 // elementwise division followed by summation
587 
588 template ITPP_EXPORT double elem_div_sum(const vec &a, const vec &b);
589 template ITPP_EXPORT std::complex<double> elem_div_sum(const cvec &a, const cvec &b);
590 template ITPP_EXPORT int elem_div_sum(const ivec &a, const ivec &b);
591 template ITPP_EXPORT short elem_div_sum(const svec &a, const svec &b);
592 template ITPP_EXPORT bin elem_div_sum(const bvec &a, const bvec &b);
593 
594 // concat operator
595 
596 template ITPP_EXPORT vec concat(const vec &v, double a);
597 template ITPP_EXPORT cvec concat(const cvec &v, std::complex<double> a);
598 template ITPP_EXPORT ivec concat(const ivec &v, int a);
599 template ITPP_EXPORT svec concat(const svec &v, short a);
600 template ITPP_EXPORT bvec concat(const bvec &v, bin a);
601 
602 template ITPP_EXPORT vec concat(double a, const vec &v);
603 template ITPP_EXPORT cvec concat(std::complex<double> a, const cvec &v);
604 template ITPP_EXPORT ivec concat(int a, const ivec &v);
605 template ITPP_EXPORT svec concat(short a, const svec &v);
606 template ITPP_EXPORT bvec concat(bin a, const bvec &v);
607 
608 template ITPP_EXPORT vec concat(const vec &v1, const vec &v2);
609 template ITPP_EXPORT cvec concat(const cvec &v1, const cvec &v2);
610 template ITPP_EXPORT ivec concat(const ivec &v1, const ivec &v2);
611 template ITPP_EXPORT svec concat(const svec &v1, const svec &v2);
612 template ITPP_EXPORT bvec concat(const bvec &v1, const bvec &v2);
613 
614 template ITPP_EXPORT vec concat(const vec &v1, const vec &v2, const vec &v3);
615 template ITPP_EXPORT cvec concat(const cvec &v1, const cvec &v2, const cvec &v3);
616 template ITPP_EXPORT ivec concat(const ivec &v1, const ivec &v2, const ivec &v3);
617 template ITPP_EXPORT svec concat(const svec &v1, const svec &v2, const svec &v3);
618 template ITPP_EXPORT bvec concat(const bvec &v1, const bvec &v2, const bvec &v3);
619 
620 template ITPP_EXPORT vec concat(const vec &v1, const vec &v2,
621  const vec &v3, const vec &v4);
622 template ITPP_EXPORT cvec concat(const cvec &v1, const cvec &v2,
623  const cvec &v3, const cvec &v4);
624 template ITPP_EXPORT ivec concat(const ivec &v1, const ivec &v2,
625  const ivec &v3, const ivec &v4);
626 template ITPP_EXPORT svec concat(const svec &v1, const svec &v2,
627  const svec &v3, const svec &v4);
628 template ITPP_EXPORT bvec concat(const bvec &v1, const bvec &v2,
629  const bvec &v3, const bvec &v4);
630 
631 template ITPP_EXPORT vec concat(const vec &v1, const vec &v2, const vec &v3,
632  const vec &v4, const vec &v5);
633 template ITPP_EXPORT cvec concat(const cvec &v1, const cvec &v2, const cvec &v3,
634  const cvec &v4, const cvec &v5);
635 template ITPP_EXPORT ivec concat(const ivec &v1, const ivec &v2, const ivec &v3,
636  const ivec &v4, const ivec &v5);
637 template ITPP_EXPORT svec concat(const svec &v1, const svec &v2, const svec &v3,
638  const svec &v4, const svec &v5);
639 template ITPP_EXPORT bvec concat(const bvec &v1, const bvec &v2, const bvec &v3,
640  const bvec &v4, const bvec &v5);
641 
642 // I/O streams
643 
644 template ITPP_EXPORT std::ostream &operator<<(std::ostream& os, const vec &vect);
645 template ITPP_EXPORT std::ostream &operator<<(std::ostream& os, const cvec &vect);
646 template ITPP_EXPORT std::ostream &operator<<(std::ostream& os, const svec &vect);
647 template ITPP_EXPORT std::ostream &operator<<(std::ostream& os, const ivec &vect);
648 template ITPP_EXPORT std::ostream &operator<<(std::ostream& os, const bvec &vect);
649 template ITPP_EXPORT std::istream &operator>>(std::istream& is, vec &vect);
650 template ITPP_EXPORT std::istream &operator>>(std::istream& is, cvec &vect);
651 template ITPP_EXPORT std::istream &operator>>(std::istream& is, svec &vect);
652 template ITPP_EXPORT std::istream &operator>>(std::istream& is, ivec &vect);
653 template ITPP_EXPORT std::istream &operator>>(std::istream& is, bvec &vect);
654 
655 } // namespace itpp
656 
SourceForge Logo

Generated on Sat May 25 2013 16:32:20 for IT++ by Doxygen 1.8.2