Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
multiply.h File Reference

Go to the source code of this file.

Functions

DoubleAc norm_DynLinArr (const DynLinArr< DoubleAc > &f)
 
template<class T >
norm_DynLinArr (const DynLinArr< T > &f)
 
template<class T >
norm_DynLinArr_part (const DynLinArr< T > &f, const DynLinArr< int > &s_use)
 
DoubleAc normsq_DynLinArr (const DynLinArr< DoubleAc > &f)
 
template<class T >
normsq_DynLinArr (const DynLinArr< T > &f)
 
template<class T >
normsq_DynLinArr_part (const DynLinArr< T > &f, const DynLinArr< int > &s_use)
 
template<class T >
DynArr< T > operator* (const DynArr< T > &mt1, const DynArr< T > &mt2)
 
template<class T >
DynLinArr< T > operator* (const DynArr< T > &mt, const DynLinArr< T > &vc)
 
DynLinArr< DoubleAcoperator* (const DynArr< DoubleAc > &mt, const DynLinArr< double > &vc)
 
DynLinArr< DoubleAcoperator* (const DynArr< double > &mt, const DynLinArr< DoubleAc > &vc)
 
template<class T >
operator* (const DynLinArr< T > &vc1, const DynLinArr< T > &vc2)
 
DoubleAc operator* (const DynLinArr< DoubleAc > &vc1, const DynLinArr< double > &vc2)
 
DoubleAc operator* (const DynLinArr< double > &vc1, const DynLinArr< DoubleAc > &vc2)
 
template<class T , class X >
DynLinArr< T > operator* (const DynLinArr< T > &ar, const X &t)
 
template<class T , class X >
DynLinArr< T > & operator*= (DynLinArr< T > &ar, const X &t)
 
template<class T , class X >
DynLinArr< T > operator* (const X &t, const DynLinArr< T > &ar)
 
template<class T , class X >
DynLinArr< T > operator/ (const DynLinArr< T > &ar, const X &t)
 
template<class T , class X >
DynLinArr< T > & operator/= (DynLinArr< T > &ar, const X &t)
 
template<class T , class X >
DynArr< T > operator* (const DynArr< T > &mt, const X &t)
 
template<class T , class X >
DynArr< T > operator* (const X &t, const DynArr< T > &mt)
 
template<class T , class X >
DynArr< T > & operator*= (DynArr< T > &mt, const X &t)
 
template<class T , class X >
DynArr< T > operator/ (const DynArr< T > &mt, const X &t)
 
template<class T , class X >
DynArr< T > & operator/= (DynArr< T > &mt, const X &t)
 
template<class T >
DynLinArr< T > operator+ (const DynLinArr< T > &vc1, const DynLinArr< T > &vc2)
 
template<class T >
DynLinArr< T > & operator+= (DynLinArr< T > &vc1, const DynLinArr< T > &vc2)
 
template<class T >
DynLinArr< T > operator- (const DynLinArr< T > &vc1, const DynLinArr< T > &vc2)
 
template<class T >
DynLinArr< T > & operator-= (DynLinArr< T > &vc1, const DynLinArr< T > &vc2)
 
DynLinArr< DoubleAcoperator+ (const DynLinArr< DoubleAc > &vc1, const DynLinArr< double > &vc2)
 
DynLinArr< DoubleAcoperator+ (const DynLinArr< double > &vc1, const DynLinArr< DoubleAc > &vc2)
 
DynLinArr< DoubleAcoperator- (const DynLinArr< DoubleAc > &vc1, const DynLinArr< double > &vc2)
 
DynLinArr< DoubleAcoperator- (const DynLinArr< double > &vc1, const DynLinArr< DoubleAc > &vc2)
 
template<class T >
DynLinArr< T > operator- (const DynLinArr< T > &ar)
 
template<class T >
void change_sign (DynLinArr< T > &ar)
 
void change_sign (float &f)
 
void change_sign (double &f)
 
template<class T , class X >
DynLinArr< T > & operator+= (DynLinArr< T > &ar, const X &t)
 
template<class T , class X >
DynLinArr< T > & operator-= (DynLinArr< T > &ar, const X &t)
 
template<class T >
DynArr< T > operator+ (const DynArr< T > &mt1, const DynArr< T > &mt2)
 
template<class T >
DynArr< T > & operator+= (DynArr< T > &mt1, const DynArr< T > &mt2)
 
template<class T >
DynArr< T > operator- (const DynArr< T > &mt1, const DynArr< T > &mt2)
 
template<class T >
DynArr< T > & operator-= (DynArr< T > &mt1, const DynArr< T > &mt2)
 
template<class T >
DynArr< T > operator- (const DynArr< T > &mt)
 
template<class T >
void change_sign (DynArr< T > &mt)
 
template<class T , class X >
DynArr< T > & operator+= (DynArr< T > &mt, const X &t)
 
template<class T , class X >
DynArr< T > & operator-= (DynArr< T > &mt, const X &t)
 
DynArr< DoubleAcoperator+ (const DynArr< DoubleAc > &mt1, const DynArr< double > &mt2)
 
DynArr< DoubleAcoperator+ (const DynArr< double > &mt1, const DynArr< DoubleAc > &mt2)
 
DynArr< DoubleAcoperator- (const DynArr< DoubleAc > &mt1, const DynArr< double > &mt2)
 
DynArr< DoubleAcoperator- (const DynArr< double > &mt1, const DynArr< DoubleAc > &mt2)
 

Function Documentation

◆ change_sign() [1/4]

void change_sign ( double &  f)
inline

Definition at line 470 of file multiply.h.

470{ f = -f; }

◆ change_sign() [2/4]

template<class T >
void change_sign ( DynArr< T > &  mt)

Definition at line 623 of file multiply.h.

624 { // just change sign without copying total content,
625 // but correspondent member function should exist for type of elements T
626 long qel_lin = mt.get_qel_lin();
627 long n;
628 for (n = 0; n < qel_lin; n++) {
629 change_sign(mt.acu_lin(n));
630 }
631 /*
632 long qdim=mt.get_qdim();
633 const DynLinArr<long>& qe=mt.get_qel();
634 IterDynArr<T> iter(&mt);
635 T* at;
636 while( (at=iter.more()) != NULL )
637 {
638 change_sign((*at));
639 }
640 */
641}
T & acu_lin(long n)
Definition: AbsArr.h:2542
long get_qel_lin(void) const
Definition: AbsArr.h:2498
void change_sign(DynLinArr< T > &ar)
Definition: multiply.h:457

◆ change_sign() [3/4]

template<class T >
void change_sign ( DynLinArr< T > &  ar)

Definition at line 457 of file multiply.h.

458 { // just change sign without copying total content,
459 // but correspondent member function should exist for type of elements T
460 long q = ar.get_qel();
461 DynLinArr<T> s(q);
462 long n;
463 for (n = 0; n < q; n++) {
464 change_sign(ar.acu(n));
465 }
466}
long get_qel(void) const
Definition: AbsArr.h:420
T & acu(long n)
Definition: AbsArr.h:372

Referenced by change_sign().

◆ change_sign() [4/4]

void change_sign ( float &  f)
inline

Definition at line 468 of file multiply.h.

468{ f = -f; }

◆ norm_DynLinArr() [1/2]

DoubleAc norm_DynLinArr ( const DynLinArr< DoubleAc > &  f)

Definition at line 15 of file multiply.cpp.

15 {
16 long q = f.get_qel();
17 DoubleAc s(0.0);
18 long n;
19 for (n = 0; n < q; n++) {
20 DoubleAc t = f[n];
21 s = s + square(t);
22 }
23 return sqrt(s);
24}
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:313
DoubleAc square(const DoubleAc &f)
Definition: DoubleAc.cpp:324

◆ norm_DynLinArr() [2/2]

template<class T >
T norm_DynLinArr ( const DynLinArr< T > &  f)

Definition at line 26 of file multiply.h.

26 {
27 long q = f.get_qel();
28 T s(0); // assumes that this clears the element
29 long n;
30 for (n = 0; n < q; n++) {
31 T t(f.acu(n));
32 s = s + t * t;
33 }
34 return sqrt(s);
35}

◆ norm_DynLinArr_part()

template<class T >
T norm_DynLinArr_part ( const DynLinArr< T > &  f,
const DynLinArr< int > &  s_use 
)

Definition at line 39 of file multiply.h.

39 {
40 mfunname("template<class T> T norm_DynLinArr_part(...)");
41 long q = f.get_qel();
42 check_econd12(q, !=, s_use.get_qel(), mcerr);
43 T s(0); // assumes that this clears the element
44 long n;
45 for (n = 0; n < q; n++) {
46 if (s_use.acu(n) == 1) {
47 T t(f.acu(n));
48 s = s + t * t;
49 }
50 }
51 return sqrt(s);
52}
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:380
#define mfunname(string)
Definition: FunNameStack.h:67
#define mcerr
Definition: prstream.h:135

◆ normsq_DynLinArr() [1/2]

DoubleAc normsq_DynLinArr ( const DynLinArr< DoubleAc > &  f)

Definition at line 26 of file multiply.cpp.

26 {
27 long q = f.get_qel();
28 DoubleAc s(0.0);
29 long n;
30 for (n = 0; n < q; n++) {
31 DoubleAc t = f[n];
32 s = s + square(t);
33 }
34 return s;
35}

◆ normsq_DynLinArr() [2/2]

template<class T >
T normsq_DynLinArr ( const DynLinArr< T > &  f)

Definition at line 56 of file multiply.h.

56 {
57 long q = f.get_qel();
58 T s(0); // assumes that this clears the element
59 long n;
60 for (n = 0; n < q; n++) {
61 T t(f.acu(n));
62 s = s + t * t;
63 }
64 return s;
65}

◆ normsq_DynLinArr_part()

template<class T >
T normsq_DynLinArr_part ( const DynLinArr< T > &  f,
const DynLinArr< int > &  s_use 
)

Definition at line 68 of file multiply.h.

68 {
69 mfunname("template<class T> T normsq_DynLinArr_part(...)");
70 long q = f.get_qel();
71 check_econd12(q, !=, s_use.get_qel(), mcerr);
72 T s(0); // assumes that this clears the element
73 long n;
74 for (n = 0; n < q; n++) {
75 if (s_use.acu(n) == 1) {
76 T t(f.acu(n));
77 s = s + t * t;
78 }
79 }
80 return s;
81}

◆ operator*() [1/11]

DynLinArr< DoubleAc > operator* ( const DynArr< double > &  mt,
const DynLinArr< DoubleAc > &  vc 
)

Definition at line 57 of file multiply.cpp.

58 {
59 mfunname("DynLinArr<DoubleAc> operator*(const DynArr<double>& mt, const "
60 "DynLinArr<DoubleAc>& vc)");
61
62 const DynLinArr<long>& qel_mt(mt.get_qel());
63 check_econd11(qel_mt.get_qel(), != 2, mcerr);
64 long q = vc.get_qel();
65 check_econd12(q, !=, qel_mt[1], mcerr);
66 DoubleAc s(0); // assumes that this clears the element
67 DynLinArr<DoubleAc> res(qel_mt[0], s);
68 long n1, n2;
69 for (n1 = 0; n1 < qel_mt[0]; n1++) {
70 for (n2 = 0; n2 < q; n2++) {
71 res.acu(n1) += mt.acu(n1, n2) * vc.acu(n2);
72 }
73 }
74 return res;
75}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:366
T & acu(long i1)
Definition: AbsArr.h:2098
const DynLinArr< long > & get_qel(void) const
Definition: AbsArr.h:2548

◆ operator*() [2/11]

DynLinArr< DoubleAc > operator* ( const DynArr< DoubleAc > &  mt,
const DynLinArr< double > &  vc 
)

Definition at line 37 of file multiply.cpp.

38 {
39 mfunname("DynLinArr<DoubleAc> operator*(const DynArr<DoubleAc>& mt, const "
40 "DynLinArr<double>& vc)");
41
42 const DynLinArr<long>& qel_mt(mt.get_qel());
43 check_econd11(qel_mt.get_qel(), != 2, mcerr);
44 long q = vc.get_qel();
45 check_econd12(q, !=, qel_mt[1], mcerr);
46 DoubleAc s(0); // assumes that this clears the element
47 DynLinArr<DoubleAc> res(qel_mt[0], s);
48 long n1, n2;
49 for (n1 = 0; n1 < qel_mt[0]; n1++) {
50 for (n2 = 0; n2 < q; n2++) {
51 res.acu(n1) += mt.acu(n1, n2) * vc.acu(n2);
52 }
53 }
54 return res;
55}

◆ operator*() [3/11]

template<class T >
DynLinArr< T > operator* ( const DynArr< T > &  mt,
const DynLinArr< T > &  vc 
)

Definition at line 125 of file multiply.h.

125 {
126 const DynLinArr<long>& qel_mt(mt.get_qel());
127 if (qel_mt.get_qel() != 2) {
128 mcerr << "template<class T>\n"
129 << "DynLinArr<T> operator*(const DynArr<T>& mt, "
130 << "const DynLinArr<T>& vc):\n";
131 mcerr << "qel_mt.get_qel() != 2, qel_mt.get_qel() =" << qel_mt.get_qel()
132 << '\n';
133 spexit(mcerr);
134 }
135 long q = vc.get_qel();
136 if (q != qel_mt[1]) {
137 mcerr << "template<class T>\n"
138 << "DynLinArr<T> operator*(const DynArr<T>& mt, "
139 << "const DynLinArr<T>& vc):\n";
140 mcerr << "q != qel_mt[1], q =" << q << "qel_mt[1]=" << qel_mt[1] << '\n';
141 spexit(mcerr);
142 }
143 T s(0); // assumes that this clears the element
144 DynLinArr<T> res(qel_mt[0], s);
145 long n1, n2;
146 for (n1 = 0; n1 < qel_mt[0]; n1++) {
147 for (n2 = 0; n2 < q; n2++) {
148 res[n1] += mt.acu(n1, n2) * vc.acu(n2);
149 }
150 }
151 return res;
152}
#define spexit(stream)
Definition: FunNameStack.h:536

◆ operator*() [4/11]

template<class T , class X >
DynArr< T > operator* ( const DynArr< T > &  mt,
const X &  t 
)

Definition at line 255 of file multiply.h.

255 {
256 mfunnamep("template<class T, class X> DynArr<T> operator*(const DynArr<T>& "
257 "mt, const X& t)");
258 DynArr<T> ms(mt.get_qel(), NULL);
259 long qel_lin = mt.get_qel_lin();
260 long n;
261 for (n = 0; n < qel_lin; n++) {
262 ms.acu_lin(n) = mt.acu_lin(n) * t;
263 }
264 /*
265 DynArr<T> ms(mt);
266 IterDynArr<T> iter(&ms);
267 T* at;
268 while( (at=iter.more()) != NULL )
269 {
270 (*at) = (*at) * t ;
271 }
272 */
273 return ms;
274}
#define mfunnamep(string)
Definition: FunNameStack.h:77

◆ operator*() [5/11]

template<class T >
DynArr< T > operator* ( const DynArr< T > &  mt1,
const DynArr< T > &  mt2 
)

Definition at line 85 of file multiply.h.

85 {
86 mfunnamep("template<class T> DynArr<T> operator*(const DynArr<T>& mt1, const "
87 "DynArr<T>& mt2)");
88 check_econd11(mt1.get_qdim(), != 2, mcerr);
89 check_econd11(mt2.get_qdim(), > 2, mcerr);
90 check_econd11(mt2.get_qdim(), < 1, mcerr);
91 const DynLinArr<long>& qel_mt1(mt1.get_qel());
92 const DynLinArr<long>& qel_mt2(mt2.get_qel());
93 check_econd12(qel_mt1[1], !=, qel_mt2[0], mcerr);
94 if (mt2.get_qdim() == 2) { // otherwise 1
95 long q1 = qel_mt1[0];
96 long q2 = qel_mt2[1];
97 long q3 = qel_mt1[1];
98 DynArr<T> res(q1, q2);
99 for (long n1 = 0; n1 < q1; ++n1) {
100 for (long n2 = 0; n2 < q2; ++n2) {
101 T t(0.0);
102 for (long n3 = 0; n3 < q3; ++n3) {
103 t += mt1.acu(n1, n3) * mt2.acu(n3, n2);
104 }
105 res.acu(n1, n2) = t;
106 }
107 }
108 return res;
109 } else {
110 long q1 = qel_mt1[0];
111 long q3 = qel_mt1[1];
112 DynArr<T> res(q1);
113 for (long n1 = 0; n1 < q1; ++n1) {
114 T t(0.0);
115 for (long n3 = 0; n3 < q3; ++n3) {
116 t += mt1.acu(n1, n3) * mt2.acu(n3);
117 }
118 res.acu(n1) = t;
119 }
120 return res;
121 }
122}
long get_qdim(void) const
Definition: AbsArr.h:2547

◆ operator*() [6/11]

DoubleAc operator* ( const DynLinArr< double > &  vc1,
const DynLinArr< DoubleAc > &  vc2 
)

Definition at line 93 of file multiply.cpp.

94 {
95 mfunname("DoubleAc operator*(const DynLinArr<double>& vc1, const "
96 "DynLinArr<DoubleAc>& vc2)");
97 //mcout<<"operator*(const DynLinArr<double>& vc1, ...):\n";
98 long q1 = vc1.get_qel();
99 long q2 = vc2.get_qel();
100 check_econd12(q1, !=, q2, mcerr);
101 DoubleAc s(0); // assumes that this clears the element
102 long n;
103 //mcout<<"s="<<s<<'\n';
104 for (n = 0; n < q1; n++) {
105 s += vc1.acu(n) * vc2.acu(n);
106 //mcout<<"vc1[n]="<<vc1[n]<<'\n';
107 //mcout<<"vc2[n]="<<vc2[n]<<'\n';
108 //mcout<<"vc1[n] * vc2[n]="<<vc1[n] * vc2[n]<<'\n';
109 //mcout<<"s="<<s<<'\n';
110 }
111 return s;
112}

◆ operator*() [7/11]

DoubleAc operator* ( const DynLinArr< DoubleAc > &  vc1,
const DynLinArr< double > &  vc2 
)

Definition at line 77 of file multiply.cpp.

78 {
79 mfunname("DoubleAc operator*(const DynLinArr<DoubleAc>& vc1, const "
80 "DynLinArr<double>& vc2)");
81
82 long q1 = vc1.get_qel();
83 long q2 = vc2.get_qel();
84 check_econd12(q1, !=, q2, mcerr);
85 DoubleAc s(0); // assumes that this clears the element
86 long n;
87 for (n = 0; n < q1; n++) {
88 s += vc1.acu(n) * vc2.acu(n);
89 }
90 return s;
91}

◆ operator*() [8/11]

template<class T , class X >
DynLinArr< T > operator* ( const DynLinArr< T > &  ar,
const X &  t 
)

Definition at line 196 of file multiply.h.

196 {
197 long q = ar.get_qel();
198 DynLinArr<T> res(q);
199 long n;
200 for (n = 0; n < q; n++) {
201 res.acu(n) = ar.acu(n) * t;
202 }
203 return res;
204}

◆ operator*() [9/11]

template<class T >
T operator* ( const DynLinArr< T > &  vc1,
const DynLinArr< T > &  vc2 
)

Definition at line 163 of file multiply.h.

163 {
164 //mcout<<"T operator*(const DynLinArr<T>& vc1, const DynLinArr<T>& vc2):\n";
165 long q1 = vc1.get_qel();
166 long q2 = vc2.get_qel();
167 if (q1 != q2) {
168 mcerr << "template<class T>\n"
169 << "DynLinArr<T> operator*(const DynArr<T>& mt, "
170 << "const DynLinArr<T>& vc):\n";
171 mcerr << "q1 != q2, q1 =" << q1 << "q2=" << q2 << '\n';
172 spexit(mcerr);
173 }
174 T s(0); // assumes that this clears the element
175 long n;
176 //mcout<<"s="<<s<<'\n';
177 for (n = 0; n < q1; n++) {
178 s += vc1.acu(n) * vc2.acu(n);
179 //mcout<<"vc1[n]="<<vc1[n]<<'\n';
180 //mcout<<"vc2[n]="<<vc2[n]<<'\n';
181 //mcout<<"vc1[n] * vc2[n]="<<vc1[n] * vc2[n]<<'\n';
182 //mcout<<"s="<<s<<'\n';
183 }
184 return s;
185}

◆ operator*() [10/11]

template<class T , class X >
DynArr< T > operator* ( const X &  t,
const DynArr< T > &  mt 
)

Definition at line 277 of file multiply.h.

277 {
278 mfunnamep("template<class T, class X> DynArr<T> operator*(const X& t, const "
279 "DynArr<T>& mt)");
280 DynArr<T> ms(mt.get_qel(), NULL);
281 long qel_lin = mt.get_qel_lin();
282 long n;
283 for (n = 0; n < qel_lin; n++) {
284 ms.acu_lin(n) = t * mt.acu_lin(n);
285 }
286 /*
287 DynArr<T> ms(mt);
288 IterDynArr<T> iter(&ms);
289 T* at;
290 while( (at=iter.more()) != NULL )
291 {
292 (*at) = t * (*at);
293 }
294 */
295 return ms;
296}

◆ operator*() [11/11]

template<class T , class X >
DynLinArr< T > operator* ( const X &  t,
const DynLinArr< T > &  ar 
)

Definition at line 217 of file multiply.h.

217 {
218 mfunnamep("template<class T, class X> DynLinArr<T> operator*(const X& t, "
219 "const DynLinArr<T>& ar)");
220 long q = ar.get_qel();
221 DynLinArr<T> res(q);
222 long n;
223 for (n = 0; n < q; n++) {
224 res.acu(n) = t * ar.acu(n);
225 }
226 return res;
227}

◆ operator*=() [1/2]

template<class T , class X >
DynArr< T > & operator*= ( DynArr< T > &  mt,
const X &  t 
)

Definition at line 298 of file multiply.h.

298 {
299 mfunnamep("template<class T, class X> DynArr<T>& operator*=(DynArr<T>& mt, "
300 "const X& t)");
301 long qel_lin = mt.get_qel_lin();
302 long n;
303 for (n = 0; n < qel_lin; n++) {
304 mt.acu_lin(n) *= t;
305 }
306 /*
307 //DynArr<T> ms(mt);
308 IterDynArr<T> iter(&mt);
309 T* at;
310 while( (at=iter.more()) != NULL )
311 {
312 (*at) *= t ;
313 }
314 */
315 return mt;
316}

◆ operator*=() [2/2]

template<class T , class X >
DynLinArr< T > & operator*= ( DynLinArr< T > &  ar,
const X &  t 
)

Definition at line 207 of file multiply.h.

207 {
208 long q = ar.get_qel();
209 long n;
210 for (n = 0; n < q; n++) {
211 ar.acu(n) *= t;
212 }
213 return ar;
214}

◆ operator+() [1/6]

DynArr< DoubleAc > operator+ ( const DynArr< double > &  mt1,
const DynArr< DoubleAc > &  mt2 
)

Definition at line 209 of file multiply.cpp.

210 {
211 mfunname("DynArr<DoubleAc> operator+(const DynArr<double>& mt1, const "
212 "DynArr<DoubleAc>& mt2)");
213 long qdim1 = mt1.get_qdim();
214 long qdim2 = mt2.get_qdim();
215 check_econd12(qdim1, !=, qdim2, mcerr);
216 const DynLinArr<long>& qe1 = mt1.get_qel();
217 const DynLinArr<long>& qe2 = mt2.get_qel();
218 check_econd12(qe1, !=, qe2, mcerr);
219 DynArr<DoubleAc> ms(mt2);
220 IterDynArr<DoubleAc> iter(&ms);
221 DoubleAc* at;
222 while ((at = iter.more()) != NULL) {
223 (*at) = (*at) + mt1.acu(iter.get_ncur());
224 }
225 return ms;
226}

◆ operator+() [2/6]

DynArr< DoubleAc > operator+ ( const DynArr< DoubleAc > &  mt1,
const DynArr< double > &  mt2 
)

Definition at line 172 of file multiply.cpp.

173 {
174 mfunname("DynArr<DoubleAc> operator+(const DynArr<DoubleAc>& mt1, const "
175 "DynArr<double>& mt2)");
176 long qdim1 = mt1.get_qdim();
177 long qdim2 = mt2.get_qdim();
178 check_econd12(qdim1, !=, qdim2, mcerr);
179 const DynLinArr<long>& qe1 = mt1.get_qel();
180 const DynLinArr<long>& qe2 = mt2.get_qel();
181 check_econd12(qe1, !=, qe2, mcerr);
182 DynArr<DoubleAc> ms(mt1);
183 IterDynArr<DoubleAc> iter(&ms);
184 DoubleAc* at;
185 while ((at = iter.more()) != NULL) {
186 (*at) = (*at) + mt2.acu(iter.get_ncur());
187 }
188 return ms;
189}

◆ operator+() [3/6]

template<class T >
DynArr< T > operator+ ( const DynArr< T > &  mt1,
const DynArr< T > &  mt2 
)

Definition at line 493 of file multiply.h.

493 {
494 mfunnamep("template<class T> DynArr<T> operator+(const DynArr<T>& mt1, const "
495 "DynArr<T>& mt2)");
496 long qdim1 = mt1.get_qdim();
497 long qdim2 = mt2.get_qdim();
498 check_econd12(qdim1, !=, qdim2, mcerr);
499 const DynLinArr<long>& qe1 = mt1.get_qel();
500 const DynLinArr<long>& qe2 = mt2.get_qel();
501 check_econd12(qe1, !=, qe2, mcerr);
502 DynArr<T> ms(mt1.get_qel(), NULL);
503 long qel_lin = mt1.get_qel_lin();
504 long n;
505 for (n = 0; n < qel_lin; n++) {
506 ms.acu_lin(n) = mt1.acu_lin(n) + mt2.acu_lin(n);
507 }
508
509 /*
510 DynArr<T> ms(mt1); // initializes array and copy content.
511 // it seems to be more economical, than to initialize, and to assign later.
512 IterDynArr<T> iter(&ms);
513 T* at;
514 while( (at=iter.more()) != NULL )
515 {
516 (*at) = (*at) + mt2.acu( iter.get_ncur() );
517 }
518 */
519 return ms;
520}

◆ operator+() [4/6]

DynLinArr< DoubleAc > operator+ ( const DynLinArr< double > &  vc1,
const DynLinArr< DoubleAc > &  vc2 
)

Definition at line 143 of file multiply.cpp.

144 {
145 mfunname("DoubleAc operator+(const DynLinArr<double>& vc1, const "
146 "DynLinArr<DoubleAc>& vc2)");
147 long q1 = vc1.get_qel();
148 long q2 = vc2.get_qel();
149 check_econd12(q1, !=, q2, mcerr);
151 long n;
152 for (n = 0; n < q1; n++) {
153 s.acu(n) = vc1.acu(n) + vc2.acu(n);
154 }
155 return s;
156}

◆ operator+() [5/6]

DynLinArr< DoubleAc > operator+ ( const DynLinArr< DoubleAc > &  vc1,
const DynLinArr< double > &  vc2 
)

Definition at line 114 of file multiply.cpp.

115 {
116 mfunname("DoubleAc operator+(const DynLinArr<DoubleAc>& vc1, const "
117 "DynLinArr<double>& vc2)");
118 long q1 = vc1.get_qel();
119 long q2 = vc2.get_qel();
120 check_econd12(q1, !=, q2, mcerr);
122 long n;
123 for (n = 0; n < q1; n++) {
124 s.acu(n) = vc1.acu(n) + vc2.acu(n);
125 }
126 return s;
127}

◆ operator+() [6/6]

template<class T >
DynLinArr< T > operator+ ( const DynLinArr< T > &  vc1,
const DynLinArr< T > &  vc2 
)

Definition at line 362 of file multiply.h.

362 {
363 long q1 = vc1.get_qel();
364 long q2 = vc2.get_qel();
365 if (q1 != q2) {
366 mcerr << "template<class T>\n"
367 << "DynLinArr<T> operator+(const DynLinArr<T>& vc1, "
368 << "const DynLinArr<T>& vc2):\n";
369 mcerr << "q1 != q2, q1 =" << q1 << "q2=" << q2 << '\n';
370 spexit(mcerr);
371 }
372 DynLinArr<T> s(q1);
373 long n;
374 for (n = 0; n < q1; n++) {
375 s.acu(n) = vc1.acu(n) + vc2.acu(n);
376 }
377 return s;
378}

◆ operator+=() [1/4]

template<class T , class X >
DynArr< T > & operator+= ( DynArr< T > &  mt,
const X &  t 
)

Definition at line 643 of file multiply.h.

643 {
644 mfunnamep("template<class T, class X> DynArr<T>& operator+=(DynArr<T>& mt, "
645 "const X& t)");
646 long qel_lin = mt.get_qel_lin();
647 long n;
648 for (n = 0; n < qel_lin; n++) {
649 mt.acu_lin(n) += t;
650 }
651 /*
652 //DynArr<T> ms(mt);
653 IterDynArr<T> iter(&mt);
654 T* at;
655 while( (at=iter.more()) != NULL )
656 {
657 (*at) += t ;
658 }
659 */
660 return mt;
661}

◆ operator+=() [2/4]

template<class T >
DynArr< T > & operator+= ( DynArr< T > &  mt1,
const DynArr< T > &  mt2 
)

Definition at line 522 of file multiply.h.

522 {
523 mfunnamep("template<class T> DynArr<T>& operator+(DynArr<T>& mt1, const "
524 "DynArr<T>& mt2)");
525 long qdim1 = mt1.get_qdim();
526 long qdim2 = mt2.get_qdim();
527 check_econd12(qdim1, !=, qdim2, mcerr);
528 const DynLinArr<long>& qe1 = mt1.get_qel();
529 const DynLinArr<long>& qe2 = mt2.get_qel();
530 check_econd12(qe1, !=, qe2, mcerr);
531 long qel_lin = mt1.get_qel_lin();
532 long n;
533 for (n = 0; n < qel_lin; n++) {
534 mt1.acu_lin(n) += mt2.acu_lin(n);
535 }
536 /*
537 IterDynArr<T> iter(&mt1);
538 T* at;
539 while( (at=iter.more()) != NULL )
540 {
541 (*at) += mt2.acu( iter.get_ncur() );
542 }
543 */
544 return mt1;
545}

◆ operator+=() [3/4]

template<class T , class X >
DynLinArr< T > & operator+= ( DynLinArr< T > &  ar,
const X &  t 
)

Definition at line 473 of file multiply.h.

473 {
474 long q = ar.get_qel();
475 long n;
476 for (n = 0; n < q; n++) {
477 ar.acu(n) += t;
478 }
479 return ar;
480}

◆ operator+=() [4/4]

template<class T >
DynLinArr< T > & operator+= ( DynLinArr< T > &  vc1,
const DynLinArr< T > &  vc2 
)

Definition at line 381 of file multiply.h.

381 {
382 long q1 = vc1.get_qel();
383 long q2 = vc2.get_qel();
384 if (q1 != q2) {
385 mcerr << "template<class T>\n"
386 << "DynLinArr<T>& operator+=(DynLinArr<T>& vc1, "
387 << "const DynLinArr<T>& vc2):\n";
388 mcerr << "q1 != q2, q1 =" << q1 << "q2=" << q2 << '\n';
389 spexit(mcerr);
390 }
391 long n;
392 for (n = 0; n < q1; n++) {
393 vc1.acu(n) += vc2.acu(n);
394 }
395 return vc1;
396}

◆ operator-() [1/8]

DynArr< DoubleAc > operator- ( const DynArr< double > &  mt1,
const DynArr< DoubleAc > &  mt2 
)

Definition at line 228 of file multiply.cpp.

229 {
230 mfunname("DynArr<DoubleAc> operator-(const DynArr<double>& mt1, const "
231 "DynArr<DoubleAc>& mt2)");
232 long qdim1 = mt1.get_qdim();
233 long qdim2 = mt2.get_qdim();
234 check_econd12(qdim1, !=, qdim2, mcerr);
235 const DynLinArr<long>& qe1 = mt1.get_qel();
236 const DynLinArr<long>& qe2 = mt2.get_qel();
237 check_econd12(qe1, !=, qe2, mcerr);
238 DynArr<DoubleAc> ms(mt2);
239 IterDynArr<DoubleAc> iter(&ms);
240 DoubleAc* at;
241 while ((at = iter.more()) != NULL) {
242 (*at) = -(*at) + mt1.acu(iter.get_ncur());
243 }
244 return ms;
245}

◆ operator-() [2/8]

DynArr< DoubleAc > operator- ( const DynArr< DoubleAc > &  mt1,
const DynArr< double > &  mt2 
)

Definition at line 190 of file multiply.cpp.

191 {
192 mfunname("DynArr<DoubleAc> operator-(const DynArr<DoubleAc>& mt1, const "
193 "DynArr<double>& mt2)");
194 long qdim1 = mt1.get_qdim();
195 long qdim2 = mt2.get_qdim();
196 check_econd12(qdim1, !=, qdim2, mcerr);
197 const DynLinArr<long>& qe1 = mt1.get_qel();
198 const DynLinArr<long>& qe2 = mt2.get_qel();
199 check_econd12(qe1, !=, qe2, mcerr);
200 DynArr<DoubleAc> ms(mt1);
201 IterDynArr<DoubleAc> iter(&ms);
202 DoubleAc* at;
203 while ((at = iter.more()) != NULL) {
204 (*at) = (*at) - mt2.acu(iter.get_ncur());
205 }
206 return ms;
207}

◆ operator-() [3/8]

template<class T >
DynArr< T > operator- ( const DynArr< T > &  mt)

Definition at line 600 of file multiply.h.

600 {
601 mfunnamep("template<class T> DynArr<T> operator-(const DynArr<T>& mt)");
602 //long qdim=mt.get_qdim();
603 //const DynLinArr<long>& qe=mt.get_qel();
604 DynArr<T> ms(mt.get_qel(), NULL);
605 long qel_lin = mt.get_qel_lin();
606 long n;
607 for (n = 0; n < qel_lin; n++) {
608 ms.acu_lin(n) -= mt.acu_lin(n);
609 }
610 /*
611 DynArr<T> ms(mt);
612 IterDynArr<T> iter(&ms);
613 T* at;
614 while( (at=iter.more()) != NULL )
615 {
616 (*at) = -(*at);
617 }
618 */
619 return ms;
620}

◆ operator-() [4/8]

template<class T >
DynArr< T > operator- ( const DynArr< T > &  mt1,
const DynArr< T > &  mt2 
)

Definition at line 548 of file multiply.h.

548 {
549 mfunnamep("template<class T> DynArr<T> operator-(const DynArr<T>& mt1, const "
550 "DynArr<T>& mt2)");
551 long qdim1 = mt1.get_qdim();
552 long qdim2 = mt2.get_qdim();
553 check_econd12(qdim1, !=, qdim2, mcerr);
554 const DynLinArr<long>& qe1 = mt1.get_qel();
555 const DynLinArr<long>& qe2 = mt2.get_qel();
556 check_econd12(qe1, !=, qe2, mcerr);
557 DynArr<T> ms(mt1.get_qel(), NULL);
558 long qel_lin = mt1.get_qel_lin();
559 long n;
560 for (n = 0; n < qel_lin; n++) {
561 ms.acu_lin(n) = mt1.acu_lin(n) - mt2.acu_lin(n);
562 }
563 /*
564 DynArr<T> ms(mt1);
565 IterDynArr<T> iter(&ms);
566 T* at;
567 while( (at=iter.more()) != NULL )
568 {
569 (*at) = (*at) - mt2.acu( iter.get_ncur() );
570 }
571 */
572 return ms;
573}

◆ operator-() [5/8]

DynLinArr< DoubleAc > operator- ( const DynLinArr< double > &  vc1,
const DynLinArr< DoubleAc > &  vc2 
)

Definition at line 157 of file multiply.cpp.

158 {
159 mfunname("DoubleAc operator-(const DynLinArr<double>& vc1, const "
160 "DynLinArr<DoubleAc>& vc2)");
161 long q1 = vc1.get_qel();
162 long q2 = vc2.get_qel();
163 check_econd12(q1, !=, q2, mcerr);
165 long n;
166 for (n = 0; n < q1; n++) {
167 s.acu(n) = vc1.acu(n) - vc2.acu(n);
168 }
169 return s;
170}

◆ operator-() [6/8]

DynLinArr< DoubleAc > operator- ( const DynLinArr< DoubleAc > &  vc1,
const DynLinArr< double > &  vc2 
)

Definition at line 128 of file multiply.cpp.

129 {
130 mfunname("DoubleAc operator-(const DynLinArr<DoubleAc>& vc1, const "
131 "DynLinArr<double>& vc2)");
132 long q1 = vc1.get_qel();
133 long q2 = vc2.get_qel();
134 check_econd12(q1, !=, q2, mcerr);
136 long n;
137 for (n = 0; n < q1; n++) {
138 s.acu(n) = vc1.acu(n) - vc2.acu(n);
139 }
140 return s;
141}

◆ operator-() [7/8]

template<class T >
DynLinArr< T > operator- ( const DynLinArr< T > &  ar)

Definition at line 444 of file multiply.h.

445 { // creates local copy and returns it - may
446 // be inefficient
447 long q = ar.get_qel();
448 DynLinArr<T> s(q);
449 long n;
450 for (n = 0; n < q; n++) {
451 s.acu(n) = -ar.acu(n);
452 }
453 return s;
454}

◆ operator-() [8/8]

template<class T >
DynLinArr< T > operator- ( const DynLinArr< T > &  vc1,
const DynLinArr< T > &  vc2 
)

Definition at line 399 of file multiply.h.

399 {
400 long q1 = vc1.get_qel();
401 long q2 = vc2.get_qel();
402 if (q1 != q2) {
403 mcerr << "template<class T>\n"
404 << "DynLinArr<T> operator-(const DynLinArr<T>& vc1, "
405 << "const DynLinArr<T>& vc2):\n";
406 mcerr << "q1 != q2, q1 =" << q1 << "q2=" << q2 << '\n';
407 spexit(mcerr);
408 }
409 DynLinArr<T> s(q1);
410 long n;
411 for (n = 0; n < q1; n++) {
412 s.acu(n) = vc1.acu(n) - vc2.acu(n);
413 }
414 return s;
415}

◆ operator-=() [1/4]

template<class T , class X >
DynArr< T > & operator-= ( DynArr< T > &  mt,
const X &  t 
)

Definition at line 663 of file multiply.h.

663 {
664 mfunnamep("template<class T, class X> DynArr<T>& operator-=(DynArr<T>& mt, "
665 "const X& t)");
666 long qel_lin = mt.get_qel_lin();
667 long n;
668 for (n = 0; n < qel_lin; n++) {
669 mt.acu_lin(n) += t;
670 }
671 /*
672 //DynArr<T> ms(mt);
673 IterDynArr<T> iter(&mt);
674 T* at;
675 while( (at=iter.more()) != NULL )
676 {
677 (*at) -= t ;
678 }
679 */
680 return mt;
681}

◆ operator-=() [2/4]

template<class T >
DynArr< T > & operator-= ( DynArr< T > &  mt1,
const DynArr< T > &  mt2 
)

Definition at line 575 of file multiply.h.

575 {
576 mfunnamep("template<class T> DynArr<T>& operator-(DynArr<T>& mt1, const "
577 "DynArr<T>& mt2)");
578 long qdim1 = mt1.get_qdim();
579 long qdim2 = mt2.get_qdim();
580 check_econd12(qdim1, !=, qdim2, mcerr);
581 const DynLinArr<long>& qe1 = mt1.get_qel();
582 const DynLinArr<long>& qe2 = mt2.get_qel();
583 check_econd12(qe1, !=, qe2, mcerr);
584 long qel_lin = mt1.get_qel_lin();
585 long n;
586 for (n = 0; n < qel_lin; n++) {
587 mt1.acu_lin(n) -= mt2.acu_lin(n);
588 }
589 /*
590 IterDynArr<T> iter(&mt1);
591 T* at;
592 while( (at=iter.more()) != NULL )
593 {
594 (*at) = (*at) - mt2.acu( iter.get_ncur() );
595 }
596 */
597 return mt1;
598}

◆ operator-=() [3/4]

template<class T , class X >
DynLinArr< T > & operator-= ( DynLinArr< T > &  ar,
const X &  t 
)

Definition at line 483 of file multiply.h.

483 {
484 long q = ar.get_qel();
485 long n;
486 for (n = 0; n < q; n++) {
487 ar.acu(n) -= t;
488 }
489 return ar;
490}

◆ operator-=() [4/4]

template<class T >
DynLinArr< T > & operator-= ( DynLinArr< T > &  vc1,
const DynLinArr< T > &  vc2 
)

Definition at line 418 of file multiply.h.

418 {
419 long q1 = vc1.get_qel();
420 long q2 = vc2.get_qel();
421 if (q1 != q2) {
422 mcerr << "template<class T>\n"
423 << "DynLinArr<T>& operator-=(DynLinArr<T>& vc1, "
424 << "const DynLinArr<T>& vc2):\n";
425 mcerr << "q1 != q2, q1 =" << q1 << "q2=" << q2 << '\n';
426 spexit(mcerr);
427 }
428 long n;
429 for (n = 0; n < q1; n++) {
430 vc1.acu(n) -= vc2.acu(n);
431 }
432 return vc1;
433}

◆ operator/() [1/2]

template<class T , class X >
DynArr< T > operator/ ( const DynArr< T > &  mt,
const X &  t 
)

Definition at line 319 of file multiply.h.

319 {
320 mfunnamep("template<class T, class X> DynArr<T> operator/(const DynArr<T>& "
321 "mt, const X& t)");
322 check_econd11(t, == 0, mcerr);
323 DynArr<T> ms(mt.get_qel(), NULL);
324 long qel_lin = mt.get_qel_lin();
325 long n;
326 for (n = 0; n < qel_lin; n++) {
327 ms.acu_lin(n) = mt.acu_lin(n) / t;
328 }
329 /*
330 DynArr<T> ms(mt);
331 IterDynArr<T> iter(&ms);
332 T* at;
333 while( (at=iter.more()) != NULL )
334 {
335 (*at) = (*at) / t ;
336 }
337 */
338 return ms;
339}

◆ operator/() [2/2]

template<class T , class X >
DynLinArr< T > operator/ ( const DynLinArr< T > &  ar,
const X &  t 
)

Definition at line 230 of file multiply.h.

230 {
231 mfunname("DynLinArr<T> operator/(const DynLinArr<T>& ar, const X& t)");
232 check_econd11(t, == 0, mcerr);
233 long q = ar.get_qel();
234 DynLinArr<T> res(q);
235 long n;
236 for (n = 0; n < q; n++) {
237 res.acu(n) = ar.acu(n) / t;
238 }
239 return res;
240}

◆ operator/=() [1/2]

template<class T , class X >
DynArr< T > & operator/= ( DynArr< T > &  mt,
const X &  t 
)

Definition at line 340 of file multiply.h.

340 {
341 mfunnamep("template<class T, class X> DynArr<T>& operator/(DynArr<T>& mt, "
342 "const X& t)");
343 check_econd11(t, == 0, mcerr);
344 long qel_lin = mt.get_qel_lin();
345 long n;
346 for (n = 0; n < qel_lin; n++) {
347 mt.acu_lin(n) /= t;
348 }
349 /*
350 //DynArr<T> ms(mt);
351 IterDynArr<T> iter(&mt);
352 T* at;
353 while( (at=iter.more()) != NULL )
354 {
355 (*at) = (*at) / t ;
356 }
357 */
358 return mt;
359}

◆ operator/=() [2/2]

template<class T , class X >
DynLinArr< T > & operator/= ( DynLinArr< T > &  ar,
const X &  t 
)

Definition at line 243 of file multiply.h.

243 {
244 mfunname("DynLinArr<T>& operator/=(DynLinArr<T>& ar, const X& t)");
245 check_econd11(t, == 0, mcerr);
246 long q = ar.get_qel();
247 long n;
248 for (n = 0; n < q; n++) {
249 ar.acu(n) /= t;
250 }
251 return ar;
252}