00001 00029 #ifndef _MSC_VER 00030 # include <itpp/config.h> 00031 #else 00032 # include <itpp/config_msvc.h> 00033 #endif 00034 00035 #if defined (HAVE_BLAS) 00036 # include <itpp/base/blas.h> 00037 #endif 00038 00039 #include <itpp/base/vec.h> 00040 #include <itpp/base/converters.h> 00041 #include <cstdio> 00042 #include <limits> 00043 00045 00046 namespace itpp 00047 { 00048 00049 00050 template<class Num_T> 00051 std::vector<std::string> Vec<Num_T>::tokenize(const std::string &str_in, 00052 bool &abc_format) const 00053 { 00054 std::vector<std::string> vs; // vector for storing parsed tokens 00055 std::string s; // currently processed token string 00056 bool start = true; 00057 bool space = false; 00058 bool colon = false; 00059 bool comma = false; 00060 bool lparen = false; 00061 abc_format = false; 00062 for (std::string::size_type i = 0; i < str_in.size(); ++i) { 00063 char c = str_in[i]; 00064 switch (c) { 00065 case ' ': case '\t': 00066 space = true; // set flag for whitespaces 00067 break; 00068 case ',': 00069 if (lparen) 00070 comma = true; // set flag for comma in "(re,im)" format 00071 else 00072 space = true; // otherwise treat comma as separator 00073 break; 00074 case ')': 00075 s.push_back('i'); // replace right paren in "(re,im)" with 'i' 00076 break; 00077 case ':': 00078 colon = true; // set flag for "a:b[:c]" format string 00079 space = false; // reset flag for whitespaces 00080 abc_format = true; // set external flag for "a:b[:c]" format 00081 s.push_back(c); 00082 break; 00083 case '(': 00084 lparen = true; // set flag for complex "(re,im)" format 00085 break; 00086 default: 00087 if (colon) { // reset colon and space flags 00088 colon = false; // to get rid of whitespaces around ":" 00089 space = false; 00090 } 00091 else if (lparen && comma) { // support for "(re,im)" format 00092 lparen = false; 00093 comma = false; 00094 space = false; 00095 if ((c != '-') && (c != '+')) // if needed 00096 s.push_back('+'); // insert '+' between "re" and "im" 00097 } 00098 else if (space) { // new token detected 00099 space = false; 00100 if (!start) { // if not at the beginning of the string 00101 vs.push_back(s); // store already parsed token 00102 s.clear(); // and start parsing the next token 00103 } 00104 } 00105 s.push_back(c); // append next character to the current token 00106 start = false; // reset the "beginning of the string" flag 00107 break; 00108 } 00109 } 00110 if (!s.empty()) // if the final token is not an empty string 00111 vs.push_back(s); // store it in the output vector 00112 return vs; 00113 } 00114 00115 00116 template<> 00117 int Vec<int>::parse_token(const std::string &s) const 00118 { 00119 int out; 00120 std::istringstream buffer(s); 00121 if (s.find('x', 1) != std::string::npos) { 00122 buffer >> std::hex >> out; 00123 } 00124 else if (((s[0] == '0') 00125 || (((s[0] == '-') || (s[0] == '+')) && (s[1] == '0'))) 00126 && (s.find('8', 1) == std::string::npos) 00127 && (s.find('9', 1) == std::string::npos)) { 00128 buffer >> std::oct >> out; 00129 } 00130 else { 00131 buffer >> std::dec >> out; 00132 } 00133 return out; 00134 } 00135 00136 template<> 00137 double Vec<double>::parse_token(const std::string &s) const 00138 { 00139 double out; 00140 if ((s == "NaN") || (s == "nan") || (s == "NAN")) { 00141 if (std::numeric_limits<double>::has_quiet_NaN) 00142 out = std::numeric_limits<double>::quiet_NaN(); 00143 else if (std::numeric_limits<double>::has_signaling_NaN) 00144 out = std::numeric_limits<double>::signaling_NaN(); 00145 else 00146 it_error("Vec<double>::set(): NaN not supported"); 00147 } 00148 else if ((s =="-Inf") || (s =="-inf") || (s =="-INF")) { 00149 out = -std::numeric_limits<double>::infinity(); 00150 } 00151 else if ((s =="Inf") || (s =="inf") || (s =="INF") || 00152 (s =="+Inf") || (s =="+inf") || (s =="+INF")) { 00153 out = std::numeric_limits<double>::infinity(); 00154 } 00155 else { 00156 std::istringstream buffer(s); 00157 buffer >> out; 00158 it_assert(!buffer.fail(), "Vec<double>::set(): Stream operation failed " 00159 "(buffer >> out)"); 00160 } 00161 return out; 00162 } 00163 00164 00165 template<> 00166 void Vec<bin>::set(const std::string &str) 00167 { 00168 bool abc_format; 00169 std::vector<std::string> tokens = tokenize(str, abc_format); 00170 it_assert(!abc_format, "Vec<bin>::set(): \"a:b:c\" format string not " 00171 "supported for binary vectors"); 00172 set_size(tokens.size()); 00173 for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) { 00174 std::istringstream buffer(tokens[i]); 00175 buffer >> data[i]; 00176 it_assert(!buffer.fail(), "Vec<bin>::set(): Stream operation failed " 00177 "(buffer >> data)"); 00178 } 00179 } 00180 00181 template<> 00182 void Vec<short int>::set(const std::string &str) 00183 { 00184 // parser for "short int" is the same as for "int", so reuse it here 00185 ivec iv(str); 00186 this->operator=(to_svec(iv)); 00187 } 00188 00189 template<> 00190 void Vec<int>::set(const std::string &str) 00191 { 00192 bool abc_format; 00193 std::vector<std::string> tokens = tokenize(str, abc_format); 00194 // no "a:b:c" tokens, so the size of output vector is known 00195 if (!abc_format) { 00196 set_size(tokens.size()); 00197 for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) 00198 data[i] = parse_token(tokens[i]); 00199 } 00200 else { 00201 int pos = 0; 00202 set_size((tokens.size() > 20) ? tokens.size() : 20); 00203 for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) { 00204 // check if the current token is in "a:b[:c]" format 00205 if (tokens[i].find(':', 1) == std::string::npos) { 00206 if (++pos > datasize) { 00207 set_size(2 * datasize, true); 00208 } 00209 data[pos-1] = parse_token(tokens[i]); 00210 } 00211 else { 00212 int a, b, c; 00213 parse_abc_token(tokens[i], a, b, c); 00214 if (++pos > datasize) { 00215 set_size(2 * datasize, true); 00216 } 00217 data[pos-1] = a; 00218 00219 if ((b > 0) && (c >= a)) { 00220 while ((data[pos-1] + b) <= c) { 00221 if (++pos > datasize) { 00222 set_size(2 * datasize, true); 00223 } 00224 data[pos-1] = data[pos-2] + b; 00225 } 00226 } 00227 else if ((b < 0) && (c <= a)) { 00228 while ((data[pos-1] + b) >= c) { 00229 if (++pos > datasize) { 00230 set_size(2 * datasize, true); 00231 } 00232 data[pos-1] = data[pos-2] + b; 00233 } 00234 } 00235 else if (b == 0 && c == a) { 00236 break; 00237 } 00238 else { 00239 it_error("Vec<int>::set(): Improper data string (a:b:c)"); 00240 } 00241 } 00242 } 00243 set_size(pos, true); 00244 } // if (!abc_format) 00245 } 00246 00247 00248 template<> 00249 void Vec<double>::set(const std::string &str) 00250 { 00251 bool abc_format; 00252 std::vector<std::string> tokens = tokenize(str, abc_format); 00253 // no "a:b:c" tokens, so the size of output vector is known 00254 if (!abc_format) { 00255 set_size(tokens.size()); 00256 for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) 00257 data[i] = parse_token(tokens[i]); 00258 } 00259 else { 00260 int pos = 0; 00261 set_size((tokens.size() > 20) ? tokens.size() : 20); 00262 for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) { 00263 // check if the current token is in "a:b[:c]" format 00264 if (tokens[i].find(':', 1) == std::string::npos) { 00265 if (++pos > datasize) { 00266 set_size(2 * datasize, true); 00267 } 00268 data[pos-1] = parse_token(tokens[i]); 00269 } 00270 else { 00271 double a, b, c; 00272 parse_abc_token(tokens[i], a, b, c); 00273 if (++pos > datasize) { 00274 set_size(2 * datasize, true); 00275 } 00276 data[pos-1] = a; 00277 // Adding this margin fixes precision problems in e.g. "0:0.2:3", 00278 // where the last value was 2.8 instead of 3. 00279 double eps_margin = std::fabs((c - a) / b) * eps; 00280 if ((b > 0) && (c >= a)) { 00281 while ((data[pos-1] + b) <= (c + eps_margin)) { 00282 if (++pos > datasize) { 00283 set_size(2 * datasize, true); 00284 } 00285 data[pos-1] = data[pos-2] + b; 00286 } 00287 } 00288 else if ((b < 0) && (c <= a)) { 00289 while ((data[pos-1] + b) >= (c - eps_margin)) { 00290 if (++pos > datasize) { 00291 set_size(2 * datasize, true); 00292 } 00293 data[pos-1] = data[pos-2] + b; 00294 } 00295 } 00296 else if (b == 0 && c == a) { 00297 break; 00298 } 00299 else { 00300 it_error("Vec<double>::set(): Improper data string (a:b:c)"); 00301 } 00302 } 00303 } 00304 set_size(pos, true); 00305 } // if (!abc_format) 00306 } 00307 00308 template<> 00309 void Vec<std::complex<double> >::set(const std::string &str) 00310 { 00311 bool abc_format; 00312 std::vector<std::string> tokens = tokenize(str, abc_format); 00313 it_assert(!abc_format, "Vec<bin>::set(): \"a:b:c\" format string not " 00314 "supported for binary vectors"); 00315 set_size(tokens.size()); 00316 for (std::vector<std::string>::size_type i = 0; i < tokens.size(); ++i) { 00317 std::istringstream buffer(tokens[i]); 00318 buffer >> data[i]; 00319 it_assert(!buffer.fail(), "Vec<complex>::set(): Stream operation failed " 00320 "(buffer >> data)"); 00321 } 00322 } 00323 00324 00325 #if defined(HAVE_BLAS) 00326 template<> 00327 double dot(const vec &v1, const vec &v2) 00328 { 00329 it_assert_debug(v1.datasize == v2.datasize, "vec::dot(): Wrong sizes"); 00330 int incr = 1; 00331 return blas::ddot_(&v1.datasize, v1.data, &incr, v2.data, &incr); 00332 } 00333 #else 00334 template<> 00335 double dot(const vec &v1, const vec &v2) 00336 { 00337 it_assert_debug(v1.datasize == v2.datasize, "Vec::dot(): Wrong sizes"); 00338 double r = 0.0; 00339 for (int i = 0; i < v1.datasize; ++i) 00340 r += v1.data[i] * v2.data[i]; 00341 return r; 00342 } 00343 #endif // HAVE_BLAS 00344 00345 #if defined(HAVE_BLAS) 00346 template<> 00347 mat outer_product(const vec &v1, const vec &v2, bool) 00348 { 00349 it_assert_debug((v1.datasize > 0) && (v2.datasize > 0), 00350 "Vec::outer_product():: Input vector of zero size"); 00351 00352 mat out(v1.datasize, v2.datasize); 00353 out.zeros(); 00354 double alpha = 1.0; 00355 int incr = 1; 00356 blas::dger_(&v1.datasize, &v2.datasize, &alpha, v1.data, &incr, 00357 v2.data, &incr, out._data(), &v1.datasize); 00358 return out; 00359 } 00360 00361 template<> 00362 cmat outer_product(const cvec &v1, const cvec &v2, bool hermitian) 00363 { 00364 it_assert_debug((v1.datasize > 0) && (v2.datasize > 0), 00365 "Vec::outer_product():: Input vector of zero size"); 00366 00367 cmat out(v1.datasize, v2.datasize); 00368 out.zeros(); 00369 std::complex<double> alpha(1.0); 00370 int incr = 1; 00371 if (hermitian) { 00372 blas::zgerc_(&v1.datasize, &v2.datasize, &alpha, v1.data, &incr, 00373 v2.data, &incr, out._data(), &v1.datasize); 00374 } 00375 else { 00376 blas::zgeru_(&v1.datasize, &v2.datasize, &alpha, v1.data, &incr, 00377 v2.data, &incr, out._data(), &v1.datasize); 00378 } 00379 return out; 00380 } 00381 #else 00382 template<> 00383 mat outer_product(const vec &v1, const vec &v2, bool) 00384 { 00385 it_assert_debug((v1.datasize > 0) && (v2.datasize > 0), 00386 "Vec::outer_product():: Input vector of zero size"); 00387 00388 mat out(v1.datasize, v2.datasize); 00389 for (int i = 0; i < v1.datasize; ++i) { 00390 for (int j = 0; j < v2.datasize; ++j) { 00391 out(i, j) = v1.data[i] * v2.data[j]; 00392 } 00393 } 00394 return out; 00395 } 00396 00397 template<> 00398 cmat outer_product(const cvec &v1, const cvec &v2, bool hermitian) 00399 { 00400 it_assert_debug((v1.datasize > 0) && (v2.datasize > 0), 00401 "Vec::outer_product():: Input vector of zero size"); 00402 00403 cmat out(v1.datasize, v2.datasize); 00404 if (hermitian) { 00405 for (int i = 0; i < v1.datasize; ++i) { 00406 for (int j = 0; j < v2.datasize; ++j) { 00407 out(i, j) = v1.data[i] * conj(v2.data[j]); 00408 } 00409 } 00410 } 00411 else { 00412 for (int i = 0; i < v1.datasize; ++i) { 00413 for (int j = 0; j < v2.datasize; ++j) { 00414 out(i, j) = v1.data[i] * v2.data[j]; 00415 } 00416 } 00417 } 00418 return out; 00419 } 00420 #endif // HAVE_BLAS 00421 00422 00423 template<> 00424 bvec Vec<std::complex<double> >::operator<=(std::complex<double>) const 00425 { 00426 it_error("operator<=: not implemented for complex"); 00427 bvec temp; 00428 return temp; 00429 } 00430 00431 template<> 00432 bvec Vec<std::complex<double> >::operator>(std::complex<double>) const 00433 { 00434 it_error("operator>: not implemented for complex"); 00435 bvec temp; 00436 return temp; 00437 } 00438 00439 template<> 00440 bvec Vec<std::complex<double> >::operator<(std::complex<double>) const 00441 { 00442 it_error("operator<: not implemented for complex"); 00443 bvec temp; 00444 return temp; 00445 } 00446 00447 template<> 00448 bvec Vec<std::complex<double> >::operator>=(std::complex<double>) const 00449 { 00450 it_error("operator>=: not implemented for complex"); 00451 bvec temp; 00452 return temp; 00453 } 00454 00455 template<> 00456 Mat<std::complex<double> > Vec<std::complex<double> >::hermitian_transpose() const 00457 { 00458 Mat<std::complex<double> > temp(1, datasize); 00459 for (int i = 0; i < datasize; i++) 00460 temp(i) = std::conj(data[i]); 00461 00462 return temp; 00463 } 00464 00465 00466 //--------------------------------------------------------------------- 00467 // Instantiations 00468 //--------------------------------------------------------------------- 00469 00470 template class Vec<double>; 00471 template class Vec<int>; 00472 template class Vec<short int>; 00473 template class Vec<std::complex<double> >; 00474 template class Vec<bin>; 00475 00476 // addition operator 00477 00478 template vec operator+(const vec &v1, const vec &v2); 00479 template cvec operator+(const cvec &v1, const cvec &v2); 00480 template ivec operator+(const ivec &v1, const ivec &v2); 00481 template svec operator+(const svec &v1, const svec &v2); 00482 template bvec operator+(const bvec &v1, const bvec &v2); 00483 00484 template vec operator+(const vec &v1, double t); 00485 template cvec operator+(const cvec &v1, std::complex<double> t); 00486 template ivec operator+(const ivec &v1, int t); 00487 template svec operator+(const svec &v1, short t); 00488 template bvec operator+(const bvec &v1, bin t); 00489 00490 template vec operator+(double t, const vec &v1); 00491 template cvec operator+(std::complex<double> t, const cvec &v1); 00492 template ivec operator+(int t, const ivec &v1); 00493 template svec operator+(short t, const svec &v1); 00494 template bvec operator+(bin t, const bvec &v1); 00495 00496 // subraction operator 00497 00498 template vec operator-(const vec &v1, const vec &v2); 00499 template cvec operator-(const cvec &v1, const cvec &v2); 00500 template ivec operator-(const ivec &v1, const ivec &v2); 00501 template svec operator-(const svec &v1, const svec &v2); 00502 template bvec operator-(const bvec &v1, const bvec &v2); 00503 00504 template vec operator-(const vec &v, double t); 00505 template cvec operator-(const cvec &v, std::complex<double> t); 00506 template ivec operator-(const ivec &v, int t); 00507 template svec operator-(const svec &v, short t); 00508 template bvec operator-(const bvec &v, bin t); 00509 00510 template vec operator-(double t, const vec &v); 00511 template cvec operator-(std::complex<double> t, const cvec &v); 00512 template ivec operator-(int t, const ivec &v); 00513 template svec operator-(short t, const svec &v); 00514 template bvec operator-(bin t, const bvec &v); 00515 00516 // unary minus 00517 00518 template vec operator-(const vec &v); 00519 template cvec operator-(const cvec &v); 00520 template ivec operator-(const ivec &v); 00521 template svec operator-(const svec &v); 00522 template bvec operator-(const bvec &v); 00523 00524 // multiplication operator 00525 00526 #if !defined(HAVE_BLAS) 00527 template double dot(const vec &v1, const vec &v2); 00528 #endif 00529 template std::complex<double> dot(const cvec &v1, const cvec &v2); 00530 template int dot(const ivec &v1, const ivec &v2); 00531 template short dot(const svec &v1, const svec &v2); 00532 template bin dot(const bvec &v1, const bvec &v2); 00533 00534 template double operator*(const vec &v1, const vec &v2); 00535 template std::complex<double> operator*(const cvec &v1, const cvec &v2); 00536 template int operator*(const ivec &v1, const ivec &v2); 00537 template short operator*(const svec &v1, const svec &v2); 00538 template bin operator*(const bvec &v1, const bvec &v2); 00539 00540 #if !defined(HAVE_BLAS) 00541 template mat outer_product(const vec &v1, const vec &v2, bool hermitian); 00542 #endif 00543 template imat outer_product(const ivec &v1, const ivec &v2, bool hermitian); 00544 template smat outer_product(const svec &v1, const svec &v2, bool hermitian); 00545 template bmat outer_product(const bvec &v1, const bvec &v2, bool hermitian); 00546 00547 template vec operator*(const vec &v, double t); 00548 template cvec operator*(const cvec &v, std::complex<double> t); 00549 template ivec operator*(const ivec &v, int t); 00550 template svec operator*(const svec &v, short t); 00551 template bvec operator*(const bvec &v, bin t); 00552 00553 template vec operator*(double t, const vec &v); 00554 template cvec operator*(std::complex<double> t, const cvec &v); 00555 template ivec operator*(int t, const ivec &v); 00556 template svec operator*(short t, const svec &v); 00557 template bvec operator*(bin t, const bvec &v); 00558 00559 // elementwise multiplication 00560 00561 template vec elem_mult(const vec &a, const vec &b); 00562 template cvec elem_mult(const cvec &a, const cvec &b); 00563 template ivec elem_mult(const ivec &a, const ivec &b); 00564 template svec elem_mult(const svec &a, const svec &b); 00565 template bvec elem_mult(const bvec &a, const bvec &b); 00566 00567 template void elem_mult_out(const vec &a, const vec &b, vec &out); 00568 template void elem_mult_out(const cvec &a, const cvec &b, cvec &out); 00569 template void elem_mult_out(const ivec &a, const ivec &b, ivec &out); 00570 template void elem_mult_out(const svec &a, const svec &b, svec &out); 00571 template void elem_mult_out(const bvec &a, const bvec &b, bvec &out); 00572 00573 template vec elem_mult(const vec &a, const vec &b, const vec &c); 00574 template cvec elem_mult(const cvec &a, const cvec &b, const cvec &c); 00575 template ivec elem_mult(const ivec &a, const ivec &b, const ivec &c); 00576 template svec elem_mult(const svec &a, const svec &b, const svec &c); 00577 template bvec elem_mult(const bvec &a, const bvec &b, const bvec &c); 00578 00579 template void elem_mult_out(const vec &a, const vec &b, const vec &c, 00580 vec &out); 00581 template void elem_mult_out(const cvec &a, const cvec &b, const cvec &c, 00582 cvec &out); 00583 template void elem_mult_out(const ivec &a, const ivec &b, const ivec &c, 00584 ivec &out); 00585 template void elem_mult_out(const svec &a, const svec &b, const svec &c, 00586 svec &out); 00587 template void elem_mult_out(const bvec &a, const bvec &b, const bvec &c, 00588 bvec &out); 00589 00590 template vec elem_mult(const vec &a, const vec &b, const vec &c, 00591 const vec &d); 00592 template cvec elem_mult(const cvec &a, const cvec &b, const cvec &c, 00593 const cvec &d); 00594 template ivec elem_mult(const ivec &a, const ivec &b, const ivec &c, 00595 const ivec &d); 00596 template svec elem_mult(const svec &a, const svec &b, const svec &c, 00597 const svec &d); 00598 template bvec elem_mult(const bvec &a, const bvec &b, const bvec &c, 00599 const bvec &d); 00600 00601 template void elem_mult_out(const vec &a, const vec &b, const vec &c, 00602 const vec &d, vec &out); 00603 template void elem_mult_out(const cvec &a, const cvec &b, const cvec &c, 00604 const cvec &d, cvec &out); 00605 template void elem_mult_out(const ivec &a, const ivec &b, const ivec &c, 00606 const ivec &d, ivec &out); 00607 template void elem_mult_out(const svec &a, const svec &b, const svec &c, 00608 const svec &d, svec &out); 00609 template void elem_mult_out(const bvec &a, const bvec &b, const bvec &c, 00610 const bvec &d, bvec &out); 00611 00612 // in-place elementwise multiplication 00613 00614 template void elem_mult_inplace(const vec &a, vec &b); 00615 template void elem_mult_inplace(const cvec &a, cvec &b); 00616 template void elem_mult_inplace(const ivec &a, ivec &b); 00617 template void elem_mult_inplace(const svec &a, svec &b); 00618 template void elem_mult_inplace(const bvec &a, bvec &b); 00619 00620 // elementwise multiplication followed by summation 00621 00622 template double elem_mult_sum(const vec &a, const vec &b); 00623 template std::complex<double> elem_mult_sum(const cvec &a, const cvec &b); 00624 template int elem_mult_sum(const ivec &a, const ivec &b); 00625 template short elem_mult_sum(const svec &a, const svec &b); 00626 template bin elem_mult_sum(const bvec &a, const bvec &b); 00627 00628 // division operator 00629 00630 template vec operator/(const vec &v, double t); 00631 template cvec operator/(const cvec &v, std::complex<double> t); 00632 template ivec operator/(const ivec &v, int t); 00633 template svec operator/(const svec &v, short t); 00634 template bvec operator/(const bvec &v, bin t); 00635 00636 template vec operator/(double t, const vec &v); 00637 template cvec operator/(std::complex<double> t, const cvec &v); 00638 template ivec operator/(int t, const ivec &v); 00639 template svec operator/(short t, const svec &v); 00640 template bvec operator/(bin t, const bvec &v); 00641 00642 // elementwise division operator 00643 00644 template vec elem_div(const vec &a, const vec &b); 00645 template cvec elem_div(const cvec &a, const cvec &b); 00646 template ivec elem_div(const ivec &a, const ivec &b); 00647 template svec elem_div(const svec &a, const svec &b); 00648 template bvec elem_div(const bvec &a, const bvec &b); 00649 00650 template vec elem_div(double t, const vec &v); 00651 template cvec elem_div(std::complex<double> t, const cvec &v); 00652 template ivec elem_div(int t, const ivec &v); 00653 template svec elem_div(short t, const svec &v); 00654 template bvec elem_div(bin t, const bvec &v); 00655 00656 template void elem_div_out(const vec &a, const vec &b, vec &out); 00657 template void elem_div_out(const cvec &a, const cvec &b, cvec &out); 00658 template void elem_div_out(const ivec &a, const ivec &b, ivec &out); 00659 template void elem_div_out(const svec &a, const svec &b, svec &out); 00660 template void elem_div_out(const bvec &a, const bvec &b, bvec &out); 00661 00662 // elementwise division followed by summation 00663 00664 template double elem_div_sum(const vec &a, const vec &b); 00665 template std::complex<double> elem_div_sum(const cvec &a, const cvec &b); 00666 template int elem_div_sum(const ivec &a, const ivec &b); 00667 template short elem_div_sum(const svec &a, const svec &b); 00668 template bin elem_div_sum(const bvec &a, const bvec &b); 00669 00670 // concat operator 00671 00672 template vec concat(const vec &v, double a); 00673 template cvec concat(const cvec &v, std::complex<double> a); 00674 template ivec concat(const ivec &v, int a); 00675 template svec concat(const svec &v, short a); 00676 template bvec concat(const bvec &v, bin a); 00677 00678 template vec concat(double a, const vec &v); 00679 template cvec concat(std::complex<double> a, const cvec &v); 00680 template ivec concat(int a, const ivec &v); 00681 template svec concat(short a, const svec &v); 00682 template bvec concat(bin a, const bvec &v); 00683 00684 template vec concat(const vec &v1, const vec &v2); 00685 template cvec concat(const cvec &v1, const cvec &v2); 00686 template ivec concat(const ivec &v1, const ivec &v2); 00687 template svec concat(const svec &v1, const svec &v2); 00688 template bvec concat(const bvec &v1, const bvec &v2); 00689 00690 template vec concat(const vec &v1, const vec &v2, const vec &v3); 00691 template cvec concat(const cvec &v1, const cvec &v2, const cvec &v3); 00692 template ivec concat(const ivec &v1, const ivec &v2, const ivec &v3); 00693 template svec concat(const svec &v1, const svec &v2, const svec &v3); 00694 template bvec concat(const bvec &v1, const bvec &v2, const bvec &v3); 00695 00696 template vec concat(const vec &v1, const vec &v2, 00697 const vec &v3, const vec &v4); 00698 template cvec concat(const cvec &v1, const cvec &v2, 00699 const cvec &v3, const cvec &v4); 00700 template ivec concat(const ivec &v1, const ivec &v2, 00701 const ivec &v3, const ivec &v4); 00702 template svec concat(const svec &v1, const svec &v2, 00703 const svec &v3, const svec &v4); 00704 template bvec concat(const bvec &v1, const bvec &v2, 00705 const bvec &v3, const bvec &v4); 00706 00707 template vec concat(const vec &v1, const vec &v2, const vec &v3, 00708 const vec &v4, const vec &v5); 00709 template cvec concat(const cvec &v1, const cvec &v2, const cvec &v3, 00710 const cvec &v4, const cvec &v5); 00711 template ivec concat(const ivec &v1, const ivec &v2, const ivec &v3, 00712 const ivec &v4, const ivec &v5); 00713 template svec concat(const svec &v1, const svec &v2, const svec &v3, 00714 const svec &v4, const svec &v5); 00715 template bvec concat(const bvec &v1, const bvec &v2, const bvec &v3, 00716 const bvec &v4, const bvec &v5); 00717 00718 // I/O streams 00719 00720 template std::ostream &operator<<(std::ostream& os, const vec &vect); 00721 template std::ostream &operator<<(std::ostream& os, const cvec &vect); 00722 template std::ostream &operator<<(std::ostream& os, const svec &vect); 00723 template std::ostream &operator<<(std::ostream& os, const ivec &vect); 00724 template std::ostream &operator<<(std::ostream& os, const bvec &vect); 00725 template std::istream &operator>>(std::istream& is, vec &vect); 00726 template std::istream &operator>>(std::istream& is, cvec &vect); 00727 template std::istream &operator>>(std::istream& is, svec &vect); 00728 template std::istream &operator>>(std::istream& is, ivec &vect); 00729 template std::istream &operator>>(std::istream& is, bvec &vect); 00730 00731 } // namespace itpp 00732
Generated on Sat Jul 9 2011 15:21:30 for IT++ by Doxygen 1.7.4