26#ifndef _CXSC_SCMATRIX_HPP_INCLUDED
27#define _CXSC_SCMATRIX_HPP_INCLUDED
31#include <scvector.hpp>
36#include <sparsecdot.hpp>
37#include <sparsematrix.hpp>
38#include <srmatrix.hpp>
52inline bool comp_pair_c(std::pair<int,complex> p1, std::pair<int,complex> p2) {
53 return p1.first < p2.first;
74 std::vector<complex> x;
107 const std::vector<complex>&
values()
const {
115 lb1 = lb2 = ub1 = ub2 = 0;
119 scmatrix(
const int r,
const int c) : m(r),n(c),lb1(1),ub1(r),lb2(1),ub2(c) {
120 p = std::vector<int>((n>0) ? n+1 : 1, 0);
121 ind.reserve(2*(m+n));
128 scmatrix(
const int r,
const int c,
const int e) : m(r),n(c),lb1(1),ub1(r),lb2(1),ub2(c) {
129 p = std::vector<int>((n>0) ? n+1 : 1, 0);
147 p = std::vector<int>(n+1,0);
153 std::vector<triplet_store<complex> > work;
156 for(
int k=0 ; k<nnz ; k++) {
157 work.push_back(triplet_store<complex>(rows[
Lb(rows)+k],cols[
Lb(cols)+k],
values[
Lb(
values)+k]));
160 sort(work.begin(), work.end());
164 for(
int j=0 ; j<n ; j++) {
166 while((
unsigned int)i < work.size() && work[i].col == j ) {
167 ind.push_back(work[i].row);
168 x.push_back(work[i].val);
175 }
else if(t == compressed_row) {
179 p = std::vector<int>(n+1,0);
185 for(
int i=0 ; i<n+1 ; i++)
186 p[i] = rows[
Lb(rows)+i];
188 std::vector<triplet_store<complex> > work;
191 for(
int j=0 ; j<n ; j++) {
192 for(
int k=p[j] ; k<p[j+1] ; k++) {
193 work.push_back(triplet_store<complex>(j,cols[
Lb(cols)+k],
values[
Lb(
values)+k]));
197 sort(work.begin(), work.end());
201 for(
int j=0 ; j<n ; j++) {
203 while((
unsigned int)i < work.size() && work[i].col == j ) {
204 ind.push_back(work[i].row);
205 x.push_back(work[i].val);
212 }
else if(t == compressed_column) {
215 p = std::vector<int>(n+1,0);
221 for(
int i=0 ; i<n+1 ; i++)
222 p[i] = rows[
Lb(rows)+i];
224 std::vector<std::pair<int,complex> > work;
227 for(
int j=0 ; j<n ; j++) {
230 for(
int k=p[j] ; k<p[j+1] ; k++) {
234 std::sort(work.begin(),work.end(),comp_pair_c);
236 for(
unsigned int i=0 ; i<work.size() ; i++) {
237 ind.push_back(work[i].first);
238 x.push_back(work[i].second);
258 p = std::vector<int>(n+1,0);
264 std::vector<triplet_store<complex> > work;
267 for(
int k=0 ; k<nnz ; k++) {
268 work.push_back(triplet_store<complex>(rows[k],cols[k],
values[k]));
271 sort(work.begin(), work.end());
275 for(
int j=0 ; j<n ; j++) {
277 while((
unsigned int)i < work.size() && work[i].col == j ) {
278 ind.push_back(work[i].row);
279 x.push_back(work[i].val);
286 }
else if(t == compressed_row) {
290 p = std::vector<int>(n+1,0);
296 for(
int i=0 ; i<n+1 ; i++)
299 std::vector<triplet_store<complex> > work;
302 for(
int j=0 ; j<n ; j++) {
303 for(
int k=p[j] ; k<p[j+1] ; k++) {
304 work.push_back(triplet_store<complex>(j,cols[k],
values[k]));
308 sort(work.begin(), work.end());
312 for(
int j=0 ; j<n ; j++) {
314 while((
unsigned int)i < work.size() && work[i].col == j ) {
315 ind.push_back(work[i].row);
316 x.push_back(work[i].val);
323 }
else if(t == compressed_column) {
326 p = std::vector<int>(n+1,0);
332 for(
int i=0 ; i<n+1 ; i++)
335 std::vector<std::pair<int,complex> > work;
338 for(
int j=0 ; j<n ; j++) {
341 for(
int k=p[j] ; k<p[j+1] ; k++) {
342 work.push_back(std::make_pair(cols[k],
values[k]));
345 std::sort(work.begin(),work.end(),comp_pair_c);
347 for(
unsigned int i=0 ; i<work.size() ; i++) {
348 ind.push_back(work[i].first);
349 x.push_back(work[i].second);
359 scmatrix(
const srmatrix& A) : p(A.p), ind(A.ind), m(A.m), n(A.n), lb1(A.lb1), ub1(A.ub1), lb2(A.lb2), ub2(A.ub2) {
361 for(
unsigned int i=0 ; i<A.x.size() ; i++)
368 p = std::vector<int>((n>0) ? n+1 : 1, 0);
369 ind.reserve((m*n*0.1 < 2*m) ? (int)(m*n*0.1) : 2*m);
370 x.reserve((m*n*0.1 < 2*m) ? (int)(m*n*0.1) : 2*m);
375 for(
int j=0 ; j<n ; j++) {
376 for(
int i=0 ; i<m ; i++) {
377 if(A[i+lb1][j+lb2] != 0.0) {
379 x.push_back(
complex(A[i+lb1][j+lb2]));
391 p = std::vector<int>((n>0) ? n+1 : 1, 0);
392 ind.reserve((m*n*0.1 < 2*m) ? (int)(m*n*0.1) : 2*m);
393 x.reserve((m*n*0.1 < 2*m) ? (int)(m*n*0.1) : 2*m);
398 for(
int j=0 ; j<n ; j++) {
399 for(
int i=0 ; i<m ; i++) {
400 if(A[i+lb1][j+lb2] != 0.0) {
402 x.push_back(
complex(A[i+lb1][j+lb2]));
416 scmatrix(
const int ms,
const int ns,
const cmatrix& A) : m(ms), n(ns), lb1(1), ub1(ms), lb2(1), ub2(ns) {
419 p = std::vector<int>((n>0) ? n+1 : 1, 0);
423 std::vector<triplet_store<complex> > work;
427 for(
int i=0 ; i<
ColLen(A) ; i++) {
428 for(
int j=
Lb(A,2) ; j<=
Ub(A,2) ; j++) {
429 if(i+j >=0 && i+j < n) {
430 work.push_back(triplet_store<complex>(i,i+j,A[i+
Lb(A,1)][j]));
435 sort(work.begin(), work.end());
439 for(
int j=0 ; j<n ; j++) {
441 while((
unsigned int)i < work.size() && work[i].col == j ) {
442 ind.push_back(work[i].row);
443 x.push_back(work[i].val);
461 for(
int j=0 ; j<n ; j++) {
462 for(
int k=p[j] ; k<p[j+1] ; k++) {
463 A[ind[k]+lb1][j+lb2] = x[k];
474 std::vector<int> pnew(n+1,0);
475 std::vector<int> indnew;
476 std::vector<complex> xnew;
479 for(
int j=0 ; j<n ; j++) {
480 for(
int k=p[j] ; k<p[j+1] ; k++) {
482 xnew.push_back(x[k]);
483 indnew.push_back(ind[k]);
498 return sp_ms_assign<scmatrix,real,complex>(*
this,A);
503 return sp_ms_assign<scmatrix,complex,complex>(*
this,A);
508 return spf_mm_assign<scmatrix,rmatrix,complex>(*
this,A);
513 return spf_mm_assign<scmatrix,cmatrix,complex>(*
this,A);
518 return spf_mm_assign<scmatrix,rmatrix_slice,complex>(*
this,A);
523 return spf_mm_assign<scmatrix,cmatrix_slice,complex>(*
this,A);
534 for(
unsigned int i=0 ; i<A.x.size() ; i++)
560 if(i<lb1 || i>ub1 || j<lb2 || j>ub2)
561 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix::operator()(int, int)"));
564 for(
int k=p[j-lb2] ; k<p[j-lb2+1] && ind[k]<=i-lb1 ; k++) {
565 if(ind[k] == i-lb1) r = x[k];
581 if(i<lb1 || i>ub1 || j<lb2 || j>ub2)
582 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix::element()(int, int)"));
585 for(k=p[j-lb2] ; k<p[j-lb2+1] && ind[k]<=i-lb1 ; k++) {
586 if(ind[k] == i-lb1)
return x[k];
590 std::vector<int>::iterator ind_it = ind.begin() + k;
591 std::vector<complex>::iterator x_it = x.begin() + k;
592 ind.insert(ind_it, i-lb1);
593 x_it = x.insert(x_it,
complex(0.0));
594 for(k=j-lb2+1 ; k<(int)p.size() ; k++)
620 for(
int k=0 ; k<n ; k++) {
623 std::map<int,complex> work;
624 for(
int j=p[q[
Lb(q)+k]] ; j<p[q[
Lb(q)+k]+1] ; j++)
625 work.insert(std::make_pair(per[
Lb(per)+ind[j]], x[j]));
627 for(std::map<int,complex>::iterator it = work.begin() ; it != work.end() ; it++) {
628 A.ind.push_back(it->first);
629 A.x.push_back(it->second);
646 for(
int k=0 ; k<n ; k++) {
649 std::map<int,complex> work;
650 for(
int j=p[k] ; j<p[k+1] ; j++)
651 work.insert(std::make_pair(per[
Lb(per)+ind[j]], x[j]));
653 for(std::map<int,complex>::iterator it = work.begin() ; it != work.end() ; it++) {
654 A.ind.push_back(it->first);
655 A.x.push_back(it->second);
680 return p[n]/((double)m*n);
690 return spf_mm_addassign<scmatrix,rmatrix,cmatrix>(*
this,B);
695 return spf_mm_addassign<scmatrix,cmatrix,cmatrix>(*
this,B);
700 return spf_mm_addassign<scmatrix,rmatrix_slice,cmatrix>(*
this,B);
705 return spf_mm_addassign<scmatrix,cmatrix_slice,cmatrix>(*
this,B);
710 return spsp_mm_addassign<scmatrix,srmatrix,complex>(*
this,B);
715 return spsp_mm_addassign<scmatrix,scmatrix,complex>(*
this,B);
720 return spf_mm_subassign<scmatrix,rmatrix,cmatrix>(*
this,B);
725 return spf_mm_subassign<scmatrix,cmatrix,cmatrix>(*
this,B);
730 return spf_mm_subassign<scmatrix,rmatrix_slice,cmatrix>(*
this,B);
735 return spf_mm_subassign<scmatrix,cmatrix_slice,cmatrix>(*
this,B);
740 return spsp_mm_subassign<scmatrix,srmatrix,complex>(*
this,B);
745 return spsp_mm_subassign<scmatrix,scmatrix,complex>(*
this,B);
750 return spf_mm_multassign<scmatrix,cmatrix,sparse_cdot,cmatrix>(*
this,B);
755 return spf_mm_multassign<scmatrix,rmatrix,sparse_cdot,cmatrix>(*
this,B);
760 return spf_mm_multassign<scmatrix,rmatrix_slice,sparse_cdot,cmatrix>(*
this,B);
765 return spf_mm_multassign<scmatrix,cmatrix_slice,sparse_cdot,cmatrix>(*
this,B);
770 return spsp_mm_multassign<scmatrix,srmatrix,sparse_cdot,complex>(*
this,B);
775 return spsp_mm_multassign<scmatrix,scmatrix,sparse_cdot,complex>(*
this,B);
780 return sp_ms_multassign(*
this,r);
785 return sp_ms_multassign(*
this,r);
790 return sp_ms_divassign(*
this,r);
795 return sp_ms_divassign(*
this,r);
833#include "matrix_friend_declarations.inl"
838 lb1 = A.lb1; lb2 = A.lb2; ub1 = A.ub1; ub2 = A.ub2;
842 for(
int j=0 ; j<A.n ; j++) {
843 for(
int k=A.p[j] ; k<A.p[j+1] ; k++) {
844 dat[A.ind[k]*A.n+j] = A.x[k];
851 lb1 = A.lb1; lb2 = A.lb2; ub1 = A.ub1; ub2 = A.ub2;
855 for(
int j=0 ; j<A.n ; j++) {
856 for(
int k=A.p[j] ; k<A.p[j+1] ; k++) {
857 dat[A.ind[k]*A.n+j] = A.x[k];
864 scmatrix I(A.m, A.n, (A.m>A.n) ? A.m : A.n);
865 I.lb1 = A.lb1; I.lb2 = A.lb2;
866 I.ub1 = A.ub1; I.ub2 = A.ub2;
869 for(
int i=0 ; i<A.m ; i++) {
870 I.p[i+1] = I.p[i] + 1;
875 for(
int i=0 ; i<A.n ; i++) {
876 I.p[i+1] = I.p[i] + 1;
890 std::vector<int> w(A.m,0);
891 for(
unsigned int i=0 ; i<A.ind.size() ; i++)
897 for(
unsigned int i=1 ; i<B.p.size() ; i++)
898 B.p[i] = w[i-1] + B.p[i-1];
901 w.insert(w.begin(), 0);
902 for(
unsigned int i=1 ; i<w.size() ; i++) {
910 for(
int j=0 ; j<A.n ; j++) {
911 for(
int k=A.p[j] ; k<A.p[j+1] ; k++) {
999inline void Resize(
scmatrix& A,
const int l1,
const int u1,
const int l2,
const int u2) {
1000 sp_m_resize(A,l1,u1,l2,u2);
1013 for(
int i=0 ; i<res.
get_nnz() ; i++)
1014 res.x.push_back(Re(A.x[i]));
1031 for(
int i=0 ; i<res.
get_nnz() ; i++)
1032 res.x.push_back(Im(A.x[i]));
1044 for(
unsigned int i=0 ; i<ret.x.size() ; i++)
1045 ret.x[i] =
abs(A.x[i]);
1058 res.p[A.n] = A.p[A.n];
1060 for(
int j=0 ; j<res.n ; j++) {
1061 for(
int k=A.p[j] ; k<A.p[j+1] ; k++) {
1063 res.x.push_back(
abs(A.x[k]));
1065 res.x.push_back(-
abs(A.x[k]));
1082 return fsp_mm_mult<cmatrix,srmatrix,cmatrix,sparse_cdot>(A,B);
1093 return fsp_mm_mult<rmatrix,scmatrix,cmatrix,sparse_cdot>(A,B);
1104 return fsp_mm_mult<cmatrix,scmatrix,cmatrix,sparse_cdot>(A,B);
1115 return spf_mm_mult<scmatrix,rmatrix,cmatrix,sparse_cdot>(A,B);
1126 return spf_mm_mult<srmatrix,cmatrix,cmatrix,sparse_cdot>(A,B);
1137 return spf_mm_mult<scmatrix,cmatrix,cmatrix,sparse_cdot>(A,B);
1148 return fsp_mm_mult<cmatrix_slice,srmatrix,cmatrix,sparse_cdot>(A,B);
1159 return fsp_mm_mult<rmatrix_slice,scmatrix,cmatrix,sparse_cdot>(A,B);
1170 return fsp_mm_mult<cmatrix_slice,scmatrix,cmatrix,sparse_cdot>(A,B);
1181 return spf_mm_mult<scmatrix,rmatrix_slice,cmatrix,sparse_cdot>(A,B);
1192 return spf_mm_mult<srmatrix,cmatrix_slice,cmatrix,sparse_cdot>(A,B);
1203 return spf_mm_mult<scmatrix,cmatrix_slice,cmatrix,sparse_cdot>(A,B);
1214 return spsp_mm_mult<scmatrix,srmatrix,scmatrix,sparse_cdot,complex>(A,B);
1225 return spsp_mm_mult<srmatrix,scmatrix,scmatrix,sparse_cdot,complex>(A,B);
1236 return spsp_mm_mult<scmatrix,scmatrix,scmatrix,sparse_cdot,complex>(A,B);
1241 return sp_ms_div<scmatrix,real,scmatrix>(A,r);
1246 return sp_ms_div<scmatrix,complex,scmatrix>(A,r);
1251 return sp_ms_div<srmatrix,complex,scmatrix>(A,r);
1256 return sp_ms_mult<scmatrix,real,scmatrix>(A,r);
1261 return sp_ms_mult<scmatrix,complex,scmatrix>(A,r);
1266 return sp_ms_mult<srmatrix,complex,scmatrix>(A,r);
1271 return sp_sm_mult<real,scmatrix,scmatrix>(r,A);
1276 return sp_sm_mult<complex,scmatrix,scmatrix>(r,A);
1281 return sp_sm_mult<complex,srmatrix,scmatrix>(r,A);
1292 return spf_mv_mult<scmatrix,rvector,cvector,sparse_cdot>(A,v);
1303 return spf_mv_mult<srmatrix,cvector,cvector,sparse_cdot>(A,v);
1314 return spf_mv_mult<scmatrix,cvector,cvector,sparse_cdot>(A,v);
1325 return spf_mv_mult<scmatrix,rvector_slice,cvector,sparse_cdot>(A,v);
1336 return spf_mv_mult<srmatrix,cvector_slice,cvector,sparse_cdot>(A,v);
1347 return spf_mv_mult<scmatrix,cvector_slice,cvector,sparse_cdot>(A,v);
1358 return spsp_mv_mult<scmatrix,srvector,scvector,sparse_cdot,complex>(A,v);
1369 return spsp_mv_mult<srmatrix,scvector,scvector,sparse_cdot,complex>(A,v);
1380 return spsp_mv_mult<scmatrix,scvector,scvector,sparse_cdot,complex>(A,v);
1391 return spsl_mv_mult<scmatrix,srvector_slice,scvector,sparse_cdot,complex>(A,v);
1402 return spsl_mv_mult<srmatrix,scvector_slice,scvector,sparse_cdot,complex>(A,v);
1413 return spsl_mv_mult<scmatrix,scvector_slice,scvector,sparse_cdot,complex>(A,v);
1424 return fsp_mv_mult<cmatrix,srvector,cvector,sparse_cdot>(A,v);
1435 return fsp_mv_mult<rmatrix,scvector,cvector,sparse_cdot>(A,v);
1446 return fsp_mv_mult<cmatrix,scvector,cvector,sparse_cdot>(A,v);
1457 return fsp_mv_mult<cmatrix_slice,srvector,cvector,sparse_cdot>(A,v);
1468 return fsp_mv_mult<rmatrix_slice,scvector,cvector,sparse_cdot>(A,v);
1479 return fsp_mv_mult<cmatrix_slice,scvector,cvector,sparse_cdot>(A,v);
1490 return fsl_mv_mult<cmatrix,srvector_slice,cvector,sparse_cdot>(A,v);
1501 return fsl_mv_mult<rmatrix,scvector_slice,cvector,sparse_cdot>(A,v);
1512 return fsl_mv_mult<cmatrix,scvector_slice,cvector,sparse_cdot>(A,v);
1523 return fsl_mv_mult<cmatrix_slice,srvector_slice,cvector,sparse_cdot>(A,v);
1534 return fsl_mv_mult<rmatrix_slice,scvector_slice,cvector,sparse_cdot>(A,v);
1545 return fsl_mv_mult<cmatrix_slice,scvector_slice,cvector,sparse_cdot>(A,v);
1550 return fsp_mm_add<cmatrix,srmatrix,cmatrix>(A,B);
1555 return fsp_mm_add<rmatrix,scmatrix,cmatrix>(A,B);
1560 return fsp_mm_add<cmatrix,scmatrix,cmatrix>(A,B);
1565 return spf_mm_add<scmatrix,rmatrix,cmatrix>(A,B);
1570 return spf_mm_add<srmatrix,cmatrix,cmatrix>(A,B);
1575 return spf_mm_add<scmatrix,cmatrix,cmatrix>(A,B);
1580 return fsp_mm_add<cmatrix_slice,srmatrix,cmatrix>(A,B);
1585 return fsp_mm_add<rmatrix_slice,scmatrix,cmatrix>(A,B);
1590 return fsp_mm_add<cmatrix_slice,scmatrix,cmatrix>(A,B);
1595 return spf_mm_add<scmatrix,rmatrix_slice,cmatrix>(A,B);
1600 return spf_mm_add<srmatrix,cmatrix_slice,cmatrix>(A,B);
1605 return spf_mm_add<scmatrix,cmatrix_slice,cmatrix>(A,B);
1610 return spsp_mm_add<scmatrix,srmatrix,scmatrix,complex>(A,B);
1615 return spsp_mm_add<srmatrix,scmatrix,scmatrix,complex>(A,B);
1620 return spsp_mm_add<scmatrix,scmatrix,scmatrix,complex>(A,B);
1625 return fsp_mm_sub<cmatrix,srmatrix,cmatrix>(A,B);
1630 return fsp_mm_sub<rmatrix,scmatrix,cmatrix>(A,B);
1635 return fsp_mm_sub<cmatrix,scmatrix,cmatrix>(A,B);
1640 return spf_mm_sub<scmatrix,rmatrix,cmatrix>(A,B);
1645 return spf_mm_sub<srmatrix,cmatrix,cmatrix>(A,B);
1650 return spf_mm_sub<scmatrix,cmatrix,cmatrix>(A,B);
1655 return fsp_mm_sub<cmatrix_slice,srmatrix,cmatrix>(A,B);
1660 return fsp_mm_sub<rmatrix_slice,scmatrix,cmatrix>(A,B);
1665 return fsp_mm_sub<cmatrix_slice,scmatrix,cmatrix>(A,B);
1670 return spf_mm_sub<scmatrix,rmatrix_slice,cmatrix>(A,B);
1675 return spf_mm_sub<srmatrix,cmatrix_slice,cmatrix>(A,B);
1680 return spf_mm_sub<scmatrix,cmatrix_slice,cmatrix>(A,B);
1685 return spsp_mm_sub<scmatrix,srmatrix,scmatrix,complex>(A,B);
1690 return spsp_mm_sub<srmatrix,scmatrix,scmatrix,complex>(A,B);
1695 return spsp_mm_sub<scmatrix,scmatrix,scmatrix,complex>(A,B);
1700 return sp_m_negative<scmatrix,scmatrix>(M);
1729 return fsp_mm_addassign(*
this,B);
1733 return fsp_mm_addassign(*
this,B);
1737 return fsp_mm_addassign(*
this,B);
1741 return fsp_mm_addassign(*
this,B);
1745 return fsp_mm_subassign(*
this,B);
1749 return fsp_mm_subassign(*
this,B);
1753 return fsp_mm_subassign(*
this,B);
1757 return fsp_mm_subassign(*
this,B);
1761 return fsp_mm_multassign<cmatrix,srmatrix,sparse_cdot,cmatrix>(*
this,B);
1765 return fsp_mm_multassign<cmatrix,scmatrix,sparse_cdot,cmatrix>(*
this,B);
1769 return fsp_mm_multassign<cmatrix_slice,srmatrix,sparse_cdot,cmatrix>(*
this,B);
1773 return fsp_mm_multassign<cmatrix_slice,scmatrix,sparse_cdot,cmatrix>(*
this,B);
1778 return spsp_mm_comp(A,B);
1783 return spsp_mm_comp(A,B);
1788 return spsp_mm_comp(A,B);
1793 return spf_mm_comp(A,B);
1798 return spf_mm_comp(A,B);
1803 return spf_mm_comp(A,B);
1808 return fsp_mm_comp(A,B);
1813 return fsp_mm_comp(A,B);
1818 return fsp_mm_comp(A,B);
1823 return fsp_mm_comp(A,B);
1828 return fsp_mm_comp(A,B);
1833 return fsp_mm_comp(A,B);
1838 return spf_mm_comp(A,B);
1843 return spf_mm_comp(A,B);
1848 return spf_mm_comp(A,B);
1853 return !spsp_mm_comp(A,B);
1858 return !spsp_mm_comp(A,B);
1863 return !spsp_mm_comp(A,B);
1868 return !spf_mm_comp(A,B);
1873 return !spf_mm_comp(A,B);
1878 return !spf_mm_comp(A,B);
1883 return !fsp_mm_comp(A,B);
1888 return !fsp_mm_comp(A,B);
1893 return !fsp_mm_comp(A,B);
1898 return !fsp_mm_comp(A,B);
1903 return !fsp_mm_comp(A,B);
1908 return !fsp_mm_comp(A,B);
1913 return !spf_mm_comp(A,B);
1918 return !spf_mm_comp(A,B);
1923 return !spf_mm_comp(A,B);
1937inline std::ostream& operator<<(std::ostream& os,
const scmatrix& A) {
1938 return sp_m_output<scmatrix,complex>(os,A);
1947inline std::istream& operator>>(std::istream& is,
scmatrix& A) {
1948 return sp_m_input<scmatrix,complex>(is,A);
1971 A.p = std::vector<int>(A.n+1, 0);
1972 A.ind.reserve(A.m + A.n);
1973 A.x.reserve(A.m + A.n);
1975 for(
int i=0 ; i<A.n ; i++) {
1977 for(
int j=Mat.p[sl2l-Mat.lb2+i] ; j<Mat.p[sl2l-Mat.lb2+i+1] ; j++) {
1978 if(Mat.ind[j] >= sl1l-Mat.lb1 && Mat.ind[j] <= sl1u-Mat.lb1) {
1979 A.ind.push_back(Mat.ind[j]-(sl1l-Mat.lb1));
1980 A.x.push_back(Mat.x[j]);
1999 A.p = std::vector<int>(A.n+1, 0);
2000 A.ind.reserve(A.m + A.n);
2001 A.x.reserve(A.m + A.n);
2003 for(
int i=0 ; i<A.n ; i++) {
2005 for(
int j=Mat.p[sl2l-Mat.lb2+i] ; j<Mat.p[sl2l-Mat.lb2+i+1] ; j++) {
2006 if(Mat.ind[j] >= sl1l-Mat.lb1 && Mat.ind[j] <= sl1u-Mat.lb1) {
2007 A.ind.push_back(Mat.ind[j]-(sl1l-Mat.lb1));
2008 A.x.push_back(Mat.x[j]);
2021 return sl_ms_assign<scmatrix_slice, real, std::vector<complex>::iterator,
complex>(*
this,C);
2026 return sl_ms_assign<scmatrix_slice, complex, std::vector<complex>::iterator,
complex>(*
this,C);
2031 return slsp_mm_assign<scmatrix_slice, srmatrix, std::vector<complex>::iterator>(*
this,C);
2036 return slsp_mm_assign<scmatrix_slice, scmatrix, std::vector<complex>::iterator>(*
this,C);
2041 return slf_mm_assign<scmatrix_slice, rmatrix, std::vector<complex>::iterator,
complex>(*
this,C);
2046 return slf_mm_assign<scmatrix_slice, cmatrix, std::vector<complex>::iterator,
complex>(*
this,C);
2051 return slf_mm_assign<scmatrix_slice, rmatrix_slice, std::vector<complex>::iterator,
complex>(*
this,C);
2056 return slf_mm_assign<scmatrix_slice, cmatrix_slice, std::vector<complex>::iterator,
complex>(*
this,C);
2245#if(CXSC_INDEX_CHECK)
2246 if(i<A.lb1 || i>A.ub1 || j<A.lb2 || j>A.ub2)
2247 cxscthrow(ELEMENT_NOT_IN_VEC(
"scmatrix_slice::operator()(int, int)"));
2259#if(CXSC_INDEX_CHECK)
2260 if(i<A.lb1 || i>A.ub1 || j<A.lb2 || j>A.ub2)
2261 cxscthrow(ELEMENT_NOT_IN_VEC(
"scmatrix_slice::element(int, int)"));
2276 friend std::istream& operator>>(std::istream&,
const scmatrix_subv&);
2298#include "matrix_friend_declarations.inl"
2302 dat =
new complex[A.A.m*A.A.n];
2303 lb1 = A.A.lb1; lb2 = A.A.lb2; ub1 = A.A.ub1; ub2 = A.A.ub2;
2307 for(
int j=0 ; j<A.A.n ; j++) {
2308 for(
int k=A.A.p[j] ; k<A.A.p[j+1] ; k++) {
2309 dat[A.A.ind[k]*A.A.n+j] = A.A.x[k];
2315 dat =
new complex[A.A.m*A.A.n];
2316 lb1 = A.A.lb1; lb2 = A.A.lb2; ub1 = A.A.ub1; ub2 = A.A.ub2;
2320 for(
int j=0 ; j<A.A.n ; j++) {
2321 for(
int k=A.A.p[j] ; k<A.A.p[j+1] ; k++) {
2322 dat[A.A.ind[k]*A.A.n+j] = A.A.x[k];
2338#if(CXSC_INDEX_CHECK)
2339 if(i<lb1 || j>ub1 || k<lb2 || l>ub2)
2340 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix::operator()(int, int, int, int)"));
2346#if(CXSC_INDEX_CHECK)
2347 if(i<lb1 || j>ub1 || k<lb2 || l>ub2)
2348 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix::operator()(int, int, int, int) const"));
2405 return sp_m_negative<scmatrix,scmatrix>(M.A);
2421 return spsp_mm_mult<scmatrix,srmatrix,scmatrix,sparse_cdot,complex>(M1.A,M2.A);
2432 return spsp_mm_mult<srmatrix,scmatrix,scmatrix,sparse_cdot,complex>(M1.A,M2.A);
2443 return spsp_mm_mult<scmatrix,scmatrix,scmatrix,sparse_cdot,complex>(M1.A,M2.A);
2454 return spsp_mm_mult<scmatrix,srmatrix,scmatrix,sparse_cdot,complex>(M1.A,M2);
2465 return spsp_mm_mult<srmatrix,scmatrix,scmatrix,sparse_cdot,complex>(M1.A,M2);
2476 return spsp_mm_mult<scmatrix,scmatrix,scmatrix,sparse_cdot,complex>(M1.A,M2);
2487 return spsp_mm_mult<scmatrix,srmatrix,scmatrix,sparse_cdot,complex>(M1,M2.A);
2498 return spsp_mm_mult<srmatrix,scmatrix,scmatrix,sparse_cdot,complex>(M1,M2.A);
2509 return spsp_mm_mult<scmatrix,scmatrix,scmatrix,sparse_cdot,complex>(M1,M2.A);
2520 return spf_mm_mult<scmatrix,rmatrix,cmatrix,sparse_cdot>(M1.A,M2);
2531 return spf_mm_mult<srmatrix,cmatrix,cmatrix,sparse_cdot>(M1.A,M2);
2542 return spf_mm_mult<scmatrix,cmatrix,cmatrix,sparse_cdot>(M1.A,M2);
2553 return fsp_mm_mult<cmatrix,srmatrix,cmatrix,sparse_cdot>(M1,M2.A);
2564 return fsp_mm_mult<rmatrix,scmatrix,cmatrix,sparse_cdot>(M1,M2.A);
2575 return fsp_mm_mult<cmatrix,scmatrix,cmatrix,sparse_cdot>(M1,M2.A);
2586 return spf_mm_mult<scmatrix,rmatrix_slice,cmatrix,sparse_cdot>(M1.A,M2);
2597 return spf_mm_mult<srmatrix,cmatrix_slice,cmatrix,sparse_cdot>(M1.A,M2);
2608 return spf_mm_mult<scmatrix,cmatrix_slice,cmatrix,sparse_cdot>(M1.A,M2);
2619 return fsp_mm_mult<cmatrix,srmatrix,cmatrix,sparse_cdot>(M1,M2.A);
2630 return fsp_mm_mult<rmatrix,scmatrix,cmatrix,sparse_cdot>(M1,M2.A);
2641 return fsp_mm_mult<cmatrix,scmatrix,cmatrix,sparse_cdot>(M1,M2.A);
2652 return spsp_mv_mult<scmatrix,srvector,scvector,sparse_cdot,complex>(M.A,v);
2663 return spsp_mv_mult<srmatrix,scvector,scvector,sparse_cdot,complex>(M.A,v);
2674 return spsp_mv_mult<scmatrix,scvector,scvector,sparse_cdot,complex>(M.A,v);
2685 return spsl_mv_mult<scmatrix,srvector_slice,scvector,sparse_cdot,complex>(M.A,v);
2696 return spsl_mv_mult<srmatrix,scvector_slice,scvector,sparse_cdot,complex>(M.A,v);
2707 return spsl_mv_mult<scmatrix,scvector_slice,scvector,sparse_cdot,complex>(M.A,v);
2718 return spf_mv_mult<scmatrix,rvector,cvector,sparse_cdot>(M.A,v);
2729 return spf_mv_mult<srmatrix,cvector,cvector,sparse_cdot>(M.A,v);
2740 return spf_mv_mult<scmatrix,cvector,cvector,sparse_cdot>(M.A,v);
2751 return spf_mv_mult<scmatrix,rvector_slice,cvector,sparse_cdot>(M.A,v);
2762 return spf_mv_mult<srmatrix,cvector_slice,cvector,sparse_cdot>(M.A,v);
2773 return spf_mv_mult<scmatrix,cvector_slice,cvector,sparse_cdot>(M.A,v);
2778 return sp_ms_mult<scmatrix,real,scmatrix>(M.A,r);
2783 return sp_ms_mult<scmatrix,complex,scmatrix>(M.A,r);
2788 return sp_ms_mult<srmatrix,complex,scmatrix>(M.A,r);
2793 return sp_ms_div<scmatrix,real,scmatrix>(M.A,r);
2798 return sp_ms_div<scmatrix,complex,scmatrix>(M.A,r);
2803 return sp_ms_div<srmatrix,complex,scmatrix>(M.A,r);
2808 return sp_sm_mult<real,scmatrix,scmatrix>(r,M.A);
2813 return sp_sm_mult<complex,srmatrix,scmatrix>(r,M.A);
2818 return sp_sm_mult<complex,scmatrix,scmatrix>(r,M.A);
2823 return spsp_mm_add<scmatrix,srmatrix,scmatrix,complex>(M1.A,M2.A);
2828 return spsp_mm_add<srmatrix,scmatrix,scmatrix,complex>(M1.A,M2.A);
2833 return spsp_mm_add<scmatrix,scmatrix,scmatrix,complex>(M1.A,M2.A);
2838 return spsp_mm_add<scmatrix,srmatrix,scmatrix,complex>(M1.A,M2);
2843 return spsp_mm_add<srmatrix,scmatrix,scmatrix,complex>(M1.A,M2);
2848 return spsp_mm_add<scmatrix,scmatrix,scmatrix,complex>(M1.A,M2);
2853 return spsp_mm_add<scmatrix,srmatrix,scmatrix,complex>(M1,M2.A);
2858 return spsp_mm_add<srmatrix,scmatrix,scmatrix,complex>(M1,M2.A);
2863 return spsp_mm_add<scmatrix,scmatrix,scmatrix,complex>(M1,M2.A);
2868 return spf_mm_add<scmatrix,rmatrix,cmatrix>(M1.A,M2);
2873 return spf_mm_add<srmatrix,cmatrix,cmatrix>(M1.A,M2);
2878 return spf_mm_add<scmatrix,cmatrix,cmatrix>(M1.A,M2);
2883 return fsp_mm_add<cmatrix,srmatrix,cmatrix>(M1,M2.A);
2888 return fsp_mm_add<rmatrix,scmatrix,cmatrix>(M1,M2.A);
2893 return fsp_mm_add<cmatrix,scmatrix,cmatrix>(M1,M2.A);
2898 return spf_mm_add<scmatrix,rmatrix_slice,cmatrix>(M1.A,M2);
2903 return spf_mm_add<srmatrix,cmatrix_slice,cmatrix>(M1.A,M2);
2908 return spf_mm_add<scmatrix,cmatrix_slice,cmatrix>(M1.A,M2);
2913 return fsp_mm_add<cmatrix_slice,srmatrix,cmatrix>(M1,M2.A);
2918 return fsp_mm_add<rmatrix_slice,scmatrix,cmatrix>(M1,M2.A);
2923 return fsp_mm_add<cmatrix_slice,scmatrix,cmatrix>(M1,M2.A);
2928 return spsp_mm_sub<scmatrix,srmatrix,scmatrix,complex>(M1.A,M2.A);
2933 return spsp_mm_sub<srmatrix,scmatrix,scmatrix,complex>(M1.A,M2.A);
2938 return spsp_mm_sub<scmatrix,scmatrix,scmatrix,complex>(M1.A,M2.A);
2943 return spsp_mm_sub<scmatrix,srmatrix,scmatrix,complex>(M1.A,M2);
2948 return spsp_mm_sub<srmatrix,scmatrix,scmatrix,complex>(M1.A,M2);
2953 return spsp_mm_sub<scmatrix,scmatrix,scmatrix,complex>(M1.A,M2);
2958 return spsp_mm_sub<scmatrix,srmatrix,scmatrix,complex>(M1,M2.A);
2963 return spsp_mm_sub<srmatrix,scmatrix,scmatrix,complex>(M1,M2.A);
2968 return spsp_mm_sub<scmatrix,scmatrix,scmatrix,complex>(M1,M2.A);
2973 return spf_mm_sub<scmatrix,rmatrix,cmatrix>(M1.A,M2);
2978 return spf_mm_sub<srmatrix,cmatrix,cmatrix>(M1.A,M2);
2983 return spf_mm_sub<scmatrix,cmatrix,cmatrix>(M1.A,M2);
2988 return fsp_mm_sub<cmatrix,srmatrix,cmatrix>(M1,M2.A);
2993 return fsp_mm_sub<rmatrix,scmatrix,cmatrix>(M1,M2.A);
2998 return fsp_mm_sub<cmatrix,scmatrix,cmatrix>(M1,M2.A);
3003 return spf_mm_sub<scmatrix,rmatrix_slice,cmatrix>(M1.A,M2);
3008 return spf_mm_sub<srmatrix,cmatrix_slice,cmatrix>(M1.A,M2);
3013 return spf_mm_sub<scmatrix,cmatrix_slice,cmatrix>(M1.A,M2);
3018 return fsp_mm_sub<cmatrix_slice,srmatrix,cmatrix>(M1,M2.A);
3023 return fsp_mm_sub<rmatrix_slice,scmatrix,cmatrix>(M1,M2.A);
3028 return fsp_mm_sub<cmatrix_slice,scmatrix,cmatrix>(M1,M2.A);
3103 return spsp_mm_comp(M1.A,M2.A);
3108 return spsp_mm_comp(M1.A,M2.A);
3113 return spsp_mm_comp(M1.A,M2.A);
3118 return spsp_mm_comp(M1.A,M2);
3123 return spsp_mm_comp(M1.A,M2);
3128 return spsp_mm_comp(M1.A,M2);
3133 return spsp_mm_comp(M1,M2.A);
3138 return spsp_mm_comp(M1,M2.A);
3143 return spsp_mm_comp(M1,M2.A);
3148 return spf_mm_comp(M1.A,M2);
3153 return spf_mm_comp(M1.A,M2);
3158 return spf_mm_comp(M1.A,M2);
3163 return fsp_mm_comp(M1,M2.A);
3168 return fsp_mm_comp(M1,M2.A);
3173 return fsp_mm_comp(M1,M2.A);
3178 return fsp_mm_comp(M1,M2.A);
3183 return fsp_mm_comp(M1,M2.A);
3188 return fsp_mm_comp(M1,M2.A);
3193 return spf_mm_comp(M1.A,M2);
3198 return spf_mm_comp(M1.A,M2);
3203 return spf_mm_comp(M1.A,M2);
3208 return !spsp_mm_comp(M1.A,M2.A);
3213 return !spsp_mm_comp(M1.A,M2.A);
3218 return !spsp_mm_comp(M1.A,M2.A);
3223 return !spsp_mm_comp(M1.A,M2);
3228 return !spsp_mm_comp(M1.A,M2);
3233 return !spsp_mm_comp(M1.A,M2);
3238 return !spsp_mm_comp(M1,M2.A);
3243 return !spsp_mm_comp(M1,M2.A);
3248 return !spsp_mm_comp(M1,M2.A);
3253 return !spf_mm_comp(M1.A,M2);
3258 return !spf_mm_comp(M1.A,M2);
3263 return !spf_mm_comp(M1.A,M2);
3268 return !fsp_mm_comp(M1,M2.A);
3273 return !fsp_mm_comp(M1,M2.A);
3278 return !fsp_mm_comp(M1,M2.A);
3283 return !fsp_mm_comp(M1,M2.A);
3288 return !fsp_mm_comp(M1,M2.A);
3293 return !fsp_mm_comp(M1,M2.A);
3298 return !spf_mm_comp(M1.A,M2);
3303 return !spf_mm_comp(M1.A,M2);
3308 return !spf_mm_comp(M1.A,M2);
3313 return sp_m_not(M.A);
3323 return sp_m_output<scmatrix,complex>(os, M.A);
3351 scmatrix_subv(
scmatrix& A,
bool r,
int i,
int j,
int k,
int l) : dat(A,i,j,k,l), row(r) {
3352 if(row) index=i;
else index=k;
3355 scmatrix_subv(
const scmatrix& A,
bool r,
int i,
int j,
int k,
int l) : dat(A,i,j,k,l), row(r) {
3356 if(row) index=i;
else index=k;
3368#if(CXSC_INDEX_CHECK)
3369 if(i<dat.A.lb2 || i>dat.A.ub2)
3370 cxscthrow(ELEMENT_NOT_IN_VEC(
"scmatrix_subv::operator[](int)"));
3374#if(CXSC_INDEX_CHECK)
3375 if(i<dat.A.lb1 || i>dat.A.ub1)
3376 cxscthrow(ELEMENT_NOT_IN_VEC(
"scmatrix_subv::operator[](int)"));
3388#if(CXSC_INDEX_CHECK)
3389 if(i<dat.A.lb2 || i>dat.A.ub2)
3390 cxscthrow(ELEMENT_NOT_IN_VEC(
"scmatrix_subv::operator[](int)"));
3392 return dat(index,i);
3394#if(CXSC_INDEX_CHECK)
3395 if(i<dat.A.lb1 || i>dat.A.ub1)
3396 cxscthrow(ELEMENT_NOT_IN_VEC(
"scmatrix_subv::operator[](int)"));
3398 return dat(i,index);
3404 return sv_vs_assign(*
this,v);
3409 return sv_vs_assign(*
this,v);
3414 return svsp_vv_assign(*
this,v);
3419 return svsp_vv_assign(*
this,v);
3424 return svsl_vv_assign(*
this,v);
3429 return svsl_vv_assign(*
this,v);
3434 return svf_vv_assign(*
this,v);
3439 return svf_vv_assign(*
this,v);
3444 return svf_vv_assign(*
this,v);
3449 return svf_vv_assign(*
this,v);
3454 return svsp_vv_assign(*
this,
srvector(v));
3459 return svsp_vv_assign(*
this,
scvector(v));
3523#include "vector_friend_declarations.inl"
3529 return Lb(S.dat, 2);
3531 return Lb(S.dat, 1);
3537 return Ub(S.dat, 2);
3539 return Ub(S.dat, 1);
3544 return Ub(S)-
Lb(S)+1;
3566 if(v.row) n=v.dat.A.n;
else n=v.dat.A.m;
3574#if(CXSC_INDEX_CHECK)
3575 if(c.col()<lb2 || c.col()>ub2)
3576 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix::operator[](const cxscmatrix_column&)"));
3578 return scmatrix_subv(*
this,
false, lb1, ub1, c.col(), c.col());
3582#if(CXSC_INDEX_CHECK)
3584 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix::operator[](const int)"));
3590#if(CXSC_INDEX_CHECK)
3591 if(c.col()<lb2 || c.col()>ub2)
3592 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix::operator[](const cxscmatrix_column&)"));
3594 return scmatrix_subv(*
this,
false, lb1, ub1, c.col(), c.col());
3598#if(CXSC_INDEX_CHECK)
3600 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix::operator[](const int)"));
3606#if(CXSC_INDEX_CHECK)
3607 if(i<A.lb1 || i>A.ub1)
3608 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix_slice::operator[](const int)"));
3614#if(CXSC_INDEX_CHECK)
3615 if(c.col()<A.lb2 || c.col()>A.ub2)
3616 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix_slice::operator[](const cxscmatrix_column&)"));
3618 return scmatrix_subv(*M,
false, A.lb1, A.ub1, c.col(), c.col());
3622#if(CXSC_INDEX_CHECK)
3623 if(i<A.lb1 || i>A.ub1)
3624 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix_slice::operator[](const int)"));
3630#if(CXSC_INDEX_CHECK)
3631 if(c.col()<A.lb2 || c.col()>A.ub2)
3632 cxscthrow(ROW_OR_COL_NOT_IN_MAT(
"scmatrix_slice::operator[](const cxscmatrix_column&)"));
3634 return scmatrix_subv(*M,
false, A.lb1, A.ub1, c.col(), c.col());
3647 for(
int j=0 ; j<n ; j++) {
3648 for(
int k=A.dat.A.p[j] ; k<A.dat.A.p[j+1] ; k++) {
3650 x.push_back(A.dat.A.x[k]);
3659 for(
unsigned int k=0 ; k<A.dat.A.ind.size() ; k++) {
3660 p.push_back(A.dat.A.ind[k]);
3661 x.push_back(A.dat.A.x[k]);
4641 spsp_vv_accu<cdotprecision,scvector,scvector,sparse_cdot>(dot,
scvector(v1),
scvector(v2));
4649 spsp_vv_accu<cdotprecision,scvector,srvector,sparse_cdot>(dot,
scvector(v1),
srvector(v2));
4657 spsp_vv_accu<cdotprecision,srvector,scvector,sparse_cdot>(dot,
srvector(v1),
scvector(v2));
4665 spsp_vv_accu<cdotprecision,scvector,scvector,sparse_cdot>(dot,
scvector(v1), v2);
4673 spsp_vv_accu<cdotprecision,scvector,srvector,sparse_cdot>(dot,
scvector(v1), v2);
4681 spsp_vv_accu<cdotprecision,srvector,scvector,sparse_cdot>(dot,
srvector(v1), v2);
4689 spsl_vv_accu<cdotprecision,scvector,scvector_slice,sparse_cdot>(dot,
scvector(v1), v2);
4697 spsl_vv_accu<cdotprecision,scvector,srvector_slice,sparse_cdot>(dot,
scvector(v1), v2);
4705 spsl_vv_accu<cdotprecision,srvector,scvector_slice,sparse_cdot>(dot,
srvector(v1), v2);
4713 spf_vv_accu<cdotprecision,scvector,cvector,sparse_cdot>(dot,
scvector(v1), v2);
4721 spf_vv_accu<cdotprecision,scvector,rvector,sparse_cdot>(dot,
scvector(v1), v2);
4729 spf_vv_accu<cdotprecision,srvector,cvector,sparse_cdot>(dot,
srvector(v1), v2);
4737 spf_vv_accu<cdotprecision,scvector,cvector_slice,sparse_cdot>(dot,
scvector(v1), v2);
4745 spf_vv_accu<cdotprecision,scvector,rvector_slice,sparse_cdot>(dot,
scvector(v1), v2);
4753 spf_vv_accu<cdotprecision,srvector,cvector_slice,sparse_cdot>(dot,
srvector(v1), v2);
4761 spsp_vv_accu<cdotprecision,scvector,scvector,sparse_cdot>(dot, v1,
scvector(v2));
4769 spsp_vv_accu<cdotprecision,scvector,srvector,sparse_cdot>(dot, v1,
srvector(v2));
4777 spsp_vv_accu<cdotprecision,srvector,scvector,sparse_cdot>(dot, v1,
scvector(v2));
4785 slsp_vv_accu<cdotprecision,scvector_slice,scvector,sparse_cdot>(dot, v1,
scvector(v2));
4793 slsp_vv_accu<cdotprecision,scvector_slice,srvector,sparse_cdot>(dot, v1,
srvector(v2));
4801 slsp_vv_accu<cdotprecision,srvector_slice,scvector,sparse_cdot>(dot, v1,
scvector(v2));
4809 fsp_vv_accu<cdotprecision,cvector,scvector,sparse_cdot>(dot, v1,
scvector(v2));
4817 fsp_vv_accu<cdotprecision,cvector,srvector,sparse_cdot>(dot, v1,
srvector(v2));
4825 fsp_vv_accu<cdotprecision,rvector,scvector,sparse_cdot>(dot, v1,
scvector(v2));
4833 fsp_vv_accu<cdotprecision,cvector_slice,scvector,sparse_cdot>(dot, v1,
scvector(v2));
4841 fsp_vv_accu<cdotprecision,cvector_slice,srvector,sparse_cdot>(dot, v1,
srvector(v2));
4849 fsp_vv_accu<cdotprecision,rvector_slice,scvector,sparse_cdot>(dot, v1,
scvector(v2));
4859 spsp_vv_accuapprox<cdotprecision,scvector,scvector,sparse_cdot>(dot,
scvector(v1),
scvector(v2));
4869 spsp_vv_accuapprox<cdotprecision,scvector,srvector,sparse_cdot>(dot,
scvector(v1),
srvector(v2));
4879 spsp_vv_accuapprox<cdotprecision,srvector,scvector,sparse_cdot>(dot,
srvector(v1),
scvector(v2));
4889 spsp_vv_accuapprox<cdotprecision,scvector,scvector,sparse_cdot>(dot,
scvector(v1), v2);
4899 spsp_vv_accuapprox<cdotprecision,scvector,srvector,sparse_cdot>(dot,
scvector(v1), v2);
4909 spsp_vv_accuapprox<cdotprecision,srvector,scvector,sparse_cdot>(dot,
srvector(v1), v2);
4919 spsl_vv_accuapprox<cdotprecision,scvector,scvector_slice,sparse_cdot>(dot,
scvector(v1), v2);
4929 spsl_vv_accuapprox<cdotprecision,scvector,srvector_slice,sparse_cdot>(dot,
scvector(v1), v2);
4939 spsl_vv_accuapprox<cdotprecision,srvector,scvector_slice,sparse_cdot>(dot,
srvector(v1), v2);
4949 spf_vv_accuapprox<cdotprecision,scvector,cvector,sparse_cdot>(dot,
scvector(v1), v2);
4959 spf_vv_accuapprox<cdotprecision,scvector,rvector,sparse_cdot>(dot,
scvector(v1), v2);
4969 spf_vv_accuapprox<cdotprecision,srvector,cvector,sparse_cdot>(dot,
srvector(v1), v2);
4979 spf_vv_accuapprox<cdotprecision,scvector,cvector_slice,sparse_cdot>(dot,
scvector(v1), v2);
4989 spf_vv_accuapprox<cdotprecision,scvector,rvector_slice,sparse_cdot>(dot,
scvector(v1), v2);
4999 spf_vv_accuapprox<cdotprecision,srvector,cvector_slice,sparse_cdot>(dot,
srvector(v1), v2);
5009 spsp_vv_accuapprox<cdotprecision,scvector,scvector,sparse_cdot>(dot, v1,
scvector(v2));
5019 spsp_vv_accuapprox<cdotprecision,scvector,srvector,sparse_cdot>(dot, v1,
srvector(v2));
5029 spsp_vv_accuapprox<cdotprecision,srvector,scvector,sparse_cdot>(dot, v1,
scvector(v2));
5039 slsp_vv_accuapprox<cdotprecision,scvector_slice,scvector,sparse_cdot>(dot, v1,
scvector(v2));
5049 slsp_vv_accuapprox<cdotprecision,scvector_slice,srvector,sparse_cdot>(dot, v1,
srvector(v2));
5059 slsp_vv_accuapprox<cdotprecision,srvector_slice,scvector,sparse_cdot>(dot, v1,
scvector(v2));
5069 fsp_vv_accuapprox<cdotprecision,cvector,scvector,sparse_cdot>(dot, v1,
scvector(v2));
5079 fsp_vv_accuapprox<cdotprecision,cvector,srvector,sparse_cdot>(dot, v1,
srvector(v2));
5089 fsp_vv_accuapprox<cdotprecision,rvector,scvector,sparse_cdot>(dot, v1,
scvector(v2));
5099 fsp_vv_accuapprox<cdotprecision,cvector_slice,scvector,sparse_cdot>(dot, v1,
scvector(v2));
5109 fsp_vv_accuapprox<cdotprecision,cvector_slice,srvector,sparse_cdot>(dot, v1,
srvector(v2));
5119 fsp_vv_accuapprox<cdotprecision,rvector_slice,scvector,sparse_cdot>(dot, v1,
scvector(v2));
5421#include "sparsematrix.inl"
The Data Type cdotprecision.
void set_k(unsigned int i)
Set precision for computation of dot products.
The Data Type cidotprecision.
int get_k() const
Get currently set precision for computation of dot products.
The Data Type cmatrix_slice.
cmatrix_slice & operator=(const cmatrix &m) noexcept
Implementation of standard assigning operator.
cmatrix_slice & operator-=(const srmatrix &m)
Implementation of addition and assignment operator.
cmatrix_slice & operator*=(const srmatrix &m)
Implementation of addition and assignment operator.
cmatrix_slice & operator+=(const srmatrix &m)
Implementation of addition and assignment operator.
The Data Type cmatrix_subv.
cmatrix_subv & operator=(const scmatrix_subv &rv)
Implementation of standard assigning operator.
cmatrix_subv & operator-=(const scmatrix_subv &rv)
Implementation of standard assigning operator.
cmatrix_subv & operator+=(const scmatrix_subv &rv)
Implementation of standard assigning operator.
cmatrix() noexcept
Constructor of class cmatrix.
cmatrix & operator+=(const srmatrix &m)
Implementation of addition and assignment operator.
cmatrix & operator*=(const srmatrix &m)
Implementation of addition and assignment operator.
cmatrix & operator-=(const srmatrix &m)
Implementation of addition and assignment operator.
cmatrix & operator=(const complex &r) noexcept
Implementation of standard assigning operator.
The Data Type cvector_slice.
The Data Type rmatrix_slice.
The Data Type rvector_slice.
A slice of a sparse complex interval matrix.
Represents a row or column vector of a sparse matrix.
A sparse complex interval matrix.
A sparse complex interval vector.
A slice of a sparse complex matrix.
scmatrix_slice & operator*=(const cmatrix_slice &M)
Assigns the product of the sparse slice and M to the slice.
scmatrix_slice & operator-=(const cmatrix_slice &M)
Assigns the element wise difference of the sparse slice and M to the slice.
friend int RowLen(const scmatrix_slice &)
Returns the number columns of the matrix slice.
friend int Ub(const scmatrix_slice &, const int)
Returns the upper index bound of the rows (if i==ROW) or columns (if i==COL) of the slice.
scmatrix_slice & operator-=(const scmatrix_slice &M)
Assigns the element wise difference of the sparse slice and M to the slice.
scmatrix_slice & operator*=(const real &r)
Assigns the component wise product of the sparse slice and r to the slice.
scmatrix_slice & operator+=(const cmatrix_slice &M)
Assigns the element wise sum of the sparse slice and M to the slice.
scmatrix_slice & operator-=(const rmatrix &M)
Assigns the element wise difference of the sparse slice and M to the slice.
friend srmatrix Re(const scmatrix_slice &)
Return the real part of the slice.
scmatrix_slice & operator=(const real &C)
Assing C to all elements of the slice
scmatrix_slice & operator+=(const scmatrix &M)
Assigns the element wise sum of the sparse slice and M to the slice.
scmatrix_slice & operator+=(const srmatrix_slice &M)
Assigns the element wise sum of the sparse slice and M to the slice.
scmatrix_slice & operator=(const cmatrix_slice &C)
Assing C to the slice.
scmatrix_subv operator[](const int)
Returns a row of the matrix.
scmatrix_slice & operator/=(const real &r)
Assigns the component wise division of the sparse slice and M to the slice.
scmatrix_slice & operator-=(const srmatrix_slice &M)
Assigns the element wise difference of the sparse slice and M to the slice.
scmatrix_slice & operator=(const rmatrix &C)
Assing C to the slice.
scmatrix_slice & operator/=(const complex &r)
Assigns the component wise division of the sparse slice and M to the slice.
friend std::ostream & operator<<(std::ostream &, const scmatrix_slice &)
Standard output operator for sparse matrix slice.
scmatrix_slice & operator*=(const scmatrix &M)
Assigns the product of the sparse slice and M to the slice.
scmatrix_slice & operator+=(const scmatrix_slice &M)
Assigns the element wise sum of the sparse slice and M to the slice.
scmatrix_slice & operator*=(const srmatrix_slice &M)
Assigns the product of the sparse slice and M to the slice.
scmatrix_slice & operator+=(const rmatrix_slice &M)
Assigns the element wise sum of the sparse slice and M to the slice.
scmatrix_slice & operator=(const cmatrix &C)
Assing C to the slice.
friend int Lb(const scmatrix_slice &, const int)
Returns the lower index bound of the rows (if i==ROW) or columns (if i==COL) of the slice.
scmatrix_slice & operator*=(const rmatrix &M)
Assigns the product of the sparse slice and M to the slice.
scmatrix_slice & operator+=(const cmatrix &M)
Assigns the element wise sum of the sparse slice and M to the slice.
scmatrix_slice & operator=(const complex &C)
Assing C to all elements of the slice.
scmatrix_slice & operator=(const scmatrix &C)
Assing C to the slice.
scmatrix_slice & operator-=(const rmatrix_slice &M)
Assigns the element wise difference of the sparse slice and M to the slice.
scmatrix_slice & operator=(const srmatrix_slice &C)
Assing C to the slice.
friend srmatrix Im(const scmatrix_slice &)
Returns the imaginary part of the slice.
scmatrix_slice & operator*=(const srmatrix &M)
Assigns the product of the sparse slice and M to the slice.
complex & element(const int i, const int j)
Returns a reference to the element (i,j) of the matrix.
scmatrix_slice & operator=(const srmatrix &C)
Assing C to the slice.
scmatrix_slice & operator=(const scmatrix_slice &C)
Assing C to the slice.
scmatrix_slice & operator*=(const rmatrix_slice &M)
Assigns the product of the sparse slice and M to the slice.
scmatrix_slice & operator*=(const cmatrix &M)
Assigns the product of the sparse slice and M to the slice.
scmatrix_slice & operator+=(const srmatrix &M)
Assigns the element wise sum of the sparse slice and M to the slice.
const complex operator()(const int i, const int j) const
Returns a copy of the element (i,j) of the matrix.
scmatrix_slice & operator-=(const scmatrix &M)
Assigns the element wise difference of the sparse slice and M to the slice.
scmatrix_slice & operator+=(const rmatrix &M)
Assigns the element wise sum of the sparse slice and M to the slice.
scmatrix_slice & operator-=(const cmatrix &M)
Assigns the element wise difference of the sparse slice and M to the slice.
scmatrix_slice & operator*=(const scmatrix_slice &M)
Assigns the product of the sparse slice and M to the slice.
scmatrix_slice & operator=(const rmatrix_slice &C)
Assing C to the slice.
friend int ColLen(const scmatrix_slice &)
Returns the number of rows of the matrix slice.
scmatrix_slice & operator-=(const srmatrix &M)
Assigns the element wise difference of the sparse slice and M to the slice.
scmatrix_slice & operator*=(const complex &r)
Assigns the component wise product of the sparse slice and r to the slice.
Represents a row or column vector of a sparse matrix.
scmatrix_subv & operator/=(const real &)
Assign the componentwise division of the subvector with a scalar to the subvector
scmatrix_subv & operator-=(const srvector &)
Assign the difference of the subvector with a vector to the subvector
complex & operator[](const int i)
Returns a reference to the i-th element of the subvector.
scmatrix_subv & operator=(const scvector_slice &v)
Assigns a vector to a subvector.
scmatrix_subv & operator*=(const real &)
Assign the componentwise product of the subvector with a scalar to the subvector.
friend int Lb(const scmatrix_subv &)
Returns the lower index bound of the subvector.
friend scvector operator-(const scmatrix_subv &)
Unary negation operator.
scmatrix_subv & operator=(const srvector &v)
Assigns a vector to a subvector.
scmatrix_subv & operator+=(const srvector &)
Assign the sum of the subvector with a vector to the subvector
scmatrix_subv & operator=(const rvector &v)
Assigns a vector to a subvector.
scmatrix_subv & operator=(const cvector &v)
Assigns a vector to a subvector.
friend std::istream & operator>>(std::istream &, scmatrix_subv &)
Standard input operator for subvectors.
scmatrix_subv & operator=(const srmatrix_subv &v)
Assigns a vector to a subvector.
friend int Ub(const scmatrix_subv &)
Returns the upper index bound of the subvector.
const complex operator[](const int i) const
Returns a copy of the i-th element of the subvector.
scmatrix_subv & operator=(const srvector_slice &v)
Assigns a vector to a subvector.
friend int VecLen(const scmatrix_subv &)
Returns the length of the subvector.
scmatrix_subv & operator=(const real &v)
Assigns v to all elements of the subvector.
scmatrix_subv & operator=(const complex &v)
Assigns v to all elements of the subvector.
scmatrix_subv & operator=(const rvector_slice &v)
Assigns a vector to a subvector.
friend srvector Re(const scmatrix_subv &)
Returns the real part of the subvector.
friend srvector Im(const scmatrix_subv &)
Returns the imaginary part of the subvector.
scmatrix_subv & operator=(const cvector_slice &v)
Assigns a vector to a subvector.
scmatrix_subv & operator=(const scvector &v)
Assigns a vector to a subvector.
scmatrix_subv & operator=(const scmatrix_subv &v)
Assigns a vector to a subvector.
friend srmatrix CompMat(const scmatrix &)
Returns Ostrowskis comparison matrix for A.
int get_nnz() const
Returns the number of non-zero entries (including explicitly stored zeros).
scmatrix operator()(const intmatrix &P, const intmatrix &Q)
Performs row and column permutations using the two permutation matrices P and Q. Faster than explicit...
friend int ColLen(const scmatrix &)
Returns the number of rows of the matrix.
scmatrix(const srmatrix &A)
Creates a sparse complex matrix out of a sparse real matrix.
scmatrix & operator*=(const cmatrix_slice &B)
Multiply the sparse matrix by B and assign the result to it.
scmatrix & operator=(const srmatrix &A)
Assigns a sparse real matrix to the sparse complex matrix.
real density() const
Returns the density (the number of non-zeros divided by the number of elements) of the matrix.
const std::vector< int > & row_indices() const
Returns a constant reference to the vector containing the row indices (the array)
friend srmatrix Re(const scmatrix &)
Returns the real part of the sparse matrix A.
friend void SetUb(scmatrix &, const int, const int)
Sets the upper index bound of the rows (i==ROW) or columns (i==COL) to j.
friend scmatrix mid(const scimatrix &)
Returns the componentwise midpoint of the matrix A.
const std::vector< complex > & values() const
Returns a constant reference to the vector containing the stored values (the array)
scmatrix & operator-=(const cmatrix_slice &B)
Subtract B from the sparse matrix and assign the result to it.
scmatrix & operator-=(const cmatrix &B)
Subtract B from the sparse matrix and assign the result to it.
scmatrix(const int m, const int n, const int nnz, const intvector &rows, const intvector &cols, const cvector &values, const enum STORAGE_TYPE t=triplet)
Creates a sparse matrix out of three vectors (arrays) forming a matrix stored in triplet,...
scmatrix & operator*=(const rmatrix &B)
Multiply the sparse matrix by B and assign the result to it.
scmatrix & operator*=(const complex &r)
Multiply all elements of the sparse matrix by r and assign the result to it.
scmatrix & operator+=(const scmatrix &B)
Add B to the sparse matrix and assign the result to it.
scmatrix_subv operator[](const cxscmatrix_column &)
Returns a column of the matrix as a sparse subvector object.
friend scmatrix Sup(const scimatrix &)
Returns the Supremum of the matrix A.
scmatrix & operator+=(const cmatrix &B)
Add B to the sparse matrix and assign the result to it.
scmatrix & operator=(const rmatrix &A)
Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix slice are ...
scmatrix & operator/=(const real &r)
Divide all elements of the sparse matrix by r and assign the result to it.
scmatrix & operator*=(const srmatrix &B)
Multiply the sparse matrix by B and assign the result to it.
friend scmatrix diam(const scimatrix &)
Returns the componentwise diameter of the matrix A.
friend int Lb(const scmatrix &, int)
Returns the lower index bound for the rows or columns of A.
scmatrix & operator-=(const rmatrix_slice &B)
Subtract B from the sparse matrix and assign the result to it.
scmatrix & operator+=(const srmatrix &B)
Add B to the sparse matrix and assign the result to it.
void dropzeros()
Drops explicitly stored zeros from the data structure.
scmatrix operator()(const intvector &pervec, const intvector &q)
Performs a row and column permutation using two permutation vectors.
scmatrix & operator/=(const complex &r)
Divide all elements of the sparse matrix by r and assign the result to it.
scmatrix & operator-=(const rmatrix &B)
Subtract B from the sparse matrix and assign the result to it.
scmatrix & operator=(const real &A)
Assigns a real value to all elements of the matrix (resulting in a dense matrix!)
scmatrix & operator-=(const scmatrix &B)
Subtract B from the sparse matrix and assign the result to it.
scmatrix & operator=(const cmatrix_slice &A)
Assigns a dense matrix slice to the sparse matrix. Only the non zero entries of the dense matrix slic...
void full(cmatrix &A) const
Creates a full matrix out of the sparse matrix and stores it in A. This should normally be done using...
friend srmatrix abs(const scmatrix &)
Returns the componentwise absolute value of the sparse matrix A.
scmatrix & operator+=(const cmatrix_slice &B)
Add B to the sparse matrix and assign the result to it.
scmatrix & operator*=(const real &r)
Multiply all elements of the sparse matrix by r and assign the result to it.
std::vector< complex > & values()
Returns a reference to the vector containing the stored values (the array)
complex & element(int i, int j)
Returns a reference to the element (i,j) of the matrix.
scmatrix operator()(const intmatrix &P)
Performs a row permutation using the permutation matrix P. Faster than explicitly computing the produ...
friend int RowLen(const scmatrix &)
Returns the number of columns of the matrix.
scmatrix(const int m, const int n, const int nnz, const int *rows, const int *cols, const complex *values, const enum STORAGE_TYPE t=triplet)
Creates a sparse matrix out of three arrays forming a matrix stored in triplet, compressed row or com...
scmatrix & operator=(const cmatrix &A)
Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix slice are ...
std::vector< int > & row_indices()
Returns a reference to the vector containing the row indices (the array)
scmatrix()
Standard constructor, creates an empty matrix of dimension 0x0.
scmatrix(const cmatrix &A)
Creates a sparse matrix out of a dense matrix A. Only the non zero elements of A are stored explicitl...
friend scmatrix transp(const scmatrix &)
Returns the transpose of A.
friend std::istream & operator>>(std::istream &, scmatrix_slice &)
Standard input operator for sparse matrix slice.
const std::vector< int > & column_pointers() const
Returns a constant reference to the vector containing the column pointers (the array)
scmatrix operator()(const intvector &pervec)
Performs a row permutation using a permutation vector.
scmatrix & operator=(const complex &A)
Assigns a complex value to all elements of the matrix (resulting in a dense matrix!...
scmatrix & operator+=(const rmatrix &B)
Add B to the sparse matrix and assign the result to it.
const complex operator()(int i, int j) const
Returns a copy of the element in row i and column j.
scmatrix(const rmatrix &A)
Creates a sparse matrix out of a dense matrix A. Only the non zero elements of A are stored explicitl...
friend srmatrix Im(const scmatrix &)
Returns the imaginary part of the sparse matrix A.
scmatrix(const int ms, const int ns, const cmatrix &A)
Constructor for banded matrices.
scmatrix & operator*=(const rmatrix_slice &B)
Multiply the sparse matrix by B and assign the result to it.
friend void SetLb(scmatrix &, const int, const int)
Sets the lower index bound of the rows (i==ROW) or columns (i==COL) to j.
scmatrix(const int r, const int c)
Creates an empty matrix with r rows and c columns, pre-reserving space for 2*(r+c) elements.
scmatrix & operator*=(const scmatrix &B)
Multiply the sparse matrix by B and assign the result to it.
scmatrix(const int r, const int c, const int e)
Creates an empty matrix with r rows and c columns, pre-reserving space for e elements.
std::vector< int > & column_pointers()
Returns a reference to the vector containing the column pointers (the array)
scmatrix & operator+=(const rmatrix_slice &B)
Add B to the sparse matrix and assign the result to it.
scmatrix & operator-=(const srmatrix &B)
Subtract B from the sparse matrix and assign the result to it.
scmatrix & operator=(const rmatrix_slice &A)
Assigns a dense matrix slice to the sparse matrix. Only the non zero entries of the dense matrix slic...
friend int Ub(const scmatrix &, int)
Returns the upper index bound for the rows or columns of A.
scmatrix & operator*=(const cmatrix &B)
Multiply the sparse matrix by B and assign the result to it.
friend scmatrix Id(const scmatrix &)
Return a sparse unity matrix of the same dimension as A.
friend scmatrix Inf(const scimatrix &)
Returns the Infimum of the matrix A.
Helper class for slices of sparse vectors.
scvector()
Default constructor, creates an empty vector of size 0
A slice of a sparse real matrix.
Represents a row or column vector of a sparse matrix.
void dropzeros()
Drops explicitly stored zeros from the data structure.
int get_nnz() const
Returns the number of non-zero entries (including explicitly stored zeros).
Helper class for slices of sparse vectors.
The namespace cxsc, providing all functionality of the class library C-XSC.
int VecLen(const scimatrix_subv &S)
Returns the length of the subvector.
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...
int ColLen(const cimatrix &)
Returns the column dimension.
rmatrix CompMat(const cimatrix &A)
Returns Ostrowski's comparison matrix.
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
cimatrix transp(const cimatrix &A)
Returns the transposed matrix.
int Ub(const cimatrix &rm, const int &i) noexcept
Returns the upper bound index.
cimatrix & SetLb(cimatrix &m, const int &i, const int &j) noexcept
Sets the lower bound index.
int RowLen(const cimatrix &)
Returns the row dimension.
STORAGE_TYPE
Enumeration depicting the storage type of a sparse matrix (Triplet storage, Compressed column storage...
cimatrix Id(const cimatrix &A)
Returns the Identity matrix.
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
civector operator*(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of multiplication operation.
void Resize(cimatrix &A) noexcept
Resizes the matrix.
cimatrix & SetUb(cimatrix &m, const int &i, const int &j) noexcept
Sets the upper bound index.
int Lb(const cimatrix &rm, const int &i) noexcept
Returns the lower bound index.