Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
multiply.cpp
Go to the documentation of this file.
1/*
2Copyright (c) 2001 Igor B. Smirnov
3
4The file can be used, copied, modified, and distributed
5according to the terms of GNU Lesser General Public License version 2.1
6as published by the Free Software Foundation,
7and provided that the above copyright notice, this permission notice,
8and notices about any modifications of the original text
9appear in all copies and in supporting documentation.
10The file is provided "as is" without express or implied warranty.
11*/
14
15namespace Heed {
16
18 const DynLinArr<double>& vc) {
20 "DynLinArr<DoubleAc> operator*(const DynArr<DoubleAc>& mt, const "
21 "DynLinArr<double>& vc)");
22
23 const DynLinArr<long>& qel_mt(mt.get_qel());
24 check_econd11(qel_mt.get_qel(), != 2, mcerr);
25 const long q = vc.get_qel();
26 check_econd12(q, !=, qel_mt[1], mcerr);
27 DoubleAc s(0); // assumes that this clears the element
28 DynLinArr<DoubleAc> res(qel_mt[0], s);
29 for (long n1 = 0; n1 < qel_mt[0]; n1++) {
30 for (long n2 = 0; n2 < q; n2++) {
31 res.acu(n1) += mt.acu(n1, n2) * vc.acu(n2);
32 }
33 }
34 return res;
35}
36
38 const DynLinArr<DoubleAc>& vc) {
40 "DynLinArr<DoubleAc> operator*(const DynArr<double>& mt, const "
41 "DynLinArr<DoubleAc>& vc)");
42
43 const DynLinArr<long>& qel_mt(mt.get_qel());
44 check_econd11(qel_mt.get_qel(), != 2, mcerr);
45 const long q = vc.get_qel();
46 check_econd12(q, !=, qel_mt[1], mcerr);
47 DoubleAc s(0); // assumes that this clears the element
48 DynLinArr<DoubleAc> res(qel_mt[0], s);
49 for (long n1 = 0; n1 < qel_mt[0]; n1++) {
50 for (long n2 = 0; n2 < q; n2++) {
51 res.acu(n1) += mt.acu(n1, n2) * vc.acu(n2);
52 }
53 }
54 return res;
55}
56
58 const DynLinArr<double>& vc2) {
60 "DoubleAc operator*(const DynLinArr<DoubleAc>& vc1, const "
61 "DynLinArr<double>& vc2)");
62
63 const long q1 = vc1.get_qel();
64 const long q2 = vc2.get_qel();
65 check_econd12(q1, !=, q2, mcerr);
66 DoubleAc s(0); // assumes that this clears the element
67 for (long n = 0; n < q1; n++) {
68 s += vc1.acu(n) * vc2.acu(n);
69 }
70 return s;
71}
72
74 const DynLinArr<DoubleAc>& vc2) {
76 "DoubleAc operator*(const DynLinArr<double>& vc1, const "
77 "DynLinArr<DoubleAc>& vc2)");
78 const long q1 = vc1.get_qel();
79 const long q2 = vc2.get_qel();
80 check_econd12(q1, !=, q2, mcerr);
81 DoubleAc s(0); // assumes that this clears the element
82 for (long n = 0; n < q1; n++) {
83 s += vc1.acu(n) * vc2.acu(n);
84 // mcout<<"vc1[n]="<<vc1[n]<<'\n';
85 // mcout<<"vc2[n]="<<vc2[n]<<'\n';
86 // mcout<<"vc1[n] * vc2[n]="<<vc1[n] * vc2[n]<<'\n';
87 // mcout<<"s="<<s<<'\n';
88 }
89 return s;
90}
91
93 const DynLinArr<double>& vc2) {
95 "DoubleAc operator+(const DynLinArr<DoubleAc>& vc1, const "
96 "DynLinArr<double>& vc2)");
97 const long q1 = vc1.get_qel();
98 const long q2 = vc2.get_qel();
99 check_econd12(q1, !=, q2, mcerr);
101 for (long n = 0; n < q1; n++) {
102 s.acu(n) = vc1.acu(n) + vc2.acu(n);
103 }
104 return s;
105}
107 const DynLinArr<double>& vc2) {
108 mfunname(
109 "DoubleAc operator-(const DynLinArr<DoubleAc>& vc1, const "
110 "DynLinArr<double>& vc2)");
111 const long q1 = vc1.get_qel();
112 const long q2 = vc2.get_qel();
113 check_econd12(q1, !=, q2, mcerr);
115 for (long n = 0; n < q1; n++) {
116 s.acu(n) = vc1.acu(n) - vc2.acu(n);
117 }
118 return s;
119}
120
122 const DynLinArr<DoubleAc>& vc2) {
123 mfunname(
124 "DoubleAc operator+(const DynLinArr<double>& vc1, const "
125 "DynLinArr<DoubleAc>& vc2)");
126 const long q1 = vc1.get_qel();
127 const long q2 = vc2.get_qel();
128 check_econd12(q1, !=, q2, mcerr);
130 for (long n = 0; n < q1; n++) {
131 s.acu(n) = vc1.acu(n) + vc2.acu(n);
132 }
133 return s;
134}
136 const DynLinArr<DoubleAc>& vc2) {
137 mfunname(
138 "DoubleAc operator-(const DynLinArr<double>& vc1, const "
139 "DynLinArr<DoubleAc>& vc2)");
140 const long q1 = vc1.get_qel();
141 const long q2 = vc2.get_qel();
142 check_econd12(q1, !=, q2, mcerr);
144 for (long n = 0; n < q1; n++) {
145 s.acu(n) = vc1.acu(n) - vc2.acu(n);
146 }
147 return s;
148}
149
151 const DynArr<double>& mt2) {
152 mfunname(
153 "DynArr<DoubleAc> operator+(const DynArr<DoubleAc>& mt1, const "
154 "DynArr<double>& mt2)");
155 const long qdim1 = mt1.get_qdim();
156 const long qdim2 = mt2.get_qdim();
157 check_econd12(qdim1, !=, qdim2, mcerr);
158 const DynLinArr<long>& qe1 = mt1.get_qel();
159 const DynLinArr<long>& qe2 = mt2.get_qel();
160 check_econd12(qe1, !=, qe2, mcerr);
161 DynArr<DoubleAc> ms(mt1);
162 IterDynArr<DoubleAc> iter(&ms);
163 DoubleAc* at;
164 while ((at = iter.more()) != NULL) {
165 (*at) = (*at) + mt2.acu(iter.get_ncur());
166 }
167 return ms;
168}
170 const DynArr<double>& mt2) {
171 mfunname(
172 "DynArr<DoubleAc> operator-(const DynArr<DoubleAc>& mt1, const "
173 "DynArr<double>& mt2)");
174 long qdim1 = mt1.get_qdim();
175 long qdim2 = mt2.get_qdim();
176 check_econd12(qdim1, !=, qdim2, mcerr);
177 const DynLinArr<long>& qe1 = mt1.get_qel();
178 const DynLinArr<long>& qe2 = mt2.get_qel();
179 check_econd12(qe1, !=, qe2, mcerr);
180 DynArr<DoubleAc> ms(mt1);
181 IterDynArr<DoubleAc> iter(&ms);
182 DoubleAc* at;
183 while ((at = iter.more()) != NULL) {
184 (*at) = (*at) - mt2.acu(iter.get_ncur());
185 }
186 return ms;
187}
188
190 const DynArr<DoubleAc>& mt2) {
191 mfunname(
192 "DynArr<DoubleAc> operator+(const DynArr<double>& mt1, const "
193 "DynArr<DoubleAc>& 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(mt2);
201 IterDynArr<DoubleAc> iter(&ms);
202 DoubleAc* at;
203 while ((at = iter.more()) != NULL) {
204 (*at) = (*at) + mt1.acu(iter.get_ncur());
205 }
206 return ms;
207}
208
210 const DynArr<DoubleAc>& mt2) {
211 mfunname(
212 "DynArr<DoubleAc> operator-(const DynArr<double>& mt1, const "
213 "DynArr<DoubleAc>& mt2)");
214 long qdim1 = mt1.get_qdim();
215 long qdim2 = mt2.get_qdim();
216 check_econd12(qdim1, !=, qdim2, mcerr);
217 const DynLinArr<long>& qe1 = mt1.get_qel();
218 const DynLinArr<long>& qe2 = mt2.get_qel();
219 check_econd12(qe1, !=, qe2, mcerr);
220 DynArr<DoubleAc> ms(mt2);
221 IterDynArr<DoubleAc> iter(&ms);
222 DoubleAc* at;
223 while ((at = iter.more()) != NULL) {
224 (*at) = -(*at) + mt1.acu(iter.get_ncur());
225 }
226 return ms;
227}
228
229}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:163
#define mfunname(string)
Definition: FunNameStack.h:45
T & acu(long i1)
Definition: AbsArr.h:1737
const DynLinArr< long > & get_qel(void) const
Definition: AbsArr.h:2169
long get_qdim(void) const
Definition: AbsArr.h:2168
long get_qel(void) const
Definition: AbsArr.h:283
T & acu(long n)
Definition: AbsArr.h:247
const DynLinArr< long > & get_ncur(void) const
Definition: AbsArr.h:2398
T * more(void)
Definition: AbsArr.h:2370
Definition: BGMesh.cpp:5
DoubleAc operator+(const DoubleAc &f1, const DoubleAc &f2)
Definition: DoubleAc.h:431
DoubleAc operator-(const DoubleAc &f)
Definition: DoubleAc.h:419
DoubleAc operator*(const DoubleAc &f1, const DoubleAc &f2)
Definition: DoubleAc.h:523
#define mcerr
Definition: prstream.h:128