26 #ifndef _CXSC_SCVECTOR_HPP_INCLUDED 27 #define _CXSC_SCVECTOR_HPP_INCLUDED 29 #include <complex.hpp> 30 #include <cvector.hpp> 33 #include <srvector.hpp> 34 #include <sparsecdot.hpp> 35 #include <sparsevector.hpp> 48 class scivector_slice;
50 class scimatrix_slice;
61 std::vector<complex> x;
72 explicit scvector(
const int s) : lb(1), ub(s), n(s) {
73 p.reserve((
int)(s*0.1));
74 x.reserve((
int)(s*0.1));
78 scvector(
const int s,
const int b) : lb(1), ub(s), n(s) {
85 for(
int i=lb ; i<=ub ; i++) {
95 for(
int i=lb ; i<=ub ; i++) {
106 for(
int i=0 ; i<nnz ; i++) {
108 p.push_back(index[i+
Lb(index)]);
117 for(
int i=0 ; i<nnz ; i++) {
119 p.push_back(index[i]);
128 for(
int i=0 ; i<v.
get_nnz() ; i++)
152 std::vector<complex>&
values() {
170 const std::vector<complex>&
values()
const {
184 return (
double)x.size()/n;
189 for(
int i=0 ; i<
get_nnz() ; i++) {
191 x.erase(x.begin()+i);
192 p.erase(p.begin()+i);
203 for(
unsigned int i=0 ; i<v.x.size() ; i++)
210 return sp_vs_assign<scvector,real,complex>(*
this,v);
215 return sp_vs_assign<scvector,complex,complex>(*
this,v);
220 return spf_vv_assign<scvector,rvector,complex>(*
this,v);
225 return spf_vv_assign<scvector,cvector,complex>(*
this,v);
230 return spf_vv_assign<scvector,rvector_slice,complex>(*
this,v);
235 return spf_vv_assign<scvector,cvector_slice,complex>(*
this,v);
249 #if(CXSC_INDEX_CHECK) 250 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC(
"scvector::operator[](const int)"));
254 for(k=0 ; k<
get_nnz() && p[k]<=i-lb ; k++) {
259 p.insert(p.begin() + k, i-lb);
260 x.insert(x.begin() + k,
complex(0.0));
271 #if(CXSC_INDEX_CHECK) 272 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC(
"scvector::operator[](const int)"));
283 #if(CXSC_INDEX_CHECK) 284 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC(
"scvector::operator()(const int)"));
288 for(
int k=0 ; k<
get_nnz() && p[k]<=i-lb ; k++) {
304 std::map<int,complex> work;
305 for(
int i=0 ; i<
get_nnz() ; i++)
306 work.insert(std::make_pair(pinv[
Lb(pinv)+p[i]], x[i]));
308 for(std::map<int,complex>::iterator it=work.begin() ; it!=work.end() ; it++) {
309 v.p.push_back(it->first);
310 v.x.push_back(it->second);
335 return sp_vs_multassign(*
this,s);
340 return sp_vs_multassign(*
this,s);
345 return sp_vs_divassign(*
this,s);
350 return sp_vs_divassign(*
this,s);
355 return spf_vv_addassign(*
this,v);
360 return spf_vv_addassign(*
this,v);
365 return spf_vv_addassign(*
this,v);
370 return spf_vv_addassign(*
this,v);
375 return spsp_vv_addassign(*
this,v);
380 return spsp_vv_addassign(*
this,v);
386 return spf_vv_subassign(*
this,v);
391 return spf_vv_subassign(*
this,v);
396 return spf_vv_subassign(*
this,v);
401 return spf_vv_subassign(*
this,v);
406 return spsp_vv_subassign(*
this,v);
411 return spsp_vv_subassign(*
this,v);
447 #include "vector_friend_declarations.inl" 455 for(
int i=0 ; i<v.n ; i++)
457 for(
int i=0 ; i<v.
get_nnz() ; i++)
458 dat[v.p[i]] = v.x[i];
466 for(
int i=0 ; i<v.n ; i++)
468 for(
int i=0 ; i<v.
get_nnz() ; i++)
469 dat[v.p[i]] = v.x[i];
473 return fsp_vv_assign<cvector,scvector,complex>(*
this,v);
477 return fsl_vv_assign<cvector,scvector_slice,complex>(*
this,v);
481 return fsp_vv_assign<cvector,srvector,complex>(*
this,v);
485 return fsl_vv_assign<cvector,srvector_slice,complex>(*
this,v);
494 v.ub = v.lb + v.n - 1;
503 v.lb = v.ub - v.n + 1;
522 for(
int i=0 ; i<v.
get_nnz() ; i++)
523 res.x[i] = Re(v.x[i]);
533 for(
int i=0 ; i<v.
get_nnz() ; i++)
534 res.x[i] = Im(v.x[i]);
542 const std::vector<complex>& xv = v.
values();
544 std::vector<real>& x = ret.
values();
546 for(
unsigned int i=0 ; i<xv.size() ; i++) {
547 x.push_back(
abs(xv[i]));
583 return sp_v_negative(v);
594 return spf_vv_mult<scvector,cvector,complex,sparse_cdot>(v1,v2);
605 return spf_vv_mult<scvector,rvector,complex,sparse_cdot>(v1,v2);
616 return spf_vv_mult<srvector,cvector,complex,sparse_cdot>(v1,v2);
627 return fsp_vv_mult<rvector,scvector,complex,sparse_cdot>(v1,v2);
638 return fsp_vv_mult<cvector,srvector,complex,sparse_cdot>(v1,v2);
649 return fsp_vv_mult<cvector,scvector,complex,sparse_cdot>(v1,v2);
660 return spf_vv_mult<scvector,rvector_slice,complex,sparse_cdot>(v1,v2);
671 return spf_vv_mult<scvector,cvector_slice,complex,sparse_cdot>(v1,v2);
682 return spf_vv_mult<srvector,cvector_slice,complex,sparse_cdot>(v1,v2);
693 return fsp_vv_mult<cvector_slice,srvector,complex,sparse_cdot>(v1,v2);
704 return fsp_vv_mult<cvector_slice,scvector,complex,sparse_cdot>(v1,v2);
715 return fsp_vv_mult<rvector_slice,scvector,complex,sparse_cdot>(v1,v2);
726 return spsp_vv_mult<scvector,srvector,complex,sparse_cdot>(v1,v2);
737 return spsp_vv_mult<srvector,scvector,complex,sparse_cdot>(v1,v2);
748 return spsp_vv_mult<scvector,scvector,complex,sparse_cdot>(v1,v2);
753 return sp_vs_mult<scvector,real,scvector>(v,s);
758 return sp_vs_mult<scvector,complex,scvector>(v,s);
763 return sp_vs_mult<srvector,complex,scvector>(v,s);
768 return sp_vs_div<scvector,real,scvector>(v,s);
773 return sp_vs_div<scvector,complex,scvector>(v,s);
778 return sp_vs_div<srvector,complex,scvector>(v,s);
783 return sp_sv_mult<real,scvector,scvector>(s,v);
788 return sp_sv_mult<complex,scvector,scvector>(s,v);
793 return sp_sv_mult<complex,srvector,scvector>(s,v);
798 return fsp_vv_add<cvector,srvector,cvector>(v1,v2);
803 return fsp_vv_add<rvector,scvector,cvector>(v1,v2);
808 return fsp_vv_add<cvector,scvector,cvector>(v1,v2);
813 return spf_vv_add<scvector,rvector,cvector>(v1,v2);
818 return spf_vv_add<srvector,cvector,cvector>(v1,v2);
823 return spf_vv_add<scvector,cvector,cvector>(v1,v2);
828 return fsp_vv_add<cvector_slice,srvector,cvector>(v1,v2);
833 return fsp_vv_add<rvector_slice,scvector,cvector>(v1,v2);
838 return fsp_vv_add<cvector_slice,scvector,cvector>(v1,v2);
843 return spf_vv_add<scvector,rvector_slice,cvector>(v1,v2);
848 return spf_vv_add<srvector,cvector_slice,cvector>(v1,v2);
853 return spf_vv_add<scvector,cvector_slice,cvector>(v1,v2);
858 return spsp_vv_add<scvector,srvector,scvector,complex>(v1,v2);
863 return spsp_vv_add<srvector,scvector,scvector,complex>(v1,v2);
868 return spsp_vv_add<scvector,scvector,scvector,complex>(v1,v2);
873 return fsp_vv_sub<cvector,srvector,cvector>(v1,v2);
878 return fsp_vv_sub<rvector,scvector,cvector>(v1,v2);
883 return fsp_vv_sub<cvector,scvector,cvector>(v1,v2);
888 return spf_vv_sub<scvector,rvector,cvector>(v1,v2);
893 return spf_vv_sub<srvector,cvector,cvector>(v1,v2);
898 return spf_vv_sub<scvector,cvector,cvector>(v1,v2);
903 return fsp_vv_sub<cvector_slice,srvector,cvector>(v1,v2);
908 return fsp_vv_sub<rvector_slice,scvector,cvector>(v1,v2);
913 return fsp_vv_sub<cvector_slice,scvector,cvector>(v1,v2);
918 return spf_vv_sub<scvector,rvector_slice,cvector>(v1,v2);
923 return spf_vv_sub<srvector,cvector_slice,cvector>(v1,v2);
928 return spf_vv_sub<scvector,cvector_slice,cvector>(v1,v2);
933 return spsp_vv_sub<scvector,srvector,scvector,complex>(v1,v2);
938 return spsp_vv_sub<srvector,scvector,scvector,complex>(v1,v2);
943 return spsp_vv_sub<scvector,scvector,scvector,complex>(v1,v2);
946 inline cvector& cvector::operator+=(
const srvector& v2) {
947 return fsp_vv_addassign(*
this,v2);
950 inline cvector& cvector::operator+=(
const scvector& v2) {
951 return fsp_vv_addassign(*
this,v2);
955 return fsp_vv_addassign(*
this,v2);
959 return fsp_vv_addassign(*
this,v2);
962 inline cvector& cvector::operator-=(
const srvector& v2) {
963 return fsp_vv_subassign(*
this,v2);
966 inline cvector& cvector::operator-=(
const scvector& v2) {
967 return fsp_vv_subassign(*
this,v2);
970 inline cvector_slice& cvector_slice::operator-=(
const srvector& v2) {
971 return fsp_vv_subassign(*
this,v2);
974 inline cvector_slice& cvector_slice::operator-=(
const scvector& v2) {
975 return fsp_vv_subassign(*
this,v2);
983 return spsp_vv_comp(v1,v2);
991 return spsp_vv_comp(v1,v2);
999 return spsp_vv_comp(v1,v2);
1007 return spf_vv_comp(v1,v2);
1015 return spf_vv_comp(v1,v2);
1023 return spf_vv_comp(v1,v2);
1031 return fsp_vv_comp(v1,v2);
1039 return fsp_vv_comp(v1,v2);
1047 return fsp_vv_comp(v1,v2);
1055 return spf_vv_comp(v1,v2);
1063 return spf_vv_comp(v1,v2);
1071 return spf_vv_comp(v1,v2);
1079 return fsp_vv_comp(v1,v2);
1087 return fsp_vv_comp(v1,v2);
1095 return fsp_vv_comp(v1,v2);
1103 return !spsp_vv_comp(v1,v2);
1111 return !spsp_vv_comp(v1,v2);
1119 return !spsp_vv_comp(v1,v2);
1127 return !spf_vv_comp(v1,v2);
1135 return !spf_vv_comp(v1,v2);
1143 return !spf_vv_comp(v1,v2);
1151 return !fsp_vv_comp(v1,v2);
1159 return !fsp_vv_comp(v1,v2);
1167 return !fsp_vv_comp(v1,v2);
1175 return !spf_vv_comp(v1,v2);
1183 return !spf_vv_comp(v1,v2);
1191 return !spf_vv_comp(v1,v2);
1199 return !fsp_vv_comp(v1,v2);
1207 return !fsp_vv_comp(v1,v2);
1215 return !fsp_vv_comp(v1,v2);
1224 inline std::ostream& operator<<(std::ostream& os,
const scvector& v) {
1225 return sp_v_output<scvector,complex>(os,v);
1234 inline std::istream& operator>>(std::istream& is,
scvector& v) {
1235 return sp_v_input<scvector,complex>(is,v);
1247 std::vector<int>& p;
1248 std::vector<complex>& x;
1265 for(i=0 ; i<v.
get_nnz() && p[i]<lb-v.lb ; i++);
1269 for(i=start ; i<v.
get_nnz() && p[i]<=ub-v.lb ; i++);
1286 return (
double)nnz/n;
1295 #if(CXSC_INDEX_CHECK) 1296 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC(
"scvector_slice::operator[](const int)"));
1300 for(k=start ; k<end+1 && p[k]-start<=i-lb ; k++) {
1301 if(p[k]-offset == i-lb)
1305 p.insert(p.begin() + k, i-lb);
1306 x.insert(x.begin() + k,
complex(0.0));
1318 #if(CXSC_INDEX_CHECK) 1319 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC(
"scvector_slice::operator[](const int)"));
1330 #if(CXSC_INDEX_CHECK) 1331 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC(
"scvector_slice::operator()(const int)"));
1335 for(
int k=start ; k<end && p[k]-start<=i-lb ; k++) {
1336 if(p[k]-start == i-lb)
1345 return sl_vs_assign<scvector_slice,real,complex,std::vector<complex>::iterator>(*
this,v);
1350 return sl_vs_assign<scvector_slice,complex,complex,std::vector<complex>::iterator>(*
this,v);
1355 return slsl_vv_assign<scvector_slice,srvector_slice,complex,std::vector<complex>::iterator>(*
this,v);
1360 return slsl_vv_assign<scvector_slice,scvector_slice,complex,std::vector<complex>::iterator>(*
this,v);
1365 return slsp_vv_assign<scvector_slice,srvector,complex,std::vector<complex>::iterator>(*
this,v);
1370 return slsp_vv_assign<scvector_slice,scvector,complex,std::vector<complex>::iterator>(*
this,v);
1375 return slf_vv_assign<scvector_slice,rvector,complex,std::vector<complex>::iterator>(*
this,v);
1380 return slf_vv_assign<scvector_slice,cvector,complex,std::vector<complex>::iterator>(*
this,v);
1385 return slf_vv_assign<scvector_slice,rvector_slice,complex,std::vector<complex>::iterator>(*
this,v);
1390 return slf_vv_assign<scvector_slice,cvector_slice,complex,std::vector<complex>::iterator>(*
this,v);
1395 return sl_vs_multassign(*
this,s);
1400 return sl_vs_multassign(*
this,s);
1405 return sl_vs_divassign(*
this,s);
1410 return sl_vs_divassign(*
this,s);
1415 return slf_vv_addassign<scvector_slice,rvector,complex>(*
this,v);
1420 return slf_vv_addassign<scvector_slice,cvector,complex>(*
this,v);
1425 return slf_vv_addassign<scvector_slice,rvector_slice,complex>(*
this,v);
1430 return slf_vv_addassign<scvector_slice,cvector_slice,complex>(*
this,v);
1435 return slsp_vv_addassign(*
this,v);
1440 return slsp_vv_addassign(*
this,v);
1445 return slsl_vv_addassign(*
this,v);
1450 return slsl_vv_addassign(*
this,v);
1455 return slf_vv_subassign<scvector_slice,rvector,complex>(*
this,v);
1460 return slf_vv_subassign<scvector_slice,cvector,complex>(*
this,v);
1465 return slf_vv_subassign<scvector_slice,rvector_slice,complex>(*
this,v);
1470 return slf_vv_subassign<scvector_slice,cvector_slice,complex>(*
this,v);
1475 return slsp_vv_subassign(*
this,v);
1480 return slsp_vv_subassign(*
this,v);
1485 return slsl_vv_subassign(*
this,v);
1490 return slsl_vv_subassign(*
this,v);
1510 #include "vector_friend_declarations.inl" 1518 for(
int i=0 ; i<v.n ; i++)
1520 for(
int i=v.start ; i<=v.end ; i++)
1521 dat[v.p[i]] = v.x[i];
1529 for(
int i=0 ; i<v.n ; i++)
1531 for(
int i=v.start ; i<=v.end ; i++)
1532 dat[v.p[i]] = v.x[i];
1559 for(
int i=s.start ; i<=s.end ; i++) {
1560 p.push_back(s.p[i]-s.offset);
1570 for(
int i=s.start ; i<=s.end ; i++) {
1571 p.push_back(s.p[i]-s.offset);
1572 x.push_back(s.x[i]);
1578 return spsl_vv_assign<scvector,srvector_slice,complex>(*
this,v);
1582 return spsl_vv_assign<scvector,scvector_slice,complex>(*
this,v);
1586 #if(CXSC_INDEX_CHECK) 1587 if(i<lb || j>ub) cxscthrow(ELEMENT_NOT_IN_VEC(
"scvector_slice::operator()(const int, const int)"));
1594 return sl_v_negative<scvector_slice,scvector>(v);
1630 return slf_vv_mult<scvector_slice,rvector,complex,sparse_cdot>(v1,v2);
1641 return slf_vv_mult<srvector_slice,cvector,complex,sparse_cdot>(v1,v2);
1652 return slf_vv_mult<scvector_slice,cvector,complex,sparse_cdot>(v1,v2);
1663 return fsl_vv_mult<cvector,srvector_slice,complex,sparse_cdot>(v1,v2);
1674 return fsl_vv_mult<rvector,scvector_slice,complex,sparse_cdot>(v1,v2);
1685 return fsl_vv_mult<cvector,scvector_slice,complex,sparse_cdot>(v1,v2);
1696 return slf_vv_mult<scvector_slice,rvector_slice,complex,sparse_cdot>(v1,v2);
1707 return slf_vv_mult<srvector_slice,cvector_slice,complex,sparse_cdot>(v1,v2);
1718 return slf_vv_mult<scvector_slice,cvector_slice,complex,sparse_cdot>(v1,v2);
1729 return fsl_vv_mult<cvector_slice,srvector_slice,complex,sparse_cdot>(v1,v2);
1740 return fsl_vv_mult<rvector_slice,scvector_slice,complex,sparse_cdot>(v1,v2);
1751 return fsl_vv_mult<cvector_slice,scvector_slice,complex,sparse_cdot>(v1,v2);
1762 return spsl_vv_mult<scvector,srvector_slice,complex,sparse_cdot>(v1,v2);
1773 return spsl_vv_mult<srvector,scvector_slice,complex,sparse_cdot>(v1,v2);
1784 return spsl_vv_mult<scvector,scvector_slice,complex,sparse_cdot>(v1,v2);
1795 return slsp_vv_mult<scvector_slice,srvector,complex,sparse_cdot>(v1,v2);
1806 return slsp_vv_mult<srvector_slice,scvector,complex,sparse_cdot>(v1,v2);
1817 return slsp_vv_mult<scvector_slice,scvector,complex,sparse_cdot>(v1,v2);
1828 return slsl_vv_mult<scvector_slice,srvector_slice,complex,sparse_cdot>(v1,v2);
1839 return slsl_vv_mult<srvector_slice,scvector_slice,complex,sparse_cdot>(v1,v2);
1850 return slsl_vv_mult<scvector_slice,scvector_slice,complex,sparse_cdot>(v1,v2);
1855 return sp_vs_mult<scvector_slice,real,scvector>(v,s);
1860 return sp_vs_mult<scvector_slice,complex,scvector>(v,s);
1865 return sp_vs_mult<srvector_slice,complex,scvector>(v,s);
1870 return sp_vs_div<scvector_slice,real,scvector>(v,s);
1875 return sp_vs_div<scvector_slice,complex,scvector>(v,s);
1880 return sp_vs_div<srvector_slice,complex,scvector>(v,s);
1885 return sp_sv_mult<real,scvector_slice,scvector>(s,v);
1890 return sp_sv_mult<complex,scvector_slice,scvector>(s,v);
1895 return sp_sv_mult<complex,srvector_slice,scvector>(s,v);
1900 return fsl_vv_add<cvector,srvector_slice,cvector>(v1,v2);
1905 return fsl_vv_add<rvector,scvector_slice,cvector>(v1,v2);
1910 return fsl_vv_add<cvector,scvector_slice,cvector>(v1,v2);
1915 return slf_vv_add<scvector_slice,rvector,cvector>(v1,v2);
1920 return slf_vv_add<srvector_slice,cvector,cvector>(v1,v2);
1925 return slf_vv_add<scvector_slice,cvector,cvector>(v1,v2);
1930 return fsl_vv_add<cvector_slice,srvector_slice,cvector>(v1,v2);
1935 return fsl_vv_add<rvector_slice,scvector_slice,cvector>(v1,v2);
1940 return fsl_vv_add<cvector_slice,scvector_slice,cvector>(v1,v2);
1945 return slf_vv_add<scvector_slice,rvector_slice,cvector>(v1,v2);
1950 return slf_vv_add<srvector_slice,cvector_slice,cvector>(v1,v2);
1955 return slf_vv_add<scvector_slice,cvector_slice,cvector>(v1,v2);
1960 return slsl_vv_add<scvector_slice,srvector_slice,scvector,complex>(v1,v2);
1965 return slsl_vv_add<srvector_slice,scvector_slice,scvector,complex>(v1,v2);
1970 return slsl_vv_add<scvector_slice,scvector_slice,scvector,complex>(v1,v2);
1975 return spsl_vv_add<scvector,srvector_slice,scvector,complex>(v1,v2);
1980 return spsl_vv_add<srvector,scvector_slice,scvector,complex>(v1,v2);
1985 return spsl_vv_add<scvector,scvector_slice,scvector,complex>(v1,v2);
1990 return slsp_vv_add<scvector_slice,srvector,scvector,complex>(v1,v2);
1995 return slsp_vv_add<srvector_slice,scvector,scvector,complex>(v1,v2);
2000 return slsp_vv_add<scvector_slice,scvector,scvector,complex>(v1,v2);
2005 return fsl_vv_sub<cvector,srvector_slice,cvector>(v1,v2);
2010 return fsl_vv_sub<rvector,scvector_slice,cvector>(v1,v2);
2015 return fsl_vv_sub<cvector,scvector_slice,cvector>(v1,v2);
2020 return slf_vv_sub<scvector_slice,rvector,cvector>(v1,v2);
2025 return slf_vv_sub<srvector_slice,cvector,cvector>(v1,v2);
2030 return slf_vv_sub<scvector_slice,cvector,cvector>(v1,v2);
2035 return fsl_vv_sub<cvector_slice,srvector_slice,cvector>(v1,v2);
2040 return fsl_vv_sub<rvector_slice,scvector_slice,cvector>(v1,v2);
2045 return fsl_vv_sub<cvector_slice,scvector_slice,cvector>(v1,v2);
2050 return slf_vv_sub<scvector_slice,rvector_slice,cvector>(v1,v2);
2055 return slf_vv_sub<srvector_slice,cvector_slice,cvector>(v1,v2);
2060 return slf_vv_sub<scvector_slice,cvector_slice,cvector>(v1,v2);
2065 return slsl_vv_sub<scvector_slice,srvector_slice,scvector,complex>(v1,v2);
2070 return slsl_vv_sub<srvector_slice,scvector_slice,scvector,complex>(v1,v2);
2075 return slsl_vv_sub<scvector_slice,scvector_slice,scvector,complex>(v1,v2);
2080 return spsl_vv_sub<scvector,srvector_slice,scvector,complex>(v1,v2);
2085 return spsl_vv_sub<srvector,scvector_slice,scvector,complex>(v1,v2);
2090 return spsl_vv_sub<scvector,scvector_slice,scvector,complex>(v1,v2);
2095 return slsp_vv_sub<scvector_slice,srvector,scvector,complex>(v1,v2);
2100 return slsp_vv_sub<srvector_slice,scvector,scvector,complex>(v1,v2);
2105 return slsp_vv_sub<scvector_slice,scvector,scvector,complex>(v1,v2);
2108 inline cvector& cvector::operator+=(
const srvector_slice& v2) {
2109 return fsl_vv_addassign(*
this,v2);
2112 inline cvector& cvector::operator+=(
const scvector_slice& v2) {
2113 return fsl_vv_addassign(*
this,v2);
2117 return fsl_vv_addassign(*
this,v2);
2121 return fsl_vv_addassign(*
this,v2);
2125 return spsl_vv_addassign(*
this,v2);
2129 return spsl_vv_addassign(*
this,v2);
2133 return fsl_vv_subassign(*
this,v2);
2136 inline cvector& cvector::operator-=(
const scvector_slice& v2) {
2137 return fsl_vv_subassign(*
this,v2);
2140 inline cvector_slice& cvector_slice::operator-=(
const srvector_slice& v2) {
2141 return fsl_vv_subassign(*
this,v2);
2144 inline cvector_slice& cvector_slice::operator-=(
const scvector_slice& v2) {
2145 return fsl_vv_subassign(*
this,v2);
2149 return spsl_vv_subassign(*
this,v2);
2153 return spsl_vv_subassign(*
this,v2);
2161 return slsl_vv_comp(v1,v2);
2169 return slsl_vv_comp(v1,v2);
2177 return slsl_vv_comp(v1,v2);
2185 return slsp_vv_comp(v1,v2);
2193 return slsp_vv_comp(v1,v2);
2201 return slsp_vv_comp(v1,v2);
2209 return spsl_vv_comp(v1,v2);
2217 return spsl_vv_comp(v1,v2);
2225 return spsl_vv_comp(v1,v2);
2233 return slf_vv_comp(v1,v2);
2241 return slf_vv_comp(v1,v2);
2249 return slf_vv_comp(v1,v2);
2257 return fsl_vv_comp(v1,v2);
2265 return fsl_vv_comp(v1,v2);
2273 return fsl_vv_comp(v1,v2);
2281 return slf_vv_comp(v1,v2);
2289 return slf_vv_comp(v1,v2);
2297 return slf_vv_comp(v1,v2);
2305 return fsl_vv_comp(v1,v2);
2313 return fsl_vv_comp(v1,v2);
2321 return fsl_vv_comp(v1,v2);
2329 return !slsl_vv_comp(v1,v2);
2337 return !slsl_vv_comp(v1,v2);
2345 return !slsl_vv_comp(v1,v2);
2353 return !slf_vv_comp(v1,v2);
2361 return !slf_vv_comp(v1,v2);
2369 return !slf_vv_comp(v1,v2);
2377 return !fsl_vv_comp(v1,v2);
2385 return !fsl_vv_comp(v1,v2);
2393 return !fsl_vv_comp(v1,v2);
2401 return !slsp_vv_comp(v1,v2);
2409 return !slsp_vv_comp(v1,v2);
2417 return !slsp_vv_comp(v1,v2);
2425 return !spsl_vv_comp(v1,v2);
2433 return !spsl_vv_comp(v1,v2);
2441 return !spsl_vv_comp(v1,v2);
2449 return !slf_vv_comp(v1,v2);
2457 return !slf_vv_comp(v1,v2);
2465 return !slf_vv_comp(v1,v2);
2473 return !fsl_vv_comp(v1,v2);
2481 return !fsl_vv_comp(v1,v2);
2489 return !fsl_vv_comp(v1,v2);
2499 return sl_v_output<scvector_slice,complex>(os,v);
2509 return sl_v_input<scvector_slice,complex>(is,v);
2517 spsp_vv_accu<cdotprecision,scvector,scvector,sparse_cdot>(dot,x,y);
2525 spsp_vv_accu<cdotprecision,scvector,srvector,sparse_cdot>(dot,x,y);
2533 spsp_vv_accu<cdotprecision,srvector,scvector,sparse_cdot>(dot,x,y);
2541 spf_vv_accu<cdotprecision,scvector,cvector,sparse_cdot>(dot,x,y);
2549 spf_vv_accu<cdotprecision,scvector,rvector,sparse_cdot>(dot,x,y);
2557 spf_vv_accu<cdotprecision,srvector,cvector,sparse_cdot>(dot,x,y);
2565 spf_vv_accu<cdotprecision,scvector,cvector_slice,sparse_cdot>(dot,x,y);
2573 spf_vv_accu<cdotprecision,scvector,rvector_slice,sparse_cdot>(dot,x,y);
2581 spf_vv_accu<cdotprecision,srvector,cvector_slice,sparse_cdot>(dot,x,y);
2589 fsp_vv_accu<cdotprecision,cvector,scvector,sparse_cdot>(dot,x,y);
2597 fsp_vv_accu<cdotprecision,cvector,srvector,sparse_cdot>(dot,x,y);
2605 fsp_vv_accu<cdotprecision,rvector,scvector,sparse_cdot>(dot,x,y);
2613 fsp_vv_accu<cdotprecision,cvector_slice,scvector,sparse_cdot>(dot,x,y);
2621 fsp_vv_accu<cdotprecision,cvector_slice,srvector,sparse_cdot>(dot,x,y);
2629 fsp_vv_accu<cdotprecision,rvector_slice,scvector,sparse_cdot>(dot,x,y);
2637 slf_vv_accu<cdotprecision,scvector_slice,cvector,sparse_cdot>(dot,x,y);
2645 slf_vv_accu<cdotprecision,scvector_slice,rvector,sparse_cdot>(dot,x,y);
2653 slf_vv_accu<cdotprecision,srvector_slice,cvector,sparse_cdot>(dot,x,y);
2661 slf_vv_accu<cdotprecision,scvector_slice,cvector_slice,sparse_cdot>(dot,x,y);
2669 slf_vv_accu<cdotprecision,scvector_slice,rvector_slice,sparse_cdot>(dot,x,y);
2677 slf_vv_accu<cdotprecision,srvector_slice,cvector_slice,sparse_cdot>(dot,x,y);
2685 fsl_vv_accu<cdotprecision,cvector,scvector_slice,sparse_cdot>(dot,x,y);
2693 fsl_vv_accu<cdotprecision,cvector,srvector_slice,sparse_cdot>(dot,x,y);
2701 fsl_vv_accu<cdotprecision,rvector,scvector_slice,sparse_cdot>(dot,x,y);
2709 fsl_vv_accu<cdotprecision,cvector_slice,scvector_slice,sparse_cdot>(dot,x,y);
2717 fsl_vv_accu<cdotprecision,cvector_slice,srvector_slice,sparse_cdot>(dot,x,y);
2725 fsl_vv_accu<cdotprecision,rvector_slice,scvector_slice,sparse_cdot>(dot,x,y);
2733 slsl_vv_accu<cdotprecision,scvector_slice,scvector_slice,sparse_cdot>(dot,x,y);
2741 slsl_vv_accu<cdotprecision,scvector_slice,srvector_slice,sparse_cdot>(dot,x,y);
2749 slsl_vv_accu<cdotprecision,srvector_slice,scvector_slice,sparse_cdot>(dot,x,y);
2757 spsl_vv_accu<cdotprecision,scvector,scvector_slice,sparse_cdot>(dot,x,y);
2765 spsl_vv_accu<cdotprecision,scvector,srvector_slice,sparse_cdot>(dot,x,y);
2773 spsl_vv_accu<cdotprecision,srvector,scvector_slice,sparse_cdot>(dot,x,y);
2781 slsp_vv_accu<cdotprecision,scvector_slice,scvector,sparse_cdot>(dot,x,y);
2789 slsp_vv_accu<cdotprecision,scvector_slice,srvector,sparse_cdot>(dot,x,y);
2797 slsp_vv_accu<cdotprecision,srvector_slice,scvector,sparse_cdot>(dot,x,y);
2806 spsp_vv_accuapprox<cdotprecision,scvector,scvector,sparse_cdot>(dot,x,y);
2815 spsp_vv_accuapprox<cdotprecision,scvector,srvector,sparse_cdot>(dot,x,y);
2824 spsp_vv_accuapprox<cdotprecision,srvector,scvector,sparse_cdot>(dot,x,y);
2833 spf_vv_accuapprox<cdotprecision,scvector,cvector,sparse_cdot>(dot,x,y);
2842 spf_vv_accuapprox<cdotprecision,scvector,rvector,sparse_cdot>(dot,x,y);
2851 spf_vv_accuapprox<cdotprecision,srvector,cvector,sparse_cdot>(dot,x,y);
2860 spf_vv_accuapprox<cdotprecision,scvector,cvector_slice,sparse_cdot>(dot,x,y);
2869 spf_vv_accuapprox<cdotprecision,scvector,rvector_slice,sparse_cdot>(dot,x,y);
2878 spf_vv_accuapprox<cdotprecision,srvector,cvector_slice,sparse_cdot>(dot,x,y);
2887 fsp_vv_accuapprox<cdotprecision,cvector,scvector,sparse_cdot>(dot,x,y);
2896 fsp_vv_accuapprox<cdotprecision,cvector,srvector,sparse_cdot>(dot,x,y);
2905 fsp_vv_accuapprox<cdotprecision,rvector,scvector,sparse_cdot>(dot,x,y);
2914 fsp_vv_accuapprox<cdotprecision,cvector_slice,scvector,sparse_cdot>(dot,x,y);
2923 fsp_vv_accuapprox<cdotprecision,cvector_slice,srvector,sparse_cdot>(dot,x,y);
2932 fsp_vv_accuapprox<cdotprecision,rvector_slice,scvector,sparse_cdot>(dot,x,y);
2941 slf_vv_accuapprox<cdotprecision,scvector_slice,cvector,sparse_cdot>(dot,x,y);
2950 slf_vv_accuapprox<cdotprecision,scvector_slice,rvector,sparse_cdot>(dot,x,y);
2959 slf_vv_accuapprox<cdotprecision,srvector_slice,cvector,sparse_cdot>(dot,x,y);
2968 slf_vv_accuapprox<cdotprecision,scvector_slice,cvector_slice,sparse_cdot>(dot,x,y);
2977 slf_vv_accuapprox<cdotprecision,scvector_slice,rvector_slice,sparse_cdot>(dot,x,y);
2986 slf_vv_accuapprox<cdotprecision,srvector_slice,cvector_slice,sparse_cdot>(dot,x,y);
2989 inline void accumulate_approx(cdotprecision& dot,
const cvector& x,
const scvector_slice& y) {
2990 fsl_vv_accuapprox<cdotprecision,cvector,scvector_slice,sparse_cdot>(dot,x,y);
2999 fsl_vv_accuapprox<cdotprecision,cvector,srvector_slice,sparse_cdot>(dot,x,y);
3008 fsl_vv_accuapprox<cdotprecision,rvector,scvector_slice,sparse_cdot>(dot,x,y);
3017 fsl_vv_accuapprox<cdotprecision,cvector_slice,scvector_slice,sparse_cdot>(dot,x,y);
3026 fsl_vv_accuapprox<cdotprecision,cvector_slice,srvector_slice,sparse_cdot>(dot,x,y);
3035 fsl_vv_accuapprox<cdotprecision,rvector_slice,scvector_slice,sparse_cdot>(dot,x,y);
3044 slsl_vv_accuapprox<cdotprecision,scvector_slice,scvector_slice,sparse_cdot>(dot,x,y);
3053 slsl_vv_accuapprox<cdotprecision,scvector_slice,srvector_slice,sparse_cdot>(dot,x,y);
3062 slsl_vv_accuapprox<cdotprecision,srvector_slice,scvector_slice,sparse_cdot>(dot,x,y);
3071 spsl_vv_accuapprox<cdotprecision,scvector,scvector_slice,sparse_cdot>(dot,x,y);
3080 spsl_vv_accuapprox<cdotprecision,scvector,srvector_slice,sparse_cdot>(dot,x,y);
3089 spsl_vv_accuapprox<cdotprecision,srvector,scvector_slice,sparse_cdot>(dot,x,y);
3098 slsp_vv_accuapprox<cdotprecision,scvector_slice,scvector,sparse_cdot>(dot,x,y);
3107 slsp_vv_accuapprox<cdotprecision,scvector_slice,srvector,sparse_cdot>(dot,x,y);
3116 slsp_vv_accuapprox<cdotprecision,srvector_slice,scvector,sparse_cdot>(dot,x,y);
3126 accumulate(tmp,x,y);
3137 accumulate(tmp,x,y);
3148 accumulate(tmp,x,y);
3159 accumulate(tmp,x,y);
3170 accumulate(tmp,x,y);
3181 accumulate(tmp,x,y);
3192 accumulate(tmp,x,y);
3203 accumulate(tmp,x,y);
3214 accumulate(tmp,x,y);
3225 accumulate(tmp,x,y);
3236 accumulate(tmp,x,y);
3247 accumulate(tmp,x,y);
3258 accumulate(tmp,x,y);
3269 accumulate(tmp,x,y);
3280 accumulate(tmp,x,y);
3291 accumulate(tmp,x,y);
3302 accumulate(tmp,x,y);
3313 accumulate(tmp,x,y);
3324 accumulate(tmp,x,y);
3335 accumulate(tmp,x,y);
3346 accumulate(tmp,x,y);
3357 accumulate(tmp,x,y);
3368 accumulate(tmp,x,y);
3379 accumulate(tmp,x,y);
3390 accumulate(tmp,x,y);
3401 accumulate(tmp,x,y);
3412 accumulate(tmp,x,y);
3423 accumulate(tmp,x,y);
3434 accumulate(tmp,x,y);
3445 accumulate(tmp,x,y);
3456 accumulate(tmp,x,y);
3467 accumulate(tmp,x,y);
3478 accumulate(tmp,x,y);
3489 accumulate(tmp,x,y);
3500 accumulate(tmp,x,y);
3511 accumulate(tmp,x,y);
3517 #include "sparsevector.inl" friend srvector Im(const scvector_slice &)
Returns the imaginary part of the complex vector slice.
scvector & operator-=(const cvector_slice &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector.
scvector & operator=(const rvector_slice &v)
Assign the dense vector slice v to a sparse vector. Only the non zero elements of v are used.
int get_nnz() const
Returns the number of non zero elements of this vector slice (note that this includes explicitly stor...
scvector operator()(const intmatrix &P)
Returns a vector whose elemnts are rearranged according to a given permutation matrix.
scvector_slice & operator=(const real &v)
Assigns v to all elements of the vector slice.
scvector & operator-=(const srvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector.
complex operator[](const int i) const
Returns a copy of the i-th (according to the currently used indexing) element of the vector.
scvector & operator=(const rvector &v)
Assign the dense vector v to a sparse vector. Only the non zero elements of v are used.
void dropzeros()
Erases explicitly stored zeros from the data structure.
friend scvector Inf(const scivector &)
Returns the infimum of the complex interval vector as a new sparse point vector.
scvector_slice & operator=(const scvector &v)
Overwrite the vector slice with the elements of v.
friend int VecLen(const scvector_slice &)
Returns the length of the vector slice.
std::vector< real > & values()
Returns a reference to the STL-vector storing the values of the non zero elements.
Helper class for slices of sparse vectors.
int get_nnz() const
Returns the number of non zero elements of this vector (note that this includes explicitly stored zer...
scvector_slice & operator+=(const srvector_slice &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
scvector_slice & operator=(const scvector_slice &v)
Overwrite the vector slice with the elements of v.
scvector & operator-=(const scvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector.
std::vector< complex > & values()
Returns a reference to the STL-vector storing the values of the non zero elements.
int get_nnz() const
Returns the number of non zero elements of this vector (note that this includes explicitly stored zer...
scvector & operator-=(const cvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector.
friend int Lb(const scvector_slice &)
Returns the lower index bound of the vector slice v.
friend srvector Re(const scvector_slice &)
Returns the real part of the complex vector slice.
const complex operator()(const int i) const
Returns a copy of the i-th (according to the currently used indexing) element of the vector.
scvector_slice & operator+=(const cvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
cvector_slice & operator+=(const cvector &rv)
Implementation of addition and allocation operation.
scvector_slice & operator+=(const rvector_slice &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
scvector_slice & operator+=(const scvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
scvector & operator=(const cvector_slice &v)
Assign the dense vector slice v to a sparse vector. Only the non zero elements of v are used.
friend srvector abs(const scvector &)
Returns the vector of component-wise absolute values of v.
int Lb(const cimatrix &rm, const int &i)
Returns the lower bound index.
The namespace cxsc, providing all functionality of the class library C-XSC.
scvector_slice & operator=(const cvector &v)
Overwrite the vector slice with the elements of v.
scvector & operator+=(const scvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector.
scvector_slice & operator/=(const complex &s)
Operator for division of each element of the vector slice with a scalar, result is assigned to the ve...
void set_k(unsigned int i)
Set precision for computation of dot products.
friend int Lb(const scvector &)
Returns the lower index bound of the vector v.
scvector_slice & operator=(const cvector_slice &v)
Overwrite the vector slice with the elements of v.
scvector_slice & operator-=(const rvector_slice &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
scvector & operator+=(const rvector_slice &v)
Operator for element-wise addition with a vector, result is assigned to the vector.
cimatrix & SetLb(cimatrix &m, const int &i, const int &j)
Sets the lower bound index.
friend scvector mid(const scivector &)
Compute the midpoint vector of v.
scvector & operator+=(const srvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector.
int VecLen(const scimatrix_subv &S)
Returns the length of the subvector.
real density() const
Returns the density of the vector (the number of non zero elements divided by the number of elements)
scvector_slice & operator-=(const rvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
scvector & operator *=(const real &s)
Operator for multiplication with a scalar, result is assigned to the vector.
scvector & operator+=(const cvector_slice &v)
Operator for element-wise addition with a vector, result is assigned to the vector.
void accumulate_approx(cdotprecision &dp, const cmatrix_subv &rv1, const cmatrix_subv &rv2)
The accurate scalar product of the last two arguments added to the value of the first argument (witho...
real density() const
Returns the density of the vector slice (the number of non zero elements divided by the number of ele...
cvector & operator=(const cvector &rv)
Implementation of standard assigning operator.
scvector & operator+=(const rvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector.
A sparse complex interval vector.
scvector_slice & operator-=(const cvector_slice &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
scvector & operator=(const cvector &v)
Assign the dense vector v to a sparse vector. Only the non zero elements of v are used.
friend scvector Sup(const scivector &)
Returns the supremum of the complex interval vector as a new sparse point vector.
The Data Type cidotprecision.
friend void SetLb(scvector &, const int)
Sets the lower index bound of the vector v to i.
The Data Type rvector_slice.
complex & operator[](const int i)
Returns a reference to the i-th (according to the currently used indexing) element of the vector.
complex operator[](const int i) const
Returns a copy of the i-th (according to the currently used indexing) element of the vector slice.
scvector_slice & operator-=(const cvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
cimatrix & SetUb(cimatrix &m, const int &i, const int &j)
Sets the upper bound index.
scvector & operator=(const real &v)
Assigns v to all elements of the vector (resulting in a dense vector!)
scvector_slice & operator+=(const srvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
scvector_slice & operator+=(const rvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
scvector_slice & operator-=(const srvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
scvector(const int n, const int nnz, const int *index, const complex *values)
Creates a sparse vector of dimension n with nnz non zeros, who are defined by the elements of index a...
scvector_slice & operator=(const complex &v)
Assigns v to all elements of the vector slice.
scvector_slice & operator+=(const scvector_slice &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
std::vector< int > & row_indices()
Returns a reference to the STL-vector storing the row indices of the non zero elements.
civector operator *(const cimatrix_subv &rv, const cinterval &s)
Implementation of multiplication operation.
The Data Type cdotprecision.
friend void SetUb(scvector &, const int)
Sets the upper index bound of the vector v to i.
void Resize(cimatrix &A)
Resizes the matrix.
scvector_slice & operator+=(const cvector_slice &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
std::vector< int > & row_indices()
Returns a reference to the STL-vector storing the row indices of the non zero elements.
scvector(const int s)
Constructor for creating an empty vector of size s.
scvector operator()(const intvector &per)
Returns a vector whose elemnts are rearranged according to a given permutation vector.
friend int Ub(const scvector &)
Returns the upper index bound of the vector v.
scvector & operator/=(const complex &s)
Operator for division of each element of the vector with a scalar, result is assigned to the vector.
scvector(const int n, const int nnz, const intvector &index, const cvector &values)
Creates a sparse vector of dimension n with nnz non zeros, who are defined by the elements of index a...
Represents a row or column vector of a sparse matrix.
cvector_slice & operator=(const scvector &sl)
Implementation of standard assigning operator.
The Data Type civector_slice.
scvector()
Default constructor, creates an empty vector of size 0.
scvector(const cvector &v)
Constructor for creating a sparse vector our of a dense vector v. Only the non-zero elements of v are...
scvector(const srvector &v)
Constructor for creating a sparse complex vector our of a sparse real vector.
scvector & operator+=(const cvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector.
complex & operator[](const int i)
Returns a reference to the i-th (according to the currently used indexing) element of the vector slic...
friend scvector diam(const scivector &)
Computes the diameter of v.
scvector_slice & operator/=(const real &s)
Operator for division of each element of the vector slice with a scalar, result is assigned to the ve...
int get_k() const
Get currently set precision for computation of dot products.
scvector_slice & operator=(const srvector &v)
Overwrite the vector slice with the elements of v.
scvector & operator-=(const rvector_slice &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector.
cvector()
Constructor of class cvector.
scvector(const rvector &v)
Constructor for creating a sparse vector our of a dense vector v. Only the non-zero elements of v are...
scvector_slice & operator=(const srvector_slice &v)
Overwrite the vector slice with the elements of v.
scvector_slice & operator=(const rvector &v)
Overwrite the vector slice with the elements of v.
friend srvector Re(const scvector &)
Returns the real part of the complex vector v.
scvector_slice & operator-=(const srvector_slice &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
Helper class for slices of sparse vectors.
scvector_slice & operator=(const rvector_slice &v)
Overwrite the vector slice with the elements of v.
scvector & operator=(const srvector &v)
Assigns a sparse real vector to a sparse complex vector.
const complex operator()(const int i) const
Returns a copy of the i-th (according to the currently used indexing) element of the vector slice.
friend int VecLen(const scvector &)
Returns the length of the vector (the dimension)
scvector_slice & operator-=(const scvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
Helper class for slices of sparse vectors.
int Ub(const cimatrix &rm, const int &i)
Returns the upper bound index.
scvector & operator-=(const rvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector.
scvector_slice & operator *=(const real &s)
Operator for multiplication with a scalar, result is assigned to the vector slice.
scvector(const int s, const int b)
Constructor for creating an empty vector of size s and reserving memory for b elements.
Represents a row or column vector of a sparse matrix.
civector operator/(const cimatrix_subv &rv, const cinterval &s)
Implementation of division operation.
The Data Type cvector_slice.
const std::vector< int > & row_indices() const
Returns a reference to the STL-vector storing the row indices of the non zero elements.
scvector & operator/=(const real &s)
Operator for division of each element of the vector with a scalar, result is assigned to the vector.
scvector & operator=(const complex &v)
Assigns v to all elements of the vector (resulting in a dense vector!)
scvector_slice & operator-=(const scvector_slice &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
friend int Ub(const scvector_slice &)
Returns the upper index bound of the vector slice v.
friend srvector Im(const scvector &)
Returns the imaginary part of the complex vector v.
ivector abs(const cimatrix_subv &mv)
Returns the absolute value of the matrix.