C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
srvector.hpp
1/*
2** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
3**
4** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
5** Universitaet Karlsruhe, Germany
6** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
7** Universitaet Wuppertal, Germany
8**
9** This library is free software; you can redistribute it and/or
10** modify it under the terms of the GNU Library General Public
11** License as published by the Free Software Foundation; either
12** version 2 of the License, or (at your option) any later version.
13**
14** This library is distributed in the hope that it will be useful,
15** but WITHOUT ANY WARRANTY; without even the implied warranty of
16** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17** Library General Public License for more details.
18**
19** You should have received a copy of the GNU Library General Public
20** License along with this library; if not, write to the Free
21** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*/
23
24/* CVS $Id: srvector.hpp,v 1.16 2014/01/30 17:23:49 cxsc Exp $ */
25
26#ifndef _CXSC_SRVECTOR_HPP_INCLUDED
27#define _CXSC_SRVECTOR_HPP_INCLUDED
28
29#include <real.hpp>
30#include <intvector.hpp>
31#include <rvector.hpp>
32#include <intmatrix.hpp>
33#include <vector>
34#include <map>
35#include <iostream>
36#include <except.hpp>
37#include <cidot.hpp>
38#include <sparsedot.hpp>
39#include <sparsevector.hpp>
40
41namespace cxsc {
42
43class srvector_slice;
44class srmatrix;
45class srmatrix_slice;
46class srmatrix_subv;
47
48class scvector;
49class sivector;
50class sivector_slice;
51class scivector;
52
54
58class srvector {
59 private:
60 std::vector<int> p;
61 std::vector<real> x;
62 int lb;
63 int ub;
64 int n;
65
66 public:
68 srvector() : lb(0), ub(-1) , n(0) {
69 }
70
72 explicit srvector(const int s) : lb(1), ub(s), n(s) {
73 p.reserve((int)(s*0.1));
74 x.reserve((int)(s*0.1));
75 }
76
78 srvector(const int s, const int b) : lb(1), ub(s), n(s) {
79 p.reserve(b);
80 x.reserve(b);
81 }
82
84 srvector(const rvector& v) : lb(Lb(v)), ub(Ub(v)), n(VecLen(v)) {
85 for(int i=lb ; i<=ub ; i++) {
86 if(v[i] != 0.0) {
87 p.push_back(i-lb);
88 x.push_back(v[i]);
89 }
90 }
91 }
92
94 srvector(const int n, const int nnz, const intvector& index, const rvector& values) : lb(1), ub(n) {
95 this->n = n;
96 for(int i=0 ; i<nnz ; i++) {
97 if(values[Lb(values)+i] != 0.0) {
98 p.push_back(index[Lb(index)+i]);
99 x.push_back(values[Lb(values)+i]);
100 }
101 }
102
103 }
104
106 srvector(const int n, const int nnz, const int *index, const real *values) : lb(1), ub(n) {
107 this->n = n;
108 for(int i=0 ; i<nnz ; i++) {
109 if(values[i] != 0.0) {
110 p.push_back(index[i]);
111 x.push_back(values[i]);
112 }
113 }
114 }
115
117 srvector(const srvector_slice&);
119 srvector(const srmatrix_subv& A);
120
122
127 std::vector<int>& row_indices() {
128 return p;
129 }
130
132
136 std::vector<real>& values() {
137 return x;
138 }
139
141
146 const std::vector<int>& row_indices() const {
147 return p;
148 }
149
151
155 const std::vector<real>& values() const {
156 return x;
157 }
158
160 int get_nnz() const {
161 return x.size();
162 }
163
165 real density() const {
166 return (double)x.size()/n;
167 }
168
170 void dropzeros() {
171 for(int i=0 ; i<get_nnz() ; i++) {
172 if(x[i] == 0.0) {
173 x.erase(x.begin()+i);
174 p.erase(p.begin()+i);
175 }
176 }
177 }
178
181 return sp_vs_assign<srvector,real,real>(*this,v);
182 }
183
186 return spf_vv_assign<srvector,rvector,real>(*this,v);
187 }
188
191 return spf_vv_assign<srvector,rvector_slice,real>(*this,v);
192 }
193
196
198
202 real& operator[](const int i) {
203#if(CXSC_INDEX_CHECK)
204 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector::operator[](const int)"));
205#endif
206 int k;
207
208 for(k=0 ; k<get_nnz() && p[k]<=i-lb ; k++) {
209 if(p[k] == i-lb)
210 return x[k];
211 }
212
213 p.insert(p.begin() + k, i-lb);
214 x.insert(x.begin() + k, 0.0);
215
216 return x[k];
217 }
218
220
224 real operator[](const int i) const {
225#if(CXSC_INDEX_CHECK)
226 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector::operator[](const int)"));
227#endif
228 return (*this)(i);
229 }
230
232
236 const real operator()(const int i) const {
237#if(CXSC_INDEX_CHECK)
238 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector::operator()(const int)"));
239#endif
240 real r = 0.0;
241
242 for(int k=0 ; k<get_nnz() && p[k]<=i-lb ; k++) {
243 if(p[k] == i-lb)
244 r = x[k];
245 }
246
247 return r;
248 }
249
251
253 srvector_slice operator()(const int i, const int j);
254
256
260 srvector v(n,get_nnz());
261 intvector pinv = perminv(per);
262
263 std::map<int,real> work;
264 for(int i=0 ; i<get_nnz() ; i++)
265 work.insert(std::make_pair(pinv[Lb(pinv)+p[i]], x[i]));
266
267 for(std::map<int,real>::iterator it=work.begin() ; it!=work.end() ; it++) {
268 v.p.push_back(it->first);
269 v.x.push_back(it->second);
270 }
271
272 return v;
273 }
274
276
283 intvector p = permvec(P);
284 return (*this)(p);
285 }
286
289 return sp_vs_multassign(*this,s);
290 }
291
294 return sp_vs_divassign(*this,s);
295 }
296
299 {
300 return spf_vv_addassign(*this,v);
301 }
302
305 return spf_vv_addassign(*this,v);
306 }
307
310 return spsp_vv_addassign(*this,v);
311 }
312
315
318 return spf_vv_subassign(*this,v);
319 }
320
323 return spf_vv_subassign(*this,v);
324 }
325
328 return spsp_vv_subassign(*this,v);
329 }
330
333
334 friend int Lb(const srvector&);
335 friend int Ub(const srvector&);
336 friend void SetLb(srvector&, const int);
337 friend void SetUb(srvector&, const int);
338
339 friend int VecLen(const srvector&);
340 friend srvector Re(const scvector&);
341 friend srvector Im(const scvector&);
342 friend srvector Inf(const sivector&);
343 friend srvector Sup(const sivector&);
344 friend srvector InfRe(const scivector&);
345 friend srvector SupRe(const scivector&);
346 friend srvector InfIm(const scivector&);
347 friend srvector SupIm(const scivector&);
348 friend srvector mid(const sivector&);
349 friend srvector diam(const sivector&);
350 friend srvector absmin(const sivector&);
351 friend srvector absmax(const sivector&);
352 friend srvector abs(const srvector&);
353 friend srvector mid(const sivector_slice&);
354 friend srvector diam(const sivector_slice&);
355
356
357 friend class srvector_slice;
358 friend class scvector_slice;
359 friend class scvector;
360 friend class sivector_slice;
361 friend class sivector;
362 friend class scivector_slice;
363 friend class scivector;
364 friend class srmatrix_subv;
365 friend class rvector;
366 friend class rvector_slice;
367 friend class ivector;
368 friend class ivector_slice;
369 friend class cvector;
370 friend class cvector_slice;
371 friend class civector;
372 friend class civector_slice;
373
374
375#include "vector_friend_declarations.inl"
376};
377
378inline rvector::rvector(const srvector& v) {
379 l = v.lb;
380 u = v.ub;
381 size = v.n;
382 dat = new real[v.n];
383 for(int i=0 ; i<v.n ; i++)
384 dat[i] = 0.0;
385 for(int i=0 ; i<v.get_nnz() ; i++)
386 dat[v.p[i]] = v.x[i];
387}
388
390 return fsp_vv_assign<rvector,srvector,real>(*this,v);
391}
392
394 return fsl_vv_assign<rvector,srvector_slice,real>(*this,v);
395}
396
397
399
402inline void SetLb(srvector& v, const int i) {
403 v.lb = i;
404 v.ub = v.lb + v.n - 1;
405}
406
408
411inline void SetUb(srvector& v, const int j) {
412 v.ub = j;
413 v.lb = v.ub - v.n + 1;
414}
415
417inline int Lb(const srvector& v) {
418 return v.lb;
419}
420
422inline int Ub(const srvector& v) {
423 return v.ub;
424}
425
427inline int VecLen(const srvector& v) {
428 return v.n;
429}
430
432inline void Resize(srvector& v) {
433 sp_v_resize(v);
434}
435
437
440inline void Resize(srvector& v, const int n) {
441 sp_v_resize(v,n);
442}
443
445
449inline void Resize(srvector& v, const int l, const int u) {
450 sp_v_resize(v,l,u);
451}
452
454inline srvector operator-(const srvector& v) {
455 return sp_v_negative(v);
456}
457
459
465inline real operator*(const srvector& v1, const rvector& v2) {
466 return spf_vv_mult<srvector,rvector,real,sparse_dot>(v1,v2);
467}
468
470
476inline real operator*(const rvector& v1, const srvector& v2) {
477 return fsp_vv_mult<rvector,srvector,real,sparse_dot>(v1,v2);
478}
479
481
487inline real operator*(const srvector& v1, const rvector_slice& v2) {
488 return spf_vv_mult<srvector,rvector_slice,real,sparse_dot>(v1,v2);
489}
490
492
498inline real operator*(const rvector_slice& v1, const srvector& v2) {
499 return fsp_vv_mult<rvector_slice,srvector,real,sparse_dot>(v1,v2);
500}
501
503
509inline real operator*(const srvector& v1, const srvector& v2) {
510 return spsp_vv_mult<srvector,srvector,real,sparse_dot>(v1,v2);
511}
512
514inline srvector operator*(const srvector& v, const real& s) {
515 return sp_vs_mult<srvector,real,srvector>(v,s);
516}
517
519inline srvector operator/(const srvector& v, const real& s) {
520 return sp_vs_div<srvector,real,srvector>(v,s);
521}
522
524inline srvector operator*(const real& s, const srvector& v) {
525 return sp_sv_mult<real,srvector,srvector>(s,v);
526}
527
529inline rvector operator+(const rvector& v1, const srvector& v2) {
530 return fsp_vv_add<rvector,srvector,rvector>(v1,v2);
531}
532
534inline rvector operator+(const srvector& v1, const rvector& v2) {
535 return spf_vv_add<srvector,rvector,rvector>(v1,v2);
536}
537
539inline rvector operator+(const rvector_slice& v1, const srvector& v2) {
540 return fsp_vv_add<rvector_slice,srvector,rvector>(v1,v2);
541}
542
544inline rvector operator+(const srvector& v1, const rvector_slice& v2) {
545 return spf_vv_add<srvector,rvector_slice,rvector>(v1,v2);
546}
547
549inline srvector operator+(const srvector& v1, const srvector& v2) {
550 return spsp_vv_add<srvector,srvector,srvector,real>(v1,v2);
551}
552
554inline rvector operator-(const rvector& v1, const srvector& v2) {
555 return fsp_vv_sub<rvector,srvector,rvector>(v1,v2);
556}
557
559inline rvector operator-(const srvector& v1, const rvector& v2) {
560 return spf_vv_sub<srvector,rvector,rvector>(v1,v2);
561}
562
564inline rvector operator-(const rvector_slice& v1, const srvector& v2) {
565 return fsp_vv_sub<rvector_slice,srvector,rvector>(v1,v2);
566}
567
569inline rvector operator-(const srvector& v1, const rvector_slice& v2) {
570 return spf_vv_sub<srvector,rvector_slice,rvector>(v1,v2);
571}
572
574inline srvector operator-(const srvector& v1, const srvector& v2) {
575 return spsp_vv_sub<srvector,srvector,srvector,real>(v1,v2);
576}
577
579 return fsp_vv_addassign(*this,v2);
580}
581
583 return fsp_vv_addassign(*this,v2);
584}
585
587 return fsp_vv_subassign(*this,v2);
588}
589
591 return fsp_vv_subassign(*this,v2);
592}
593
595
598inline bool operator==(const srvector& v1, const srvector& v2) {
599 return spsp_vv_comp(v1,v2);
600}
601
603
606inline bool operator==(const srvector& v1, const rvector& v2) {
607 return spf_vv_comp(v1,v2);
608}
609
611
614inline bool operator==(const rvector& v1, const srvector& v2) {
615 return fsp_vv_comp(v1,v2);
616}
617
619
622inline bool operator==(const srvector& v1, const rvector_slice& v2) {
623 return spf_vv_comp(v1,v2);
624}
625
627
630inline bool operator==(const rvector_slice& v1, const srvector& v2) {
631 return fsp_vv_comp(v1,v2);
632}
633
635
638inline bool operator!=(const srvector& v1, const srvector& v2) {
639 return !spsp_vv_comp(v1,v2);
640}
641
643
646inline bool operator!=(const srvector& v1, const rvector& v2) {
647 return !spf_vv_comp(v1,v2);
648}
649
651
654inline bool operator!=(const rvector& v1, const srvector& v2) {
655 return !fsp_vv_comp(v1,v2);
656}
657
659
662inline bool operator!=(const srvector& v1, const rvector_slice& v2) {
663 return !spf_vv_comp(v1,v2);
664}
665
667
670inline bool operator!=(const rvector_slice& v1, const srvector& v2) {
671 return !fsp_vv_comp(v1,v2);
672}
673
675
678inline bool operator<(const srvector& v1, const srvector& v2) {
679 return spsp_vv_less<srvector,srvector,real>(v1,v2);
680}
681
683
686inline bool operator<(const srvector& v1, const rvector& v2) {
687 return spf_vv_less<srvector,rvector,real>(v1,v2);
688}
689
691
694inline bool operator<(const rvector& v1, const srvector& v2) {
695 return fsp_vv_less<rvector,srvector,real>(v1,v2);
696}
697
699
702inline bool operator<(const srvector& v1, const rvector_slice& v2) {
703 return spf_vv_less<srvector,rvector_slice,real>(v1,v2);
704}
705
707
710inline bool operator<(const rvector_slice& v1, const srvector& v2) {
711 return fsp_vv_less<rvector_slice,srvector,real>(v1,v2);
712}
713
715
718inline bool operator<=(const srvector& v1, const srvector& v2) {
719 return spsp_vv_leq<srvector,srvector,real>(v1,v2);
720}
721
723
726inline bool operator<=(const srvector& v1, const rvector& v2) {
727 return spf_vv_leq<srvector,rvector,real>(v1,v2);
728}
729
731
734inline bool operator<=(const rvector& v1, const srvector& v2) {
735 return fsp_vv_leq<rvector,srvector,real>(v1,v2);
736}
737
739
742inline bool operator<=(const srvector& v1, const rvector_slice& v2) {
743 return spf_vv_leq<srvector,rvector_slice,real>(v1,v2);
744}
745
747
750inline bool operator<=(const rvector_slice& v1, const srvector& v2) {
751 return fsp_vv_leq<rvector_slice,srvector,real>(v1,v2);
752}
753
755
758inline bool operator>(const srvector& v1, const srvector& v2) {
759 return spsp_vv_greater<srvector,srvector,real>(v1,v2);
760}
761
763
766inline bool operator>(const srvector& v1, const rvector& v2) {
767 return spf_vv_greater<srvector,rvector,real>(v1,v2);
768}
769
771
774inline bool operator>(const rvector& v1, const srvector& v2) {
775 return fsp_vv_greater<rvector,srvector,real>(v1,v2);
776}
777
779
782inline bool operator>(const srvector& v1, const rvector_slice& v2) {
783 return spf_vv_greater<srvector,rvector_slice,real>(v1,v2);
784}
785
787
790inline bool operator>(const rvector_slice& v1, const srvector& v2) {
791 return fsp_vv_greater<rvector_slice,srvector,real>(v1,v2);
792}
793
795
798inline bool operator>=(const srvector& v1, const srvector& v2) {
799 return spsp_vv_geq<srvector,srvector,real>(v1,v2);
800}
801
803
806inline bool operator>=(const srvector& v1, const rvector& v2) {
807 return spf_vv_geq<srvector,rvector,real>(v1,v2);
808}
809
811
814inline bool operator>=(const rvector& v1, const srvector& v2) {
815 return fsp_vv_geq<rvector,srvector,real>(v1,v2);
816}
817
819
822inline bool operator>=(const srvector& v1, const rvector_slice& v2) {
823 return spf_vv_geq<srvector,rvector_slice,real>(v1,v2);
824}
825
827
830inline bool operator>=(const rvector_slice& v1, const srvector& v2) {
831 return fsp_vv_geq<rvector_slice,srvector,real>(v1,v2);
832}
833
835
838inline bool operator!(const srvector& x) {
839 return sp_v_not(x);
840}
841
843
848inline std::ostream& operator<<(std::ostream& os, const srvector& v) {
849 return sp_v_output<srvector,real>(os,v);
850}
851
853
858inline std::istream& operator>>(std::istream& is, srvector& v) {
859 return sp_v_input<srvector,real>(is,v);
860}
861
863
869 private:
870 std::vector<int>& p;
871 std::vector<real>& x;
872 srvector& orig;
873 int start,end;
874 int lb;
875 int ub;
876 int n;
877 int nnz;
878 int offset;
879
881
885 srvector_slice(srvector& v, int l, int u) : p(v.p), x(v.x), orig(v), lb(l), ub(u), n(u-l+1) {
886 int i;
887
888 for(i=0 ; i<v.get_nnz() && p[i]<lb-v.lb ; i++);
889
890 start = i;
891
892 for(i=start ; i<v.get_nnz() && p[i]<=ub-v.lb ; i++);
893
894 end = i-1;
895
896 nnz = end-start+1;
897 offset = lb-v.lb;
898 }
899
900 public:
902 int get_nnz() const {
903 return nnz;
904 }
906 real density() const {
907 return (double)nnz/n;
908 }
909
911
915 real& operator[](const int i) {
916#if(CXSC_INDEX_CHECK)
917 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector_slice::operator[](const int)"));
918#endif
919 int k;
920
921 for(k=start ; k<end+1 && p[k]-start<=i-lb ; k++) {
922 if(p[k]-offset == i-lb)
923 return x[k];
924 }
925
926 p.insert(p.begin() + k, i-lb);
927 x.insert(x.begin() + k, 0.0);
928 end++;
929
930 return x[k];
931 }
932
934
938 real operator[](const int i) const {
939#if(CXSC_INDEX_CHECK)
940 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector_slice::operator[](const int)"));
941#endif
942 return (*this)(i);
943 }
944
946
950 const real operator()(const int i) const {
951#if(CXSC_INDEX_CHECK)
952 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector_slice::operator()(const int)"));
953#endif
954 real r = 0.0;
955
956 for(int k=start ; k<end && p[k]-start<=i-lb ; k++) {
957 if(p[k]-start == i-lb)
958 r = x[k];
959 }
960
961 return r;
962 }
963
966 return sl_vs_assign<srvector_slice,real,real,std::vector<real>::iterator>(*this,v);
967 }
968
971 return slsl_vv_assign<srvector_slice,srvector_slice,real,std::vector<real>::iterator>(*this,v);
972 }
973
976 return slsp_vv_assign<srvector_slice,srvector,real,std::vector<real>::iterator>(*this,v);
977 }
978
981 return slf_vv_assign<srvector_slice,rvector,real,std::vector<real>::iterator>(*this,v);
982 }
983
986 return slf_vv_assign<srvector_slice,rvector,real,std::vector<real>::iterator>(*this,v);
987 }
988
991 return sl_vs_multassign(*this,s);
992 }
993
996 return sl_vs_divassign(*this,s);
997 }
998
1001 return slf_vv_addassign<srvector_slice,rvector,real>(*this,v);
1002 }
1003
1006 return slf_vv_addassign<srvector_slice,rvector_slice,real>(*this,v);
1007 }
1008
1011 return slsp_vv_addassign(*this,v);
1012 }
1013
1016 return slsl_vv_addassign(*this,v);
1017 }
1018
1021 return slf_vv_subassign<srvector_slice,rvector,real>(*this,v);
1022 }
1023
1026 return slf_vv_subassign<srvector_slice,rvector_slice,real>(*this,v);
1027 }
1028
1031 return slsp_vv_subassign(*this,v);
1032 }
1033
1036 return slsl_vv_subassign(*this,v);
1037 }
1038
1039
1040 friend int Lb(const srvector_slice&);
1041 friend int Ub(const srvector_slice&);
1042 friend int VecLen(const srvector_slice&);
1043
1044 friend srvector operator*(const srmatrix&, const srvector_slice&); //ok
1045 friend srvector operator*(const srmatrix_slice&, const srvector_slice&); //ok
1046
1047 friend class srvector;
1048 friend class scvector;
1049 friend class sivector;
1050 friend class scivector;
1051 friend class srmatrix_subv;
1052 friend class rvector;
1053 friend class rvector_slice;
1054 friend class ivector;
1055 friend class ivector_slice;
1056 friend class cvector;
1057 friend class cvector_slice;
1058 friend class civector;
1059 friend class civector_slice;
1060
1061#include "vector_friend_declarations.inl"
1062};
1063
1065 l = v.lb;
1066 u = v.ub;
1067 size = v.n;
1068 dat = new real[v.n];
1069 for(int i=0 ; i<v.n ; i++)
1070 dat[i] = 0.0;
1071 for(int i=v.start ; i<=v.end ; i++)
1072 dat[v.p[i]] = v.x[i];
1073}
1074
1076 *this = rvector(v);
1077 return *this;
1078}
1079
1081 *this = rvector(v);
1082 return *this;
1083}
1084
1085inline srvector::srvector(const srvector_slice& s) : lb(s.lb), ub(s.ub), n(s.n) {
1086 p.reserve(s.nnz);
1087 x.reserve(s.nnz);
1088
1089 for(int i=s.start ; i<=s.end ; i++) {
1090 p.push_back(s.p[i]-s.offset);
1091 x.push_back(s.x[i]);
1092 }
1093
1094}
1095
1097 return spsl_vv_assign<srvector,srvector_slice,real>(*this,v);
1098}
1099
1100inline srvector_slice srvector::operator()(const int i, const int j) {
1101#if(CXSC_INDEX_CHECK)
1102 if(i<lb || j>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector::operator()(const int,const int)"));
1103#endif
1104 return srvector_slice(*this,i,j);
1105}
1106
1108inline srvector operator-(const srvector_slice& v) {
1109 return sl_v_negative<srvector_slice,srvector>(v);
1110}
1111
1113inline int Lb(const srvector_slice& v) {
1114 return v.lb;
1115}
1116
1118inline int Ub(const srvector_slice& v) {
1119 return v.ub;
1120}
1121
1123inline int VecLen(const srvector_slice& v) {
1124 return v.n;
1125}
1126
1128inline srvector abs(const srvector& v) {
1129 srvector ret(v);
1130 std::vector<real>& x = ret.values();
1131 for(unsigned int i=0 ; i<x.size() ; i++)
1132 x[i] = abs(x[i]);
1133 return ret;
1134}
1135
1137
1143inline real operator*(const srvector_slice& v1, const rvector& v2) {
1144 return slf_vv_mult<srvector_slice,rvector,real,sparse_dot>(v1,v2);
1145}
1146
1148
1153inline real operator*(const rvector& v1, const srvector_slice& v2) {
1154 return fsl_vv_mult<rvector,srvector_slice,real,sparse_dot>(v1,v2);
1155}
1156
1158
1163inline real operator*(const srvector_slice& v1, const rvector_slice& v2) {
1164 return slf_vv_mult<srvector_slice,rvector_slice,real,sparse_dot>(v1,v2);
1165}
1166
1168
1173inline real operator*(const rvector_slice& v1, const srvector_slice& v2) {
1174 return fsl_vv_mult<rvector_slice,srvector_slice,real,sparse_dot>(v1,v2);
1175}
1176
1178
1183inline real operator*(const srvector& v1, const srvector_slice& v2) {
1184 return spsl_vv_mult<srvector,srvector_slice,real,sparse_dot>(v1,v2);
1185}
1186
1188
1193inline real operator*(const srvector_slice& v1, const srvector& v2) {
1194 return slsp_vv_mult<srvector_slice,srvector,real,sparse_dot>(v1,v2);
1195}
1196
1198
1203inline real operator*(const srvector_slice& v1, const srvector_slice& v2) {
1204 return slsl_vv_mult<srvector_slice,srvector_slice,real,sparse_dot>(v1,v2);
1205}
1206
1208inline srvector operator*(const srvector_slice& v, const real& s) {
1209 return sp_vs_mult<srvector_slice,real,srvector>(v,s);
1210}
1211
1213inline srvector operator/(const srvector_slice& v, const real& s) {
1214 return sp_vs_div<srvector_slice,real,srvector>(v,s);
1215}
1216
1218inline srvector operator*(const real& s, const srvector_slice& v) {
1219 return sp_sv_mult<real,srvector_slice,srvector>(s,v);
1220}
1221
1223inline rvector operator+(const rvector& v1, const srvector_slice& v2) {
1224 return fsl_vv_add<rvector,srvector_slice,rvector>(v1,v2);
1225}
1226
1228inline rvector operator+(const srvector_slice& v1, const rvector& v2) {
1229 return slf_vv_add<srvector_slice,rvector,rvector>(v1,v2);
1230}
1231
1233inline rvector operator+(const rvector_slice& v1, const srvector_slice& v2) {
1234 return fsl_vv_add<rvector_slice,srvector_slice,rvector>(v1,v2);
1235}
1236
1238inline rvector operator+(const srvector_slice& v1, const rvector_slice& v2) {
1239 return slf_vv_add<srvector_slice,rvector_slice,rvector>(v1,v2);
1240}
1241
1243inline srvector operator+(const srvector_slice& v1, const srvector_slice& v2) {
1244 return slsl_vv_add<srvector_slice,srvector_slice,srvector,real>(v1,v2);
1245}
1246
1248inline srvector operator+(const srvector& v1, const srvector_slice& v2) {
1249 return spsl_vv_add<srvector,srvector_slice,srvector,real>(v1,v2);
1250}
1251
1253inline srvector operator+(const srvector_slice& v1, const srvector& v2) {
1254 return slsp_vv_add<srvector_slice,srvector,srvector,real>(v1,v2);
1255}
1256
1258inline rvector operator-(const rvector& v1, const srvector_slice& v2) {
1259 return fsl_vv_sub<rvector,srvector_slice,rvector>(v1,v2);
1260}
1261
1263inline rvector operator-(const srvector_slice& v1, const rvector& v2) {
1264 return slf_vv_sub<srvector_slice,rvector,rvector>(v1,v2);
1265}
1266
1268inline rvector operator-(const rvector_slice& v1, const srvector_slice& v2) {
1269 return fsl_vv_sub<rvector_slice,srvector_slice,rvector>(v1,v2);
1270}
1271
1273inline rvector operator-(const srvector_slice& v1, const rvector_slice& v2) {
1274 return slf_vv_sub<srvector_slice,rvector_slice,rvector>(v1,v2);
1275}
1276
1278inline srvector operator-(const srvector_slice& v1, const srvector_slice& v2) {
1279 return slsl_vv_sub<srvector_slice,srvector_slice,srvector,real>(v1,v2);
1280}
1281
1283inline srvector operator-(const srvector& v1, const srvector_slice& v2) {
1284 return spsl_vv_sub<srvector,srvector_slice,srvector,real>(v1,v2);
1285}
1286
1288inline srvector operator-(const srvector_slice& v1, const srvector& v2) {
1289 return slsp_vv_sub<srvector_slice,srvector,srvector,real>(v1,v2);
1290}
1291
1293 return fsl_vv_addassign(*this,v2);
1294}
1295
1297 return fsl_vv_addassign(*this,v2);
1298}
1299
1301 return spsl_vv_addassign(*this,v2);
1302}
1303
1305 return fsl_vv_subassign(*this,v2);
1306}
1307
1309 return fsl_vv_subassign(*this,v2);
1310}
1311
1313 return spsl_vv_subassign(*this,v2);
1314}
1315
1317
1320inline bool operator==(const srvector_slice& v1, const srvector_slice& v2) {
1321 return slsl_vv_comp(v1,v2);
1322}
1323
1325
1328inline bool operator==(const srvector_slice& v1, const srvector& v2) {
1329 return slsp_vv_comp(v1,v2);
1330}
1331
1333
1336inline bool operator==(const srvector& v1, const srvector_slice& v2) {
1337 return spsl_vv_comp(v1,v2);
1338}
1339
1341
1344inline bool operator==(const srvector_slice& v1, const rvector& v2) {
1345 return slf_vv_comp(v1,v2);
1346}
1347
1349
1352inline bool operator==(const rvector& v1, const srvector_slice& v2) {
1353 return fsl_vv_comp(v1,v2);
1354}
1355
1357
1360inline bool operator==(const srvector_slice& v1, const rvector_slice& v2) {
1361 return slf_vv_comp(v1,v2);
1362}
1363
1365
1368inline bool operator==(const rvector_slice& v1, const srvector_slice& v2) {
1369 return fsl_vv_comp(v1,v2);
1370}
1371
1373
1376inline bool operator!=(const srvector_slice& v1, const srvector_slice& v2) {
1377 return !slsl_vv_comp(v1,v2);
1378}
1379
1381
1384inline bool operator!=(const srvector_slice& v1, const rvector& v2) {
1385 return !slf_vv_comp(v1,v2);
1386}
1387
1389
1392inline bool operator!=(const rvector& v1, const srvector_slice& v2) {
1393 return !fsl_vv_comp(v1,v2);
1394}
1395
1397
1400inline bool operator!=(const srvector_slice& v1, const srvector& v2) {
1401 return !slsp_vv_comp(v1,v2);
1402}
1403
1405
1408inline bool operator!=(const srvector& v1, const srvector_slice& v2) {
1409 return !spsl_vv_comp(v1,v2);
1410}
1411
1413
1416inline bool operator!=(const srvector_slice& v1, const rvector_slice& v2) {
1417 return !slf_vv_comp(v1,v2);
1418}
1419
1421
1424inline bool operator!=(const rvector_slice& v1, const srvector_slice& v2) {
1425 return !fsl_vv_comp(v1,v2);
1426}
1427
1429
1432inline bool operator<(const srvector_slice& v1, const srvector_slice& v2) {
1433 return slsl_vv_less<srvector_slice,srvector_slice,real>(v1,v2);
1434}
1435
1437
1440inline bool operator<(const srvector_slice& v1, const srvector& v2) {
1441 return slsp_vv_less<srvector_slice,srvector,real>(v1,v2);
1442}
1443
1445
1448inline bool operator<(const srvector& v1, const srvector_slice& v2) {
1449 return spsl_vv_less<srvector,srvector_slice,real>(v1,v2);
1450}
1451
1453
1456inline bool operator<(const srvector_slice& v1, const rvector& v2) {
1457 return slf_vv_less<srvector_slice,rvector,real>(v1,v2);
1458}
1459
1461
1464inline bool operator<(const rvector& v1, const srvector_slice& v2) {
1465 return fsl_vv_less<rvector,srvector_slice,real>(v1,v2);
1466}
1467
1469
1472inline bool operator<(const srvector_slice& v1, const rvector_slice& v2) {
1473 return slf_vv_less<srvector_slice,rvector_slice,real>(v1,v2);
1474}
1475
1477
1480inline bool operator<(const rvector_slice& v1, const srvector_slice& v2) {
1481 return fsl_vv_less<rvector_slice,srvector_slice,real>(v1,v2);
1482}
1483
1485
1488inline bool operator<=(const srvector_slice& v1, const srvector_slice& v2) {
1489 return slsl_vv_leq<srvector_slice,srvector_slice,real>(v1,v2);
1490}
1491
1493
1496inline bool operator<=(const srvector_slice& v1, const srvector& v2) {
1497 return slsp_vv_leq<srvector_slice,srvector,real>(v1,v2);
1498}
1499
1501
1504inline bool operator<=(const srvector& v1, const srvector_slice& v2) {
1505 return spsl_vv_leq<srvector,srvector_slice,real>(v1,v2);
1506}
1507
1509
1512inline bool operator<=(const srvector_slice& v1, const rvector& v2) {
1513 return slf_vv_leq<srvector_slice,rvector,real>(v1,v2);
1514}
1515
1517
1520inline bool operator<=(const rvector& v1, const srvector_slice& v2) {
1521 return fsl_vv_leq<rvector,srvector_slice,real>(v1,v2);
1522}
1523
1525
1528inline bool operator<=(const srvector_slice& v1, const rvector_slice& v2) {
1529 return slf_vv_leq<srvector_slice,rvector_slice,real>(v1,v2);
1530}
1531
1533
1536inline bool operator<=(const rvector_slice& v1, const srvector_slice& v2) {
1537 return fsl_vv_leq<rvector_slice,srvector_slice,real>(v1,v2);
1538}
1539
1541
1544inline bool operator>(const srvector_slice& v1, const srvector_slice& v2) {
1545 return slsl_vv_greater<srvector_slice,srvector_slice,real>(v1,v2);
1546}
1547
1549
1552inline bool operator>(const srvector_slice& v1, const srvector& v2) {
1553 return slsp_vv_greater<srvector_slice,srvector,real>(v1,v2);
1554}
1555
1557
1560inline bool operator>(const srvector& v1, const srvector_slice& v2) {
1561 return spsl_vv_greater<srvector,srvector_slice,real>(v1,v2);
1562}
1563
1565
1568inline bool operator>(const srvector_slice& v1, const rvector& v2) {
1569 return slf_vv_greater<srvector_slice,rvector,real>(v1,v2);
1570}
1571
1573
1576inline bool operator>(const rvector& v1, const srvector_slice& v2) {
1577 return fsl_vv_greater<rvector,srvector_slice,real>(v1,v2);
1578}
1579
1581
1584inline bool operator>(const srvector_slice& v1, const rvector_slice& v2) {
1585 return slf_vv_greater<srvector_slice,rvector_slice,real>(v1,v2);
1586}
1587
1589
1592inline bool operator>(const rvector_slice& v1, const srvector_slice& v2) {
1593 return fsl_vv_greater<rvector_slice,srvector_slice,real>(v1,v2);
1594}
1595
1597
1600inline bool operator>=(const srvector_slice& v1, const srvector_slice& v2) {
1601 return slsl_vv_geq<srvector_slice,srvector_slice,real>(v1,v2);
1602}
1603
1605
1608inline bool operator>=(const srvector_slice& v1, const srvector& v2) {
1609 return slsp_vv_geq<srvector_slice,srvector,real>(v1,v2);
1610}
1611
1613
1616inline bool operator>=(const srvector& v1, const srvector_slice& v2) {
1617 return spsl_vv_geq<srvector,srvector_slice,real>(v1,v2);
1618}
1619
1621
1624inline bool operator>=(const srvector_slice& v1, const rvector& v2) {
1625 return slf_vv_geq<srvector_slice,rvector,real>(v1,v2);
1626}
1627
1629
1632inline bool operator>=(const rvector& v1, const srvector_slice& v2) {
1633 return fsl_vv_geq<rvector,srvector_slice,real>(v1,v2);
1634}
1635
1637
1640inline bool operator>=(const srvector_slice& v1, const rvector_slice& v2) {
1641 return slf_vv_geq<srvector_slice,rvector_slice,real>(v1,v2);
1642}
1643
1645
1648inline bool operator>=(const rvector_slice& v1, const srvector_slice& v2) {
1649 return fsl_vv_geq<rvector_slice,srvector_slice,real>(v1,v2);
1650}
1651
1653
1656inline bool operator!(const srvector_slice& x) {
1657 return sl_v_not(x);
1658}
1659
1661
1666inline std::ostream& operator<<(std::ostream& os, const srvector_slice& v) {
1667 return sl_v_output<srvector_slice, real>(os,v);
1668}
1669
1671
1676inline std::istream& operator>>(std::istream& is, srvector_slice& v) {
1677 return sl_v_input<srvector_slice, real>(is,v);
1678}
1679
1681
1684inline void accumulate(dotprecision& dot, const srvector& x, const srvector& y) {
1685 spsp_vv_accu<dotprecision,srvector,srvector,sparse_dot>(dot,x,y);
1686}
1687
1689
1692inline void accumulate(dotprecision& dot, const srvector& x, const rvector& y) {
1693 spf_vv_accu<dotprecision,srvector,rvector,sparse_dot>(dot,x,y);
1694}
1695
1697
1700inline void accumulate(dotprecision& dot, const srvector& x, const rvector_slice& y) {
1701 spf_vv_accu<dotprecision,srvector,rvector_slice,sparse_dot>(dot,x,y);
1702}
1703
1705
1708inline void accumulate(dotprecision& dot, const rvector& x, const srvector& y) {
1709 fsp_vv_accu<dotprecision,rvector,srvector,sparse_dot>(dot,x,y);
1710}
1711
1713
1716inline void accumulate(dotprecision& dot, const rvector_slice& x, const srvector& y) {
1717 fsp_vv_accu<dotprecision,rvector_slice,srvector,sparse_dot>(dot,x,y);
1718}
1719
1721
1724inline void accumulate(dotprecision& dot, const srvector_slice& x, const rvector& y) {
1725 slf_vv_accu<dotprecision,srvector_slice,rvector,sparse_dot>(dot,x,y);
1726}
1727
1729
1732inline void accumulate(dotprecision& dot, const srvector_slice& x, const rvector_slice& y) {
1733 slf_vv_accu<dotprecision,srvector_slice,rvector_slice,sparse_dot>(dot,x,y);
1734}
1735
1737
1740inline void accumulate(dotprecision& dot, const rvector& x, const srvector_slice& y) {
1741 fsl_vv_accu<dotprecision,rvector,srvector_slice,sparse_dot>(dot,x,y);
1742}
1743
1745
1748inline void accumulate(dotprecision& dot, const rvector_slice& x, const srvector_slice& y) {
1749 fsl_vv_accu<dotprecision,rvector_slice,srvector_slice,sparse_dot>(dot,x,y);
1750}
1751
1753
1756inline void accumulate(dotprecision& dot, const srvector_slice& x, const srvector_slice& y) {
1757 slsl_vv_accu<dotprecision,srvector_slice,srvector_slice,sparse_dot>(dot,x,y);
1758}
1759
1761
1764inline void accumulate(dotprecision& dot, const srvector& x, const srvector_slice& y) {
1765 spsl_vv_accu<dotprecision,srvector,srvector_slice,sparse_dot>(dot,x,y);
1766}
1767
1769
1772inline void accumulate(dotprecision& dot, const srvector_slice& x, const srvector& y) {
1773 slsp_vv_accu<dotprecision,srvector_slice,srvector,sparse_dot>(dot,x,y);
1774}
1775
1777
1781inline void accumulate_approx(dotprecision& dot, const srvector& x, const srvector& y) {
1782 spsp_vv_accuapprox<dotprecision,srvector,srvector,sparse_dot>(dot,x,y);
1783}
1784
1786
1790inline void accumulate_approx(dotprecision& dot, const srvector& x, const rvector& y) {
1791 spf_vv_accuapprox<dotprecision,srvector,rvector,sparse_dot>(dot,x,y);
1792}
1793
1795
1799inline void accumulate_approx(dotprecision& dot, const srvector& x, const rvector_slice& y) {
1800 spf_vv_accuapprox<dotprecision,srvector,rvector_slice,sparse_dot>(dot,x,y);
1801}
1802
1804
1808inline void accumulate_approx(dotprecision& dot, const rvector& x, const srvector& y) {
1809 fsp_vv_accuapprox<dotprecision,rvector,srvector,sparse_dot>(dot,x,y);
1810}
1811
1813
1817inline void accumulate_approx(dotprecision& dot, const rvector_slice& x, const srvector& y) {
1818 fsp_vv_accuapprox<dotprecision,rvector_slice,srvector,sparse_dot>(dot,x,y);
1819}
1820
1822
1826inline void accumulate_approx(dotprecision& dot, const srvector_slice& x, const rvector& y) {
1827 slf_vv_accuapprox<dotprecision,srvector_slice,rvector,sparse_dot>(dot,x,y);
1828}
1829
1831
1835inline void accumulate_approx(dotprecision& dot, const srvector_slice& x, const rvector_slice& y) {
1836 slf_vv_accuapprox<dotprecision,srvector_slice,rvector_slice,sparse_dot>(dot,x,y);
1837}
1838
1840
1844inline void accumulate_approx(dotprecision& dot, const rvector& x, const srvector_slice& y) {
1845 fsl_vv_accuapprox<dotprecision,rvector,srvector_slice,sparse_dot>(dot,x,y);
1846}
1847
1849
1853inline void accumulate_approx(dotprecision& dot, const rvector_slice& x, const srvector_slice& y) {
1854 fsl_vv_accuapprox<dotprecision,rvector_slice,srvector_slice,sparse_dot>(dot,x,y);
1855}
1856
1858
1862inline void accumulate_approx(dotprecision& dot, const srvector_slice& x, const srvector_slice& y) {
1863 slsl_vv_accuapprox<dotprecision,srvector_slice,srvector_slice,sparse_dot>(dot,x,y);
1864}
1865
1867
1871inline void accumulate_approx(dotprecision& dot, const srvector& x, const srvector_slice& y) {
1872 spsl_vv_accuapprox<dotprecision,srvector,srvector_slice,sparse_dot>(dot,x,y);
1873}
1874
1876
1880inline void accumulate_approx(dotprecision& dot, const srvector_slice& x, const srvector& y) {
1881 slsp_vv_accuapprox<dotprecision,srvector_slice,srvector,sparse_dot>(dot,x,y);
1882}
1883
1885
1888inline void accumulate(idotprecision& dot, const srvector& x, const srvector& y) {
1889 dotprecision tmp(0.0);
1890 tmp.set_k(dot.get_k());
1891 accumulate(tmp,x,y);
1892 dot += tmp;
1893}
1894
1896
1899inline void accumulate(idotprecision& dot, const srvector& x, const rvector& y) {
1900 dotprecision tmp(0.0);
1901 tmp.set_k(dot.get_k());
1902 accumulate(tmp,x,y);
1903 dot += tmp;
1904}
1905
1907
1910inline void accumulate(idotprecision& dot, const srvector& x, const rvector_slice& y) {
1911 dotprecision tmp(0.0);
1912 tmp.set_k(dot.get_k());
1913 accumulate(tmp,x,y);
1914 dot += tmp;
1915}
1916
1918
1921inline void accumulate(idotprecision& dot, const rvector& x, const srvector& y) {
1922 dotprecision tmp(0.0);
1923 tmp.set_k(dot.get_k());
1924 accumulate(tmp,x,y);
1925 dot += tmp;
1926}
1927
1929
1932inline void accumulate(idotprecision& dot, const rvector_slice& x, const srvector& y) {
1933 dotprecision tmp(0.0);
1934 tmp.set_k(dot.get_k());
1935 accumulate(tmp,x,y);
1936 dot += tmp;
1937}
1938
1940
1943inline void accumulate(idotprecision& dot, const srvector_slice& x, const rvector& y) {
1944 dotprecision tmp(0.0);
1945 tmp.set_k(dot.get_k());
1946 accumulate(tmp,x,y);
1947 dot += tmp;
1948}
1949
1951
1954inline void accumulate(idotprecision& dot, const srvector_slice& x, const rvector_slice& y) {
1955 dotprecision tmp(0.0);
1956 tmp.set_k(dot.get_k());
1957 accumulate(tmp,x,y);
1958 dot += tmp;
1959}
1960
1962
1965inline void accumulate(idotprecision& dot, const rvector& x, const srvector_slice& y) {
1966 dotprecision tmp(0.0);
1967 tmp.set_k(dot.get_k());
1968 accumulate(tmp,x,y);
1969 dot += tmp;
1970}
1971
1973
1976inline void accumulate(idotprecision& dot, const rvector_slice& x, const srvector_slice& y) {
1977 dotprecision tmp(0.0);
1978 tmp.set_k(dot.get_k());
1979 accumulate(tmp,x,y);
1980 dot += tmp;
1981}
1982
1984
1987inline void accumulate(idotprecision& dot, const srvector_slice& x, const srvector_slice& y) {
1988 dotprecision tmp(0.0);
1989 tmp.set_k(dot.get_k());
1990 accumulate(tmp,x,y);
1991 dot += tmp;
1992}
1993
1995
1998inline void accumulate(idotprecision& dot, const srvector& x, const srvector_slice& y) {
1999 dotprecision tmp(0.0);
2000 tmp.set_k(dot.get_k());
2001 accumulate(tmp,x,y);
2002 dot += tmp;
2003}
2004
2006
2009inline void accumulate(idotprecision& dot, const srvector_slice& x, const srvector& y) {
2010 dotprecision tmp(0.0);
2011 tmp.set_k(dot.get_k());
2012 accumulate(tmp,x,y);
2013 dot += tmp;
2014}
2015
2017
2020inline void accumulate(cdotprecision& dot, const srvector& x, const srvector& y) {
2021 dotprecision tmp(0.0);
2022 tmp.set_k(dot.get_k());
2023 accumulate(tmp,x,y);
2024 dot += tmp;
2025}
2026
2028
2031inline void accumulate(cdotprecision& dot, const srvector& x, const rvector& y) {
2032 dotprecision tmp(0.0);
2033 tmp.set_k(dot.get_k());
2034 accumulate(tmp,x,y);
2035 dot += tmp;
2036}
2037
2039
2042inline void accumulate(cdotprecision& dot, const srvector& x, const rvector_slice& y) {
2043 dotprecision tmp(0.0);
2044 tmp.set_k(dot.get_k());
2045 accumulate(tmp,x,y);
2046 dot += tmp;
2047}
2048
2050
2053inline void accumulate(cdotprecision& dot, const rvector& x, const srvector& y) {
2054 dotprecision tmp(0.0);
2055 tmp.set_k(dot.get_k());
2056 accumulate(tmp,x,y);
2057 dot += tmp;
2058}
2059
2061
2064inline void accumulate(cdotprecision& dot, const rvector_slice& x, const srvector& y) {
2065 dotprecision tmp(0.0);
2066 tmp.set_k(dot.get_k());
2067 accumulate(tmp,x,y);
2068 dot += tmp;
2069}
2070
2072
2075inline void accumulate(cdotprecision& dot, const srvector_slice& x, const rvector& y) {
2076 dotprecision tmp(0.0);
2077 tmp.set_k(dot.get_k());
2078 accumulate(tmp,x,y);
2079 dot += tmp;
2080}
2081
2083
2086inline void accumulate(cdotprecision& dot, const srvector_slice& x, const rvector_slice& y) {
2087 dotprecision tmp(0.0);
2088 tmp.set_k(dot.get_k());
2089 accumulate(tmp,x,y);
2090 dot += tmp;
2091}
2092
2094
2097inline void accumulate(cdotprecision& dot, const rvector& x, const srvector_slice& y) {
2098 dotprecision tmp(0.0);
2099 tmp.set_k(dot.get_k());
2100 accumulate(tmp,x,y);
2101 dot += tmp;
2102}
2103
2105
2108inline void accumulate(cdotprecision& dot, const rvector_slice& x, const srvector_slice& y) {
2109 dotprecision tmp(0.0);
2110 tmp.set_k(dot.get_k());
2111 accumulate(tmp,x,y);
2112 dot += tmp;
2113}
2114
2116
2119inline void accumulate(cdotprecision& dot, const srvector_slice& x, const srvector_slice& y) {
2120 dotprecision tmp(0.0);
2121 tmp.set_k(dot.get_k());
2122 accumulate(tmp,x,y);
2123 dot += tmp;
2124}
2125
2127
2130inline void accumulate(cdotprecision& dot, const srvector& x, const srvector_slice& y) {
2131 dotprecision tmp(0.0);
2132 tmp.set_k(dot.get_k());
2133 accumulate(tmp,x,y);
2134 dot += tmp;
2135}
2136
2138
2141inline void accumulate(cdotprecision& dot, const srvector_slice& x, const srvector& y) {
2142 dotprecision tmp(0.0);
2143 tmp.set_k(dot.get_k());
2144 accumulate(tmp,x,y);
2145 dot += tmp;
2146}
2147
2149
2153inline void accumulate_approx(cdotprecision& dot, const srvector& x, const srvector& y) {
2154 dotprecision tmp(0.0);
2155 tmp.set_k(dot.get_k());
2156 accumulate_approx(tmp,x,y);
2157 dot += tmp;
2158}
2159
2161
2165inline void accumulate_approx(cdotprecision& dot, const srvector& x, const rvector& y) {
2166 dotprecision tmp(0.0);
2167 tmp.set_k(dot.get_k());
2168 accumulate_approx(tmp,x,y);
2169 dot += tmp;
2170}
2171
2173
2177inline void accumulate_approx(cdotprecision& dot, const srvector& x, const rvector_slice& y) {
2178 dotprecision tmp(0.0);
2179 tmp.set_k(dot.get_k());
2180 accumulate_approx(tmp,x,y);
2181 dot += tmp;
2182}
2183
2185
2189inline void accumulate_approx(cdotprecision& dot, const rvector& x, const srvector& y) {
2190 dotprecision tmp(0.0);
2191 tmp.set_k(dot.get_k());
2192 accumulate_approx(tmp,x,y);
2193 dot += tmp;
2194}
2195
2197
2201inline void accumulate_approx(cdotprecision& dot, const rvector_slice& x, const srvector& y) {
2202 dotprecision tmp(0.0);
2203 tmp.set_k(dot.get_k());
2204 accumulate_approx(tmp,x,y);
2205 dot += tmp;
2206}
2207
2209
2213inline void accumulate_approx(cdotprecision& dot, const srvector_slice& x, const rvector& y) {
2214 dotprecision tmp(0.0);
2215 tmp.set_k(dot.get_k());
2216 accumulate_approx(tmp,x,y);
2217 dot += tmp;
2218}
2219
2221
2225inline void accumulate_approx(cdotprecision& dot, const srvector_slice& x, const rvector_slice& y) {
2226 dotprecision tmp(0.0);
2227 tmp.set_k(dot.get_k());
2228 accumulate_approx(tmp,x,y);
2229 dot += tmp;
2230}
2231
2233
2237inline void accumulate_approx(cdotprecision& dot, const rvector& x, const srvector_slice& y) {
2238 dotprecision tmp(0.0);
2239 tmp.set_k(dot.get_k());
2240 accumulate_approx(tmp,x,y);
2241 dot += tmp;
2242}
2243
2245
2249inline void accumulate_approx(cdotprecision& dot, const rvector_slice& x, const srvector_slice& y) {
2250 dotprecision tmp(0.0);
2251 tmp.set_k(dot.get_k());
2252 accumulate_approx(tmp,x,y);
2253 dot += tmp;
2254}
2255
2257
2261inline void accumulate_approx(cdotprecision& dot, const srvector_slice& x, const srvector_slice& y) {
2262 dotprecision tmp(0.0);
2263 tmp.set_k(dot.get_k());
2264 accumulate_approx(tmp,x,y);
2265 dot += tmp;
2266}
2267
2269
2273inline void accumulate_approx(cdotprecision& dot, const srvector& x, const srvector_slice& y) {
2274 dotprecision tmp(0.0);
2275 tmp.set_k(dot.get_k());
2276 accumulate_approx(tmp,x,y);
2277 dot += tmp;
2278}
2279
2281
2285inline void accumulate_approx(cdotprecision& dot, const srvector_slice& x, const srvector& y) {
2286 dotprecision tmp(0.0);
2287 tmp.set_k(dot.get_k());
2288 accumulate_approx(tmp,x,y);
2289 dot += tmp;
2290}
2291
2293
2296inline void accumulate(cidotprecision& dot, const srvector& x, const srvector& y) {
2297 dotprecision tmp(0.0);
2298 tmp.set_k(dot.get_k());
2299 accumulate(tmp,x,y);
2300 dot += tmp;
2301}
2302
2304
2307inline void accumulate(cidotprecision& dot, const srvector& x, const rvector& y) {
2308 dotprecision tmp(0.0);
2309 tmp.set_k(dot.get_k());
2310 accumulate(tmp,x,y);
2311 dot += tmp;
2312}
2313
2315
2318inline void accumulate(cidotprecision& dot, const srvector& x, const rvector_slice& y) {
2319 dotprecision tmp(0.0);
2320 tmp.set_k(dot.get_k());
2321 accumulate(tmp,x,y);
2322 dot += tmp;
2323}
2324
2326
2329inline void accumulate(cidotprecision& dot, const rvector& x, const srvector& y) {
2330 dotprecision tmp(0.0);
2331 tmp.set_k(dot.get_k());
2332 accumulate(tmp,x,y);
2333 dot += tmp;
2334}
2335
2337
2340inline void accumulate(cidotprecision& dot, const rvector_slice& x, const srvector& y) {
2341 dotprecision tmp(0.0);
2342 tmp.set_k(dot.get_k());
2343 accumulate(tmp,x,y);
2344 dot += tmp;
2345}
2346
2348
2351inline void accumulate(cidotprecision& dot, const srvector_slice& x, const rvector& y) {
2352 dotprecision tmp(0.0);
2353 tmp.set_k(dot.get_k());
2354 accumulate(tmp,x,y);
2355 dot += tmp;
2356}
2357
2359
2362inline void accumulate(cidotprecision& dot, const srvector_slice& x, const rvector_slice& y) {
2363 dotprecision tmp(0.0);
2364 tmp.set_k(dot.get_k());
2365 accumulate(tmp,x,y);
2366 dot += tmp;
2367}
2368
2370
2373inline void accumulate(cidotprecision& dot, const rvector& x, const srvector_slice& y) {
2374 dotprecision tmp(0.0);
2375 tmp.set_k(dot.get_k());
2376 accumulate(tmp,x,y);
2377 dot += tmp;
2378}
2379
2381
2384inline void accumulate(cidotprecision& dot, const rvector_slice& x, const srvector_slice& y) {
2385 dotprecision tmp(0.0);
2386 tmp.set_k(dot.get_k());
2387 accumulate(tmp,x,y);
2388 dot += tmp;
2389}
2390
2392
2395inline void accumulate(cidotprecision& dot, const srvector_slice& x, const srvector_slice& y) {
2396 dotprecision tmp(0.0);
2397 tmp.set_k(dot.get_k());
2398 accumulate(tmp,x,y);
2399 dot += tmp;
2400}
2401
2403
2406inline void accumulate(cidotprecision& dot, const srvector& x, const srvector_slice& y) {
2407 dotprecision tmp(0.0);
2408 tmp.set_k(dot.get_k());
2409 accumulate(tmp,x,y);
2410 dot += tmp;
2411}
2412
2414
2417inline void accumulate(cidotprecision& dot, const srvector_slice& x, const srvector& y) {
2418 dotprecision tmp(0.0);
2419 tmp.set_k(dot.get_k());
2420 accumulate(tmp,x,y);
2421 dot += tmp;
2422}
2423
2424
2425} //namespace cxsc
2426
2427#include "sparsevector.inl"
2428
2429#endif
The Data Type cdotprecision.
Definition cdot.hpp:61
int get_k() const
Get currently set precision for computation of dot products.
Definition cdot.hpp:91
The Data Type cidotprecision.
Definition cidot.hpp:58
int get_k() const
Get currently set precision for computation of dot products.
Definition cidot.hpp:89
The Data Type civector_slice.
The Data Type civector.
Definition civector.hpp:57
The Data Type cvector_slice.
Definition cvector.hpp:845
The Data Type cvector.
Definition cvector.hpp:58
The Data Type dotprecision.
Definition dot.hpp:112
void set_k(unsigned int i)
Set precision for computation of dot products.
Definition dot.hpp:131
The Data Type idotprecision.
Definition idot.hpp:48
int get_k() const
Get currently set precision for computation of dot products.
Definition idot.hpp:86
The Data Type intmatrix.
The Data Type intvector.
Definition intvector.hpp:52
The Data Type ivector_slice.
Definition ivector.hpp:963
The Data Type ivector.
Definition ivector.hpp:55
The Scalar Type real.
Definition real.hpp:114
The Data Type rvector_slice.
Definition rvector.hpp:1064
rvector_slice & operator+=(const rvector &rv) noexcept
Implementation of addition and allocation operation.
Definition rvector.inl:397
rvector_slice & operator-=(const rvector &rv) noexcept
Implementation of subtraction and allocation operation.
Definition rvector.inl:456
rvector_slice & operator=(const rvector_slice &sl) noexcept
Implementation of standard assigning operator.
Definition rvector.inl:258
The Data Type rvector.
Definition rvector.hpp:58
rvector & operator-=(const srvector &rv)
Implementation of addition and allocation operation.
Definition srvector.hpp:586
rvector & operator+=(const srvector &rv)
Implementation of addition and allocation operation.
Definition srvector.hpp:578
rvector & operator=(const rvector &rv) noexcept
Implementation of standard assigning operator.
Definition rvector.inl:254
rvector() noexcept
Constructor of class rvector.
Definition rvector.inl:37
Helper class for slices of sparse vectors.
A sparse complex interval vector.
Definition scivector.hpp:62
Helper class for slices of sparse vectors.
A sparse complex vector.
Definition scvector.hpp:58
Helper class for slices of sparse vectors.
A sparse interval vector.
Definition sivector.hpp:59
A slice of a sparse real matrix.
Represents a row or column vector of a sparse matrix.
A sparse real matrix.
Definition srmatrix.hpp:77
Helper class for slices of sparse vectors.
Definition srvector.hpp:868
srvector_slice & operator-=(const srvector_slice &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
srvector_slice & operator-=(const rvector_slice &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
srvector_slice & operator=(const real &v)
Assigns v to all elements of the vector slice.
Definition srvector.hpp:965
srvector_slice & operator-=(const rvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
const real operator()(const int i) const
Returns a copy of the i-th (according to the currently used indexing) element of the vector slice.
Definition srvector.hpp:950
srvector_slice & operator-=(const srvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector slice.
friend int VecLen(const srvector_slice &)
Returns the length of the vector slice.
real & operator[](const int i)
Returns a reference to the i-th (according to the currently used indexing) element of the vector slic...
Definition srvector.hpp:915
srvector_slice & operator=(const srvector &v)
Overwrite the vector slice with the elements of v.
Definition srvector.hpp:975
friend int Ub(const srvector_slice &)
Returns the upper index bound of the vector slice v.
srvector_slice & operator=(const srvector_slice &v)
Overwrite the vector slice with the elements of v.
Definition srvector.hpp:970
friend int Lb(const srvector_slice &)
Returns the lower index bound of the vector slice v.
srvector_slice & operator=(const rvector &v)
Overwrite the vector slice with the elements of v.
Definition srvector.hpp:980
srvector_slice & operator+=(const srvector_slice &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
srvector_slice & operator/=(const real &s)
Operator for division of each element of the vector slice with a scalar, result is assigned to the ve...
Definition srvector.hpp:995
srvector_slice & operator+=(const rvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
srvector_slice & operator+=(const srvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
friend srvector operator*(const srmatrix &, const srvector_slice &)
Returns the product of the matrix A and the vector v.
srvector_slice & operator+=(const rvector_slice &v)
Operator for element-wise addition with a vector, result is assigned to the vector slice.
real density() const
Returns the density of the vector slice (the number of non zero elements divided by the number of ele...
Definition srvector.hpp:906
int get_nnz() const
Returns the number of non zero elements of this vector slice (note that this includes explicitly stor...
Definition srvector.hpp:902
srvector_slice & operator=(const rvector_slice &v)
Overwrite the vector slice with the elements of v.
Definition srvector.hpp:985
srvector_slice & operator*=(const real &s)
Operator for multiplication with a scalar, result is assigned to the vector slice.
Definition srvector.hpp:990
real operator[](const int i) const
Returns a copy of the i-th (according to the currently used indexing) element of the vector slice.
Definition srvector.hpp:938
A sparse real vector.
Definition srvector.hpp:58
srvector(const rvector &v)
Constructor for creating a sparse vector our of a dense vector v. Only the non-zero elements of v are...
Definition srvector.hpp:84
friend void SetUb(srvector &, const int)
Sets the upper index bound of the vector v to i.
Definition srvector.hpp:411
srvector & operator+=(const rvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector.
Definition srvector.hpp:298
friend srvector Inf(const sivector &)
Returns the infimum of the interval vector as a new sparse point vector.
Definition sivector.hpp:593
real density() const
Returns the density of the vector (the number of non zero elements divided by the number of elements)
Definition srvector.hpp:165
srvector & operator-=(const rvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector.
Definition srvector.hpp:317
friend srvector Re(const scvector &)
Returns the real part of the complex vector v.
Definition scvector.hpp:517
friend srvector Sup(const sivector &)
Returns the supremum of the interval vector as a new sparse point vector.
Definition sivector.hpp:604
srvector & operator=(const real &v)
Assigns v to all elements of the vector (resulting in a dense vector!)
Definition srvector.hpp:180
srvector & operator-=(const rvector_slice &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector.
Definition srvector.hpp:322
std::vector< real > & values()
Returns a reference to the STL-vector storing the values of the non zero elements.
Definition srvector.hpp:136
void dropzeros()
Erases explicitly stored zeros from the data structure.
Definition srvector.hpp:170
srvector & operator=(const rvector_slice &v)
Assign the dense vector slice v to a sparse vector. Only the non zero elements of v are used.
Definition srvector.hpp:190
friend int VecLen(const srvector &)
Returns the length of the vector (the dimension)
Definition srvector.hpp:427
std::vector< int > & row_indices()
Returns a reference to the STL-vector storing the row indices of the non zero elements.
Definition srvector.hpp:127
friend void SetLb(srvector &, const int)
Sets the lower index bound of the vector v to i.
Definition srvector.hpp:402
friend srvector SupIm(const scivector &)
Returns the supremum of the imaginary part of the complex interval vector as a new sparse point vecto...
srvector(const int s, const int b)
Constructor for creating an empty vector of size s and reserving memory for b elements.
Definition srvector.hpp:78
friend srvector mid(const sivector &)
Compute the midpoint vector of v.
Definition sivector.hpp:650
srvector(const int n, const int nnz, const intvector &index, const rvector &values)
Creates a sparse vector of dimension n with nnz non zeros, who are defined by the elements of index a...
Definition srvector.hpp:94
srvector & operator*=(const real &s)
Operator for multiplication with a scalar, result is assigned to the vector.
Definition srvector.hpp:288
const std::vector< real > & values() const
Returns a reference to the STL-vector storing the values of the non zero elements.
Definition srvector.hpp:155
friend srvector diam(const sivector &)
Computes the diameter of v.
Definition sivector.hpp:662
srvector & operator-=(const srvector &v)
Operator for element-wise subtraction with a vector, result is assigned to the vector.
Definition srvector.hpp:327
srvector operator()(const intvector &per)
Returns a vector whose elemnts are rearranged according to a given permutation vector.
Definition srvector.hpp:259
friend int Ub(const srvector &)
Returns the upper index bound of the vector v.
Definition srvector.hpp:422
friend srvector absmin(const sivector &)
Computes the component-wise minimum absolute values for a vector v.
Definition sivector.hpp:626
friend srvector Im(const scvector &)
Returns the imaginary part of the complex vector v.
Definition scvector.hpp:528
int get_nnz() const
Returns the number of non zero elements of this vector (note that this includes explicitly stored zer...
Definition srvector.hpp:160
friend srvector SupRe(const scivector &)
Returns the supremum of the real part of the complex interval vector as a new sparse point vector.
srvector operator()(const intmatrix &P)
Returns a vector whose elemnts are rearranged according to a given permutation matrix.
Definition srvector.hpp:282
const real operator()(const int i) const
Returns a copy of the i-th (according to the currently used indexing) element of the vector.
Definition srvector.hpp:236
srvector(const int n, const int nnz, const int *index, const real *values)
Creates a sparse vector of dimension n with nnz non zeros, who are defined by the elements of index a...
Definition srvector.hpp:106
srvector & operator/=(const real &s)
Operator for division of each element of the vector with a scalar, result is assigned to the vector.
Definition srvector.hpp:293
srvector & operator+=(const srvector &v)
Operator for element-wise addition with a vector, result is assigned to the vector.
Definition srvector.hpp:309
friend srvector abs(const srvector &)
Returns the vector whose elements are the respective absolute values of the elements of v.
friend srvector InfRe(const scivector &)
Returns the infimum of the real part of the complex interval vector as a new sparse point vector.
srvector(const int s)
Constructor for creating an empty vector of size s.
Definition srvector.hpp:72
srvector()
Default constructor, creates an empty vector of size 0.
Definition srvector.hpp:68
real operator[](const int i) const
Returns a copy of the i-th (according to the currently used indexing) element of the vector.
Definition srvector.hpp:224
const std::vector< int > & row_indices() const
Returns a reference to the STL-vector storing the row indices of the non zero elements.
Definition srvector.hpp:146
srvector & operator+=(const rvector_slice &v)
Operator for element-wise addition with a vector, result is assigned to the vector.
Definition srvector.hpp:304
friend srvector absmax(const sivector &)
Computes the component-wise maximum absolute values for a vector v.
Definition sivector.hpp:638
friend int Lb(const srvector &)
Returns the lower index bound of the vector v.
Definition srvector.hpp:417
srvector & operator=(const rvector &v)
Assign the dense vector v to a sparse vector. Only the non zero elements of v are used.
Definition srvector.hpp:185
real & operator[](const int i)
Returns a reference to the i-th (according to the currently used indexing) element of the vector.
Definition srvector.hpp:202
friend srvector InfIm(const scivector &)
Returns the infimum of the imaginary part of the complex interval vector as a new sparse point vector...
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
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...
Definition cmatrix.cpp:99
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
Definition cimatrix.inl:730
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.
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
Definition cimatrix.inl:737
civector operator*(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of multiplication operation.
Definition cimatrix.inl:731
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.