37#include <itpp/itexports.h>
43template<
class Num_T>
class Vec;
45template<
class Num_T>
class Mat;
92 bool hermitian =
false);
284 void set(
const char *str);
286 void set(
const std::string &str);
304 const Num_T &
get(
int i)
const;
510 std::vector<std::string> tokenize(
const std::string &str,
511 bool &abc_format)
const;
513 Num_T parse_token(
const std::string &s)
const;
515 void parse_abc_token(
const std::string &s, Num_T &a, Num_T &b,
518 bool in_range(
int i)
const {
return ((i <
datasize) && (i >= 0)); }
592template<
class Num_T>
inline
605template<
class Num_T>
inline
613template<
class Num_T>
inline
616template<
class Num_T>
inline
623template<
class Num_T>
inline
630template<
class Num_T>
inline
637template<
class Num_T>
inline
640 set(std::string(str));
643template<
class Num_T>
inline
649template<
class Num_T>
inline
656template<
class Num_T>
inline
680 for (
int i =
min; i <
size; ++i)
691template<
class Num_T>
inline
698template<
class Num_T>
inline
704template<
class Num_T>
inline
711template<
class Num_T>
inline
717template<
class Num_T>
inline
724 "Vec<>::operator()(i1, i2): Indexing out of range");
737 for (
int i = 0; i <
size; ++i) {
739 "Index i=" << i <<
" out of range");
740 temp(i) =
data[indexlist(i)];
750 "Wrong size of binlist vector");
753 for (
int i = 0; i <
size; ++i)
754 if (binlist(i) ==
bin(1))
761template<
class Num_T>
inline
767template<
class Num_T>
inline
770 return (*
this)(i1, i2);
773template<
class Num_T>
inline
776 return (*
this)(indexlist);
779template<
class Num_T>
inline
782 return (*
this)(binlist);
785template<
class Num_T>
inline
792template<
class Num_T>
inline
799template<
class Num_T>
inline
806template<
class Num_T>
inline
809 it_error(
"Vec::set(): Only `double', `complex<double>', `int', "
810 "`short int' and `bin' types supported");
813template<
class Num_T>
inline
816 set(std::string(str));
871template<
class Num_T>
inline
922 for (
int i = 0; i < v.
datasize; i++)
934template<
class Num_T>
inline
991template<
class Num_T>
inline
998template<
class Num_T>
inline
1004template<
class Num_T>
1009 for (
int i = 0; i < v1.
length(); ++i)
1016ITPP_EXPORT
double dot(
const vec &v1,
const vec &v2);
1020template<
class Num_T>
1024 "Vec::outer_product:: Input vector of zero size");
1027 for (
int i = 0; i < v1.
length(); ++i) {
1028 for (
int j = 0; j < v2.
length(); ++j) {
1037ITPP_EXPORT mat
outer_product(
const vec &v1,
const vec &v2,
bool);
1040ITPP_EXPORT cmat
outer_product(
const cvec &v1,
const cvec &v2,
bool hermitian);
1043template<
class Num_T>
1054template<
class Num_T>
inline
1060template<
class Num_T>
inline
1068template<
class Num_T>
inline
1077template<
class Num_T>
inline
1086template<
class Num_T>
1090 "Vec<>::elem_mult_out(): Wrong sizes");
1092 for (
int i = 0; i < a.
datasize; i++)
1096template<
class Num_T>
1101 "Vec<>::elem_mult_out(): Wrong sizes");
1103 for (
int i = 0; i < a.
datasize; i++)
1107template<
class Num_T>
1113 "Vec<>::elem_mult_out(): Wrong sizes");
1115 for (
int i = 0; i < a.
datasize; i++)
1119template<
class Num_T>
1126 "Vec<>::elem_mult_inplace(): Wrong sizes");
1127 for (
int i = 0; i < a.
datasize; i++)
1131template<
class Num_T>
inline
1135 "Vec<>::elem_mult_sum(): Wrong sizes");
1137 for (
int i = 0; i < a.
datasize; i++)
1142template<
class Num_T>
1154template<
class Num_T>
1166template<
class Num_T>
1169 it_warning(
"Vec<>::elem_div(Num_T, const Vec<Num_T> &): This function is "
1170 "deprecated and might be removed from future IT++ releases. "
1171 "Please use Vec<>::operator/(Num_T, const Vec<Num_T> &) "
1176template<
class Num_T>
inline
1179 for (
int i = 0; i <
datasize; ++i) {
1185template<
class Num_T>
inline
1189 for (
int i = 0; i <
datasize; ++i) {
1195template<
class Num_T>
inline
1203template<
class Num_T>
1210 for (
int i = 0; i < a.
datasize; i++)
1214template<
class Num_T>
inline
1221 for (
int i = 0; i < a.
datasize; i++)
1227template<
class Num_T>
1238template<
class Num_T>
1249template<
class Num_T>
1253 "Vec::mid(): indexing out of range");
1256 copy_vector(nr, &
data[start], temp.
data);
1261template<
class Num_T>
1265 "Vec<>::split(): Index out of range");
1268 copy_vector(pos,
data, temp1.
data);
1281template<
class Num_T>
1293template<
class Num_T>
1298 for (
int i = 0; i < v.
datasize; i++)
1302template<
class Num_T>
1314template<
class Num_T>
1323template<
class Num_T>
1333template<
class Num_T>
1343template<
class Num_T>
1346 int size1 = v1.
size();
1347 int size2 = v2.
size();
1349 copy_vector(size1, v1.
data, temp.
data);
1350 copy_vector(size2, v2.
data, &temp.
data[size1]);
1354template<
class Num_T>
1358 int size1 = v1.
size();
1359 int size2 = v2.
size();
1360 int size3 = v3.
size();
1362 copy_vector(size1, v1.
data, temp.
data);
1363 copy_vector(size2, v2.
data, &temp.
data[size1]);
1364 copy_vector(size3, v3.
data, &temp.
data[size1+size2]);
1368template<
class Num_T>
1372 int size1 = v1.
size();
1373 int size2 = v2.
size();
1374 int size3 = v3.
size();
1375 int size4 = v4.
size();
1376 Vec<Num_T> temp(size1 + size2 + size3 + size4);
1377 copy_vector(size1, v1.
data, temp.
data);
1378 copy_vector(size2, v2.
data, &temp.
data[size1]);
1379 copy_vector(size3, v3.
data, &temp.
data[size1+size2]);
1380 copy_vector(size4, v4.
data, &temp.
data[size1+size2+size3]);
1384template<
class Num_T>
1389 int size1 = v1.
size();
1390 int size2 = v2.
size();
1391 int size3 = v3.
size();
1392 int size4 = v4.
size();
1393 int size5 = v5.
size();
1394 Vec<Num_T> temp(size1 + size2 + size3 + size4 + size5);
1395 copy_vector(size1, v1.
data, temp.
data);
1396 copy_vector(size2, v2.
data, &temp.
data[size1]);
1397 copy_vector(size3, v3.
data, &temp.
data[size1+size2]);
1398 copy_vector(size4, v4.
data, &temp.
data[size1+size2+size3]);
1399 copy_vector(size5, v5.
data, &temp.
data[size1+size2+size3+size4]);
1403template<
class Num_T>
1406 it_warning(
"Vec<>::set_subvector(int, int, const Vec<> &): This function "
1407 "is deprecated and might be removed from future IT++ releases. "
1408 "Please use Vec<>::set_subvector(int, const Vec<> &) instead.");
1412template<
class Num_T>
inline
1416 "Vec<>::set_subvector(int, const Vec<> &): "
1417 "Index out of range or too long input vector");
1421template<
class Num_T>
inline
1427 "Vec<>::set_subvector(int, int, Num_T): Indexing out "
1429 for (
int i = i1; i <= i2; i++)
1433template<
class Num_T>
inline
1439template<
class Num_T>
1442 it_assert_debug(in_range(index),
"Vec<>::del(int): Index out of range");
1445 copy_vector(index, temp.
data,
data);
1449template<
class Num_T>
1455 "Vec<>::del(int, int): Indexing out of range");
1457 int new_size =
datasize - (i2 - i1 + 1);
1463template<
class Num_T>
1467 "Vec<>::ins(): Index out of range");
1471 copy_vector(index, Temp.
data,
data);
1476template<
class Num_T>
1480 "Vec<>::ins(): Index out of range");
1484 copy_vector(index, Temp.
data,
data);
1489template<
class Num_T>
inline
1497template<
class Num_T>
inline
1507template<
class Num_T>
1510 if (m.
cols() == 1) {
1514 else if (m.
rows() == 1) {
1519 it_error(
"Vec<>::operator=(Mat<Num_T> &): Wrong size of input matrix");
1523template<
class Num_T>
inline
1526 set(std::string(str));
1530template<
class Num_T>
inline
1537template<
class Num_T>
1543 temp(i) = (
data[i] == t);
1547template<
class Num_T>
1553 temp(i) = (
data[i] != t);
1562template<
class Num_T>
1568 temp(i) = (
data[i] < t);
1572template<
class Num_T>
1578 temp(i) = (
data[i] <= t);
1587template<
class Num_T>
1593 temp(i) = (
data[i] > t);
1602template<
class Num_T>
1608 temp(i) = (
data[i] >= t);
1617template<
class Num_T>
1623 if (
data[i] != invector.
data[i])
return false;
1628template<
class Num_T>
1633 if (
data[i] != invector.
data[i])
return true;
1639template<
class Num_T>
1645 for (i = 0; i < sz; i++) {
1656template<
class Num_T>
1659 std::ostringstream buffer;
1660 bool started =
false;
1661 bool finished =
false;
1662 bool brackets =
false;
1672 if (is.eof() || (c ==
'\n')) {
1675 is.setstate(std::ios_base::failbit);
1678 else if (!((c ==
'\n') && !started)) {
1682 else if ((c ==
' ') || (c ==
'\t')) {
1687 else if (c ==
'[') {
1690 is.setstate(std::ios_base::failbit);
1698 else if (c ==
']') {
1699 if (!started || !brackets) {
1701 is.setstate(std::ios_base::failbit);
1707 while (!is.eof() && (((c =
static_cast<char>(is.peek())) ==
' ')
1711 if (!is.eof() && (c ==
'\n')) {
1726 v.
set(buffer.str());
1738template<
class Num_T>
1739void Vec<Num_T>::parse_abc_token(
const std::string &s, Num_T &a, Num_T &b,
1742 std::string::size_type beg = 0;
1743 std::string::size_type end = s.find(
':', 0);
1744 a = parse_token(s.substr(beg, end-beg));
1746 end = s.find(
':', beg);
1747 if (end != std::string::npos) {
1748 b = parse_token(s.substr(beg, end-beg));
1749 c = parse_token(s.substr(end+1, s.size()-end));
1753 c = parse_token(s.substr(beg, end-beg-1));
1757template<
class Num_T>
1758Num_T Vec<Num_T>::parse_token(
const std::string &s)
const
1760 it_error(
"Vec::parse_token(): Only `double' and `int' types are supported");
1766ITPP_EXPORT
double Vec<double>::parse_token(
const std::string &s)
const;
1768ITPP_EXPORT
int Vec<int>::parse_token(
const std::string &s)
const;
1771template<
class Num_T>
1772std::vector<std::string> Vec<Num_T>::tokenize(
const std::string &str_in,
1773 bool &abc_format)
const
1775 std::vector<std::string> vs;
1781 bool lparen =
false;
1783 for (std::string::size_type i = 0; i < str_in.size(); ++i) {
1786 case ' ':
case '\t':
1812 else if (lparen && comma) {
1816 if ((c !=
'-') && (c !=
'+'))
1839ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT
Vec<double>;
1840ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT
Vec<int>;
1843ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT
Vec<bin>;
1847ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator+(
const vec &v1,
const vec &v2);
1848ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator+(
const cvec &v1,
const cvec &v2);
1849ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator+(
const ivec &v1,
const ivec &v2);
1850ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator+(
const svec &v1,
const svec &v2);
1851ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator+(
const bvec &v1,
const bvec &v2);
1853ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator+(
const vec &v1,
double t);
1854ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator+(
const cvec &v1, std::complex<double> t);
1855ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator+(
const ivec &v1,
int t);
1856ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator+(
const svec &v1,
short t);
1857ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator+(
const bvec &v1,
bin t);
1859ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator+(
double t,
const vec &v1);
1860ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator+(std::complex<double> t,
const cvec &v1);
1861ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator+(
int t,
const ivec &v1);
1862ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator+(
short t,
const svec &v1);
1863ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator+(
bin t,
const bvec &v1);
1867ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator-(
const vec &v1,
const vec &v2);
1868ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator-(
const cvec &v1,
const cvec &v2);
1869ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator-(
const ivec &v1,
const ivec &v2);
1870ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator-(
const svec &v1,
const svec &v2);
1871ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator-(
const bvec &v1,
const bvec &v2);
1873ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator-(
const vec &v,
double t);
1874ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator-(
const cvec &v, std::complex<double> t);
1875ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator-(
const ivec &v,
int t);
1876ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator-(
const svec &v,
short t);
1877ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator-(
const bvec &v,
bin t);
1879ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator-(
double t,
const vec &v);
1880ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator-(std::complex<double> t,
const cvec &v);
1881ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator-(
int t,
const ivec &v);
1882ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator-(
short t,
const svec &v);
1883ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator-(
bin t,
const bvec &v);
1887ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator-(
const vec &v);
1888ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator-(
const cvec &v);
1889ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator-(
const ivec &v);
1890ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator-(
const svec &v);
1891ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator-(
const bvec &v);
1894ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::complex<double>
dot(
const cvec &v1,
const cvec &v2);
1895ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
int dot(
const ivec &v1,
const ivec &v2);
1896ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
short dot(
const svec &v1,
const svec &v2);
1897ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
bin dot(
const bvec &v1,
const bvec &v2);
1899ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
double operator*(
const vec &v1,
const vec &v2);
1900ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::complex<double>
operator*(
const cvec &v1,
const cvec &v2);
1901ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
int operator*(
const ivec &v1,
const ivec &v2);
1902ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
short operator*(
const svec &v1,
const svec &v2);
1903ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
bin operator*(
const bvec &v1,
const bvec &v2);
1905ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
outer_product(
const ivec &v1,
const ivec &v2,
1907ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
outer_product(
const svec &v1,
const svec &v2,
1909ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
bmat outer_product(
const bvec &v1,
const bvec &v2,
1912ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator*(
const vec &v,
double t);
1913ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator*(
const cvec &v, std::complex<double> t);
1914ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator*(
const ivec &v,
int t);
1915ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator*(
const svec &v,
short t);
1916ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator*(
const bvec &v,
bin t);
1918ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator*(
double t,
const vec &v);
1919ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator*(std::complex<double> t,
const cvec &v);
1920ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator*(
int t,
const ivec &v);
1921ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator*(
short t,
const svec &v);
1922ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator*(
bin t,
const bvec &v);
1926ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
elem_mult(
const vec &a,
const vec &b);
1927ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
elem_mult(
const cvec &a,
const cvec &b);
1928ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
elem_mult(
const ivec &a,
const ivec &b);
1929ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
elem_mult(
const svec &a,
const svec &b);
1930ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
elem_mult(
const bvec &a,
const bvec &b);
1932ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const vec &a,
const vec &b, vec &out);
1933ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const cvec &a,
const cvec &b, cvec &out);
1934ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const ivec &a,
const ivec &b, ivec &out);
1935ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const svec &a,
const svec &b, svec &out);
1936ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const bvec &a,
const bvec &b, bvec &out);
1938ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
elem_mult(
const vec &a,
const vec &b,
const vec &c);
1939ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
elem_mult(
const cvec &a,
const cvec &b,
const cvec &c);
1940ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
elem_mult(
const ivec &a,
const ivec &b,
const ivec &c);
1941ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
elem_mult(
const svec &a,
const svec &b,
const svec &c);
1942ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
elem_mult(
const bvec &a,
const bvec &b,
const bvec &c);
1944ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const vec &a,
const vec &b,
1945 const vec &c, vec &out);
1946ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const cvec &a,
const cvec &b,
1947 const cvec &c, cvec &out);
1948ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const ivec &a,
const ivec &b,
1949 const ivec &c, ivec &out);
1950ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const svec &a,
const svec &b,
1951 const svec &c, svec &out);
1952ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const bvec &a,
const bvec &b,
1953 const bvec &c, bvec &out);
1955ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
elem_mult(
const vec &a,
const vec &b,
1956 const vec &c,
const vec &d);
1957ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
elem_mult(
const cvec &a,
const cvec &b,
1958 const cvec &c,
const cvec &d);
1959ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
elem_mult(
const ivec &a,
const ivec &b,
1960 const ivec &c,
const ivec &d);
1961ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
elem_mult(
const svec &a,
const svec &b,
1962 const svec &c,
const svec &d);
1963ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
elem_mult(
const bvec &a,
const bvec &b,
1964 const bvec &c,
const bvec &d);
1966ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const vec &a,
const vec &b,
const vec &c,
1967 const vec &d, vec &out);
1968ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const cvec &a,
const cvec &b,
1969 const cvec &c,
const cvec &d, cvec &out);
1970ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const ivec &a,
const ivec &b,
1971 const ivec &c,
const ivec &d, ivec &out);
1972ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const svec &a,
const svec &b,
1973 const svec &c,
const svec &d, svec &out);
1974ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const bvec &a,
const bvec &b,
1975 const bvec &c,
const bvec &d, bvec &out);
1979ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_inplace(
const vec &a, vec &b);
1980ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_inplace(
const cvec &a, cvec &b);
1981ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_inplace(
const ivec &a, ivec &b);
1982ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_inplace(
const svec &a, svec &b);
1983ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_inplace(
const bvec &a, bvec &b);
1987ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
double elem_mult_sum(
const vec &a,
const vec &b);
1988ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::complex<double>
elem_mult_sum(
const cvec &a,
1990ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
int elem_mult_sum(
const ivec &a,
const ivec &b);
1991ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
short elem_mult_sum(
const svec &a,
const svec &b);
1992ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
bin elem_mult_sum(
const bvec &a,
const bvec &b);
1996ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator/(
const vec &v,
double t);
1997ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator/(
const cvec &v, std::complex<double> t);
1998ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator/(
const ivec &v,
int t);
1999ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator/(
const svec &v,
short t);
2000ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator/(
const bvec &v,
bin t);
2002ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
operator/(
double t,
const vec &v);
2003ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
operator/(std::complex<double> t,
const cvec &v);
2004ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator/(
int t,
const ivec &v);
2005ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator/(
short t,
const svec &v);
2006ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator/(
bin t,
const bvec &v);
2010ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
elem_div(
const vec &a,
const vec &b);
2011ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
elem_div(
const cvec &a,
const cvec &b);
2012ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
elem_div(
const ivec &a,
const ivec &b);
2013ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
elem_div(
const svec &a,
const svec &b);
2014ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
elem_div(
const bvec &a,
const bvec &b);
2016ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
elem_div(
double t,
const vec &v);
2017ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
elem_div(std::complex<double> t,
const cvec &v);
2018ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
elem_div(
int t,
const ivec &v);
2019ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
elem_div(
short t,
const svec &v);
2020ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
elem_div(
bin t,
const bvec &v);
2022ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_div_out(
const vec &a,
const vec &b, vec &out);
2023ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_div_out(
const cvec &a,
const cvec &b, cvec &out);
2024ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_div_out(
const ivec &a,
const ivec &b, ivec &out);
2025ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_div_out(
const svec &a,
const svec &b, svec &out);
2026ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_div_out(
const bvec &a,
const bvec &b, bvec &out);
2030ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
double elem_div_sum(
const vec &a,
const vec &b);
2031ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::complex<double>
elem_div_sum(
const cvec &a,
2033ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
int elem_div_sum(
const ivec &a,
const ivec &b);
2034ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
short elem_div_sum(
const svec &a,
const svec &b);
2035ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
bin elem_div_sum(
const bvec &a,
const bvec &b);
2039ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
concat(
const vec &v,
double a);
2040ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
concat(
const cvec &v, std::complex<double> a);
2041ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
concat(
const ivec &v,
int a);
2042ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
concat(
const svec &v,
short a);
2043ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
concat(
const bvec &v,
bin a);
2045ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
concat(
double a,
const vec &v);
2046ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
concat(std::complex<double> a,
const cvec &v);
2047ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
concat(
int a,
const ivec &v);
2048ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
concat(
short a,
const svec &v);
2049ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
concat(
bin a,
const bvec &v);
2051ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
concat(
const vec &v1,
const vec &v2);
2052ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
concat(
const cvec &v1,
const cvec &v2);
2053ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
concat(
const ivec &v1,
const ivec &v2);
2054ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
concat(
const svec &v1,
const svec &v2);
2055ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
concat(
const bvec &v1,
const bvec &v2);
2057ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
concat(
const vec &v1,
const vec &v2,
const vec &v3);
2058ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
concat(
const cvec &v1,
const cvec &v2,
const cvec &v3);
2059ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
concat(
const ivec &v1,
const ivec &v2,
const ivec &v3);
2060ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
concat(
const svec &v1,
const svec &v2,
const svec &v3);
2061ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
concat(
const bvec &v1,
const bvec &v2,
const bvec &v3);
2063ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
concat(
const vec &v1,
const vec &v2,
2064 const vec &v3,
const vec &v4);
2065ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
concat(
const cvec &v1,
const cvec &v2,
2066 const cvec &v3,
const cvec &v4);
2067ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
concat(
const ivec &v1,
const ivec &v2,
2068 const ivec &v3,
const ivec &v4);
2069ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
concat(
const svec &v1,
const svec &v2,
2070 const svec &v3,
const svec &v4);
2071ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
concat(
const bvec &v1,
const bvec &v2,
2072 const bvec &v3,
const bvec &v4);
2074ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
concat(
const vec &v1,
const vec &v2,
const vec &v3,
2075 const vec &v4,
const vec &v5);
2076ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
concat(
const cvec &v1,
const cvec &v2,
const cvec &v3,
2077 const cvec &v4,
const cvec &v5);
2078ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
concat(
const ivec &v1,
const ivec &v2,
const ivec &v3,
2079 const ivec &v4,
const ivec &v5);
2080ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
concat(
const svec &v1,
const svec &v2,
const svec &v3,
2081 const svec &v4,
const svec &v5);
2082ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
concat(
const bvec &v1,
const bvec &v2,
const bvec &v3,
2083 const bvec &v4,
const bvec &v5);
2087ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream& os,
const vec &vect);
2088ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream& os,
const cvec &vect);
2089ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream& os,
const svec &vect);
2090ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream& os,
const ivec &vect);
2091ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream& os,
const bvec &vect);
2092ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream& is, vec &vect);
2093ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream& is, cvec &vect);
2094ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream& is, svec &vect);
2095ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream& is, ivec &vect);
2096ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream& is, bvec &vect);
Base class for class factories.
Matrix Class (Templated).
int rows() const
The number of rows.
int cols() const
The number of columns.
Num_T * _data()
Access of the internal data structure (not recommended to use).
Vector Class (Templated).
Vec< double > vec
Definition of double vector type.
Vec< Num_T > & operator=(const char *str)
Assign vector the values in the string str.
Vec< Num_T > get(const Vec< int > &indexlist) const
Get the elements given by the list of indices indexlist.
Vec< Num_T > & operator+=(Num_T t)
Addition of scalar.
Vec< Num_T > & operator=(Num_T t)
Assign all elements in vector to t.
Mat< Num_T > H() const
Hermitian matrix transpose. Converts to a matrix with the conjugate of the vector in the first row.
friend Vec< double > operator-(const Vec< double > &v1, const Vec< double > &v2)
Vec< bin > operator<(double t) const
Num_T & _elem(int i)
Index operator without boundary check. Not recommended for use.
void shift_left(Num_T t, int n=1)
Shift out the n left elements and at the same time shift in the element t at last position n times.
friend Vec< double > concat(const Vec< double > &v, double t)
friend Vec< double > operator*(const Vec< double > &v, double t)
Vec< Num_T > & operator+=(const Vec< Num_T > &v)
Addition of vector.
Vec< Num_T > & operator=(const std::string &str)
Assign vector the values in the string str.
Vec< Num_T > & operator/=(Num_T t)
Elementwise division.
void del(int i)
Delete element number i.
void set(const char *str)
Set the vector equal to the values in the str string.
void ins(int i, Num_T t)
Insert element t before element with index i (0 <= i <= datasize).
void ins(int i, const Vec< Num_T > &v)
Insert vector v before element with index i (0 <= i <= datasize).
Num_T value_type
The type of the vector values.
void shift_right(Num_T t, int n=1)
Shift in element t at position 0 n times.
const Num_T & _elem(int i) const
Index operator without boundary check. Not recommended for use.
Vec< bin > operator>(Num_T t) const
Elementwise greater than the scalar t.
Vec< bin > operator==(Num_T t) const
Elementwise equal to the scalar t.
Mat< Num_T > transpose() const
Matrix transpose. Converts to a matrix with the vector in the first row.
void free()
Free the storage space allocated by the vector.
const Num_T * _data() const
Get the pointer to the internal structure. Not recommended for use.
friend double elem_div_sum(const Vec< double > &a, const Vec< double > &b)
Vec< bin > operator>=(Num_T t) const
Elementwise greater than and equal to the scalar t.
friend Vec< double > operator+(const Vec< double > &v1, const Vec< double > &v2)
void shift_left(const Vec< Num_T > &v)
Shift in vector v at last positions.
friend void elem_div_out(const Vec< double > &v1, const Vec< double > &v2, Vec< double > &out)
friend Vec< double > operator/(const Vec< double > &v, double t)
Vec< Num_T > get(const Vec< bin > &binlist) const
Get the elements with indexes where binlist is 1.
Vec< Num_T > & operator*=(Num_T t)
Multiply with a scalar.
Vec(int size, const Factory &f=DEFAULT_FACTORY)
Constructor with size parameter. An element factory f can be specified.
Vec< Num_T > operator()(const Vec< bin > &binlist) const
Sub-vector with elements with indexes where binlist is 1.
Num_T * _data()
Get the pointer to the internal structure. Not recommended for use.
friend void elem_mult_out(const Vec< double > &a, const Vec< double > &b, Vec< double > &out)
bool operator==(const Vec< Num_T > &v) const
Compare with vector v. Return false if sizes or values differ.
Vec< Num_T > & operator=(const Mat< Num_T > &m)
Assign vector equal to the 1-dimensional matrix m.
void del(int i1, int i2)
Delete elements from i1 to i2.
void replace_mid(int i, const Vec< Num_T > &v)
An alias function of set_subvector(i, &v).
void clear()
Set the vector to the all zero vector.
Vec< bin > operator<=(double t) const
Vec< Num_T > operator()(const Vec< int > &indexlist) const
Sub-vector with elements given by the list of indices indexlist.
Num_T & operator[](int i)
C-style index operator. First element is 0.
friend Vec< double > elem_mult(const Vec< double > &a, const Vec< double > &b)
void set_subvector(int i, const Vec< Num_T > &v)
Set subvector to elements of vector v starting from element i.
bool operator!=(const Vec< Num_T > &v) const
Compare with vector v. Return true if sizes or values differ.
Vec< Num_T > & operator=(const Vec< Num_T > &v)
Assign vector the value and length of v.
Vec< Num_T > mid(int start, int nr) const
Get the middle part of vector from start including nr elements.
void zeros()
Set the vector to the all zero vector.
void shift_right(const Vec< Num_T > &v)
Shift in vector v at position 0.
void ones()
Set the vector to the all one vector.
const Num_T & get(int i) const
Accessor-style method. First element is 0.
Vec< Num_T > split(int pos)
Split the vector into two parts at element pos.
void set_size(int size, bool copy=false)
Set length of vector. if copy = true then keeping the old values.
Vec(const Vec< Num_T > &v)
Copy constructor.
friend double elem_mult_sum(const Vec< double > &a, const Vec< double > &b)
Vec(const Vec< Num_T > &v, const Factory &f)
Copy constructor, which takes an element factory f as an additional argument.
friend void elem_mult_inplace(const Vec< double > &a, Vec< double > &b)
Vec(const char *str, const Factory &f=DEFAULT_FACTORY)
Constructor taking a char string as input. An element factory f can be specified.
std::ostream & operator<<(std::ostream &os, const Vec< Num_T > &v)
Stream output of vector.
Vec< Num_T > & operator-=(const Vec< Num_T > &v)
Subtraction of vector.
Vec< Num_T > right(int nr) const
Get the right nr elements from the vector.
void set(const std::string &str)
Set the vector equal to the values in the str string.
const Num_T & operator[](int i) const
C-style index operator. First element is 0.
Vec< Num_T > get(int i1, int i2) const
Get the elements from i1 to i2. Index -1 indicates the last element.
const Num_T & operator()(int i) const
Index operator. First element is 0.
void alloc(int size)
Allocate storage for a vector of length size.
void set_length(int size, bool copy=false)
Set length of vector. if copy = true then keeping the old values.
std::istream & operator>>(std::istream &is, Vec< Num_T > &v)
Stream input of vector.
Mat< Num_T > T() const
Matrix transpose. Converts to a matrix with the vector in the first row.
Vec< Num_T > & operator/=(const Vec< Num_T > &v)
Elementwise division.
Vec(const Factory &f=DEFAULT_FACTORY)
Default constructor. An element factory f can be specified.
void set_subvector(int i1, int i2, Num_T t)
Set subvector defined by indices i1 and i2 to t.
void set(int i, Num_T t)
Modifier-style method. First element is 0.
Vec(const Num_T *c_array, int size, const Factory &f=DEFAULT_FACTORY)
Constructor taking a C-array as input. Copies all data. An element factory f can be specified.
Num_T & operator()(int i)
Index operator. First element is 0.
Vec< std::complex< double > > cvec
int length() const
The size of the vector.
Vec< Num_T > & operator-=(Num_T t)
Subtraction of scalar.
Vec< bin > operator!=(Num_T t) const
Elementwise not-equal to the scalar t.
Vec(const std::string &str, const Factory &f=DEFAULT_FACTORY)
Constructor taking a string as input. An element factory f can be specified.
Vec< Num_T > operator()(int i1, int i2) const
Sub-vector with elements from i1 to i2. Index -1 indicates the last element.
Mat< Num_T > hermitian_transpose() const
Hermitian matrix transpose. Converts to a matrix with the conjugate of the vector in the first row.
friend Vec< double > elem_div(const Vec< double > &v1, const Vec< double > &v2)
void set_subvector(int i1, int i2, const Vec< Num_T > &v)
This function is deprecated. Please use set_subvector(i, v) instead.
Vec< Num_T > left(int nr) const
Get the left nr elements from the vector.
Binary arithmetic (boolean) class.
bin()
Default constructor.
Vector copy functions for internal use.
Base class for class factories and memory allocation functions.
#define it_error(s)
Abort unconditionally.
#define it_warning(s)
Display a warning message.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
void hermitian_transpose(const Mat< T > &m, Mat< T > &out)
T min(const Vec< T > &in)
Minimum value of vector.
Error handling functions - header file.
Matrix Class Definitions.
Mat< bin > bmat
bin matrix
Miscellaneous functions - header file.
void elem_mult_inplace(const Mat< Num_T > &m1, Mat< Num_T > &m2)
In-place element wise multiplication of two matrices. Fast version of B = elem_mult(A,...
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
Mat< Num_T > operator-(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Subtraction of two matrices.
const Array< T > concat(const Array< T > &a, const T &e)
Append element e to the end of the Array a.
GF2mat operator*(const GF2mat &X, const GF2mat &Y)
GF(2) matrix multiplication.
Mat< Num_T > operator/(const Mat< Num_T > &m, Num_T t)
Element-wise division by a scalar.
Num_T dot(const Vec< Num_T > &v1, const Vec< Num_T > &v2)
Inner (dot) product of two vectors v1 and v2.
void destroy_elements(T *&ptr, int n)
Destroy an array of Array, Vec or Mat elements.
void elem_div_out(const Mat< Num_T > &m1, const Mat< Num_T > &m2, Mat< Num_T > &out)
Element wise division of two matrices, storing the result in matrix out.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
Mat< Num_T > elem_div(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise division of two matrices.
Num_T elem_div_sum(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise division of two matrices, followed by summation of the resultant elements....
GF2mat operator+(const GF2mat &X, const GF2mat &Y)
GF(2) matrix addition.
const Factory DEFAULT_FACTORY
Default (dummy) factory.
Mat< Num_T > elem_mult(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise multiplication of two matrices.
Num_T elem_mult_sum(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise multiplication of two matrices, followed by summation of the resultant elements....
void elem_mult_out(const Mat< Num_T > &m1, const Mat< Num_T > &m2, Mat< Num_T > &out)
Element wise multiplication of two matrices, storing the result in matrix out.
void create_elements(T *&ptr, int n, const Factory &)
Create an n-length array of T to be used as Array, Vec or Mat elements.
Mat< Num_T > outer_product(const Vec< Num_T > &v1, const Vec< Num_T > &v2, bool hermitian=false)
Outer product of two vectors v1 and v2.