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

Go to the source code of this file.

Functions

DoubleAc norm_DynLinArr (const DynLinArr< DoubleAc > &f)
 
DoubleAc normsq_DynLinArr (const DynLinArr< DoubleAc > &f)
 
DynLinArr< DoubleAcoperator* (const DynArr< DoubleAc > &mt, const DynLinArr< double > &vc)
 
DynLinArr< DoubleAcoperator* (const DynArr< double > &mt, const DynLinArr< DoubleAc > &vc)
 
DoubleAc operator* (const DynLinArr< DoubleAc > &vc1, const DynLinArr< double > &vc2)
 
DoubleAc operator* (const DynLinArr< double > &vc1, const DynLinArr< DoubleAc > &vc2)
 
DynLinArr< DoubleAcoperator+ (const DynLinArr< DoubleAc > &vc1, const DynLinArr< double > &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< double > &vc1, const DynLinArr< DoubleAc > &vc2)
 
DynArr< DoubleAcoperator+ (const DynArr< DoubleAc > &mt1, const DynArr< double > &mt2)
 
DynArr< DoubleAcoperator- (const DynArr< DoubleAc > &mt1, const DynArr< double > &mt2)
 
DynArr< DoubleAcoperator+ (const DynArr< double > &mt1, const DynArr< DoubleAc > &mt2)
 
DynArr< DoubleAcoperator- (const DynArr< double > &mt1, const DynArr< DoubleAc > &mt2)
 

Function Documentation

◆ norm_DynLinArr()

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
long get_qel(void) const
Definition: AbsArr.h:420

◆ normsq_DynLinArr()

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}

◆ operator*() [1/4]

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
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:380
#define mfunname(string)
Definition: FunNameStack.h:67
T & acu(long i1)
Definition: AbsArr.h:2098
const DynLinArr< long > & get_qel(void) const
Definition: AbsArr.h:2548
T & acu(long n)
Definition: AbsArr.h:372
#define mcerr
Definition: prstream.h:135

◆ operator*() [2/4]

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/4]

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*() [4/4]

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+() [1/4]

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}
long get_qdim(void) const
Definition: AbsArr.h:2547

◆ operator+() [2/4]

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/4]

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+() [4/4]

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-() [1/4]

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/4]

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/4]

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-() [4/4]

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}