softsusy
is hosted by
Hepforge
,
IPPP Durham
SOFTSUSY
4.1
src
xpr-matrix.h
Go to the documentation of this file.
1
10
#ifndef XPR_MATRIX_H
11
#define XPR_MATRIX_H
12
13
#include "
xpr-base.h
"
14
#include "
mycomplex.h
"
15
16
17
/******************* ADDITION ******************************/
19
template
<
typename
T,
typename
A,
typename
B>
20
MatXpr
< T,
21
MatXprBinOp
<T,
22
MatConstRef<T,MatIndexable<T,A>
>,
23
MatConstRef<T,MatIndexable<T,B>
>,
24
OpAdd<T>
> >
25
operator+
(
const
MatIndexable<T,A>
& a,
const
MatIndexable<T,B>
& b )
26
{
27
typedef
MatXprBinOp< T, MatConstRef<T,MatIndexable<T,A>
>,
28
MatConstRef<T,MatIndexable<T,B>
>,
29
OpAdd<T>
> ExprT;
30
31
return
MatXpr< T, ExprT >
(
32
ExprT(
MatConstRef
<T,
MatIndexable<T,A>
>(a),
33
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
34
}
35
37
template
<
typename
T,
typename
A,
typename
B>
38
MatXpr
< T,
39
MatXprBinOp
<T,
40
MatConstRef<T,MatXpr<T,A>
>,
41
MatConstRef<T,MatIndexable<T,B>
>,
42
OpAdd<T>
> >
43
operator+
(
const
MatXpr<T,A>
& a,
const
MatIndexable<T,B>
& b )
44
{
45
typedef
MatXprBinOp< T, MatConstRef<T,MatXpr<T,A>
>,
46
MatConstRef<T,MatIndexable<T,B>
>,
47
OpAdd<T>
> ExprT;
48
49
return
MatXpr< T, ExprT >
(
50
ExprT(
MatConstRef
<T,
MatXpr<T,A>
>(a),
51
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
52
}
53
55
template
<
typename
T,
typename
A,
typename
B>
56
MatXpr
< T,
57
MatXprBinOp
<T,
58
MatConstRef<T,MatIndexable<T,A>
>,
59
MatConstRef<T,MatXpr<T,B>
>,
60
OpAdd<T>
> >
61
operator+
(
const
MatIndexable<T,A>
& a,
const
MatXpr<T,B>
& b )
62
{
63
typedef
MatXprBinOp< T, MatConstRef<T,MatIndexable<T,A>
>,
64
MatConstRef<T,MatXpr<T,B>
>,
65
OpAdd<T>
> ExprT;
66
67
return
MatXpr< T, ExprT >
(
68
ExprT(
MatConstRef
<T,
MatIndexable<T,A>
>(a),
69
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
70
}
71
73
template
<
typename
T,
typename
A,
typename
B>
74
MatXpr
< T,
75
MatXprBinOp
<T,
76
MatConstRef<T,MatXpr<T,A>
>,
77
MatConstRef<T,MatXpr<T,B>
>,
78
OpAdd<T>
> >
79
operator+
(
const
MatXpr<T,A>
& a,
const
MatXpr<T,B>
& b )
80
{
81
typedef
MatXprBinOp< T, MatConstRef<T,MatXpr<T,A>
>,
82
MatConstRef<T,MatXpr<T,B>
>,
83
OpAdd<T>
> ExprT;
84
85
return
MatXpr< T, ExprT >
(
86
ExprT(
MatConstRef
<T,
MatXpr<T,A>
>(a),
87
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
88
}
89
90
/****** ADDITION TO TRACE *******************/
92
template
<
typename
T,
typename
B>
93
MatXpr
< T,
94
MatXprScalDiagOp1
<T,
95
MatConstRef<T,MatIndexable<T,B>
>,
96
OpAdd<T>
> >
97
operator+
( T a,
const
MatIndexable<T,B>
& b )
98
{
99
typedef
MatXprScalDiagOp1
< T,
100
MatConstRef<T,MatIndexable<T,B>
>,
101
OpAdd<T>
> ExprT;
102
103
return
MatXpr< T, ExprT >
(
104
ExprT( a,
105
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
106
}
107
109
template
<
typename
T,
typename
B>
110
MatXpr
< T,
111
MatXprScalDiagOp2
<T,
112
MatConstRef<T,MatIndexable<T,B>
>,
113
OpAdd<T>
> >
114
operator+
(
const
MatIndexable<T,B>
& b, T a )
115
{
116
typedef
MatXprScalDiagOp2
< T,
117
MatConstRef<T,MatIndexable<T,B>
>,
118
OpAdd<T>
> ExprT;
119
120
return
MatXpr< T, ExprT >
(
121
ExprT(
122
MatConstRef
<T,
MatIndexable<T,B>
>(b) , a));
123
}
124
126
template
<
typename
T,
typename
B>
127
MatXpr
< T,
128
MatXprScalDiagOp1
<T,
129
MatConstRef<T,MatXpr<T,B>
>,
130
OpAdd<T>
> >
131
operator+
( T a,
const
MatXpr<T,B>
& b )
132
{
133
typedef
MatXprScalDiagOp1
< T,
134
MatConstRef<T,MatXpr<T,B>
>,
135
OpAdd<T>
> ExprT;
136
137
return
MatXpr< T, ExprT >
(
138
ExprT( a,
139
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
140
}
141
143
template
<
typename
T,
typename
B>
144
MatXpr
< T,
145
MatXprScalDiagOp2
<T,
146
MatConstRef<T,MatXpr<T,B>
>,
147
OpAdd<T>
> >
148
operator+
(
const
MatXpr<T,B>
& b, T a )
149
{
150
typedef
MatXprScalDiagOp2
< T,
151
MatConstRef<T,MatXpr<T,B>
>,
152
OpAdd<T>
> ExprT;
153
154
return
MatXpr< T, ExprT >
(
155
ExprT(
156
MatConstRef
<T,
MatXpr<T,B>
>(b) , a));
157
}
158
159
160
161
/******************* SUBTRACTION ******************************/
163
template
<
typename
T,
typename
A,
typename
B>
164
MatXpr
< T,
165
MatXprBinOp
<T,
166
MatConstRef<T,MatIndexable<T,A>
>,
167
MatConstRef<T,MatIndexable<T,B>
>,
168
OpSubtract<T>
> >
169
operator-
(
const
MatIndexable<T,A>
& a,
const
MatIndexable<T,B>
& b )
170
{
171
typedef
MatXprBinOp< T, MatConstRef<T,MatIndexable<T,A>
>,
172
MatConstRef<T,MatIndexable<T,B>
>,
173
OpSubtract<T>
> ExprT;
174
175
return
MatXpr< T, ExprT >
(
176
ExprT(
MatConstRef
<T,
MatIndexable<T,A>
>(a),
177
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
178
}
179
181
template
<
typename
T,
typename
A,
typename
B>
182
MatXpr
< T,
183
MatXprBinOp
<T,
184
MatConstRef<T,MatXpr<T,A>
>,
185
MatConstRef<T,MatIndexable<T,B>
>,
186
OpSubtract<T>
> >
187
operator-
(
const
MatXpr<T,A>
& a,
const
MatIndexable<T,B>
& b )
188
{
189
typedef
MatXprBinOp< T, MatConstRef<T,MatXpr<T,A>
>,
190
MatConstRef<T,MatIndexable<T,B>
>,
191
OpSubtract<T>
> ExprT;
192
193
return
MatXpr< T, ExprT >
(
194
ExprT(
MatConstRef
<T,
MatXpr<T,A>
>(a),
195
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
196
}
197
199
template
<
typename
T,
typename
A,
typename
B>
200
MatXpr
< T,
201
MatXprBinOp
<T,
202
MatConstRef<T,MatIndexable<T,A>
>,
203
MatConstRef<T,MatXpr<T,B>
>,
204
OpSubtract<T>
> >
205
operator-
(
const
MatIndexable<T,A>
& a,
const
MatXpr<T,B>
& b )
206
{
207
typedef
MatXprBinOp< T, MatConstRef<T,MatIndexable<T,A>
>,
208
MatConstRef<T,MatXpr<T,B>
>,
209
OpSubtract<T>
> ExprT;
210
211
return
MatXpr< T, ExprT >
(
212
ExprT(
MatConstRef
<T,
MatIndexable<T,A>
>(a),
213
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
214
}
215
217
template
<
typename
T,
typename
A,
typename
B>
218
MatXpr
< T,
219
MatXprBinOp
<T,
220
MatConstRef<T,MatXpr<T,A>
>,
221
MatConstRef<T,MatXpr<T,B>
>,
222
OpSubtract<T>
> >
223
operator-
(
const
MatXpr<T,A>
& a,
const
MatXpr<T,B>
& b )
224
{
225
typedef
MatXprBinOp< T, MatConstRef<T,MatXpr<T,A>
>,
226
MatConstRef<T,MatXpr<T,B>
>,
227
OpSubtract<T>
> ExprT;
228
229
return
MatXpr< T, ExprT >
(
230
ExprT(
MatConstRef
<T,
MatXpr<T,A>
>(a),
231
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
232
}
233
234
/************* OUTER PRODUCT ************/
236
template
<
typename
T,
typename
A,
typename
B>
237
MatXpr
< T,
238
MatXprOuterOp
<T,
239
ConstRef<T,Xpr<T,A>
>,
240
ConstRef<T,Xpr<T,B>
>,
241
OpMultiply<T>
> >
242
outerProduct
(
const
Xpr<T,A>
& a,
const
Xpr<T,B>
& b )
243
{
244
typedef
MatXprOuterOp< T, ConstRef<T,Xpr<T,A>
>,
245
ConstRef<T,Xpr<T,B>
>,
246
OpMultiply<T>
> ExprT;
247
248
return
MatXpr< T, ExprT >
(
249
ExprT(
ConstRef
<T,
Xpr<T,A>
>(a),
250
ConstRef
<T,
Xpr<T,B>
>(b) ));
251
}
252
254
template
<
typename
T,
typename
A,
typename
B>
255
MatXpr
< T,
256
MatXprOuterOp
<T,
257
ConstRef<T,Indexable<T,A>
>,
258
ConstRef<T,Xpr<T,B>
>,
259
OpMultiply<T>
> >
260
outerProduct
(
const
Indexable<T,A>
& a,
const
Xpr<T,B>
& b )
261
{
262
typedef
MatXprOuterOp< T, ConstRef<T,Indexable<T,A>
>,
263
ConstRef<T,Xpr<T,B>
>,
264
OpMultiply<T>
> ExprT;
265
266
return
MatXpr< T, ExprT >
(
267
ExprT(
ConstRef
<T,
Indexable<T,A>
>(a),
268
ConstRef
<T,
Xpr<T,B>
>(b) ));
269
}
270
272
template
<
typename
T,
typename
A,
typename
B>
273
MatXpr
< T,
274
MatXprOuterOp
<T,
275
ConstRef<T,Xpr<T,A>
>,
276
ConstRef<T,Indexable<T,B>
>,
277
OpMultiply<T>
> >
278
outerProduct
(
const
Xpr<T,A>
& a,
const
Indexable<T,B>
& b )
279
{
280
typedef
MatXprOuterOp< T, ConstRef<T,Xpr<T,A>
>,
281
ConstRef<T,Indexable<T,B>
>,
282
OpMultiply<T>
> ExprT;
283
284
return
MatXpr< T, ExprT >
(
285
ExprT(
ConstRef
<T,
Xpr<T,A>
>(a),
286
ConstRef
<T,
Indexable<T,B>
>(b) ));
287
}
288
290
template
<
typename
T,
typename
A,
typename
B>
291
MatXpr
< T,
292
MatXprOuterOp
<T,
293
ConstRef<T,Indexable<T,A>
>,
294
ConstRef<T,Indexable<T,B>
>,
295
OpMultiply<T>
> >
296
outerProduct
(
const
Indexable<T,A>
& a,
const
Indexable<T,B>
& b )
297
{
298
typedef
MatXprOuterOp< T, ConstRef<T,Indexable<T,A>
>,
299
ConstRef<T,Indexable<T,B>
>,
300
OpMultiply<T>
> ExprT;
301
302
return
MatXpr< T, ExprT >
(
303
ExprT(
ConstRef
<T,
Indexable<T,A>
>(a),
304
ConstRef
<T,
Indexable<T,B>
>(b) ));
305
}
306
307
/************* UNARY NEGATIVE **************/
309
template
<
typename
T,
typename
A>
310
MatXpr
< T,
311
MatXprUnaryOp
<T,
312
MatConstRef<T,MatXpr<T,A>
>,
313
OpNegate<T>
> >
314
operator-
(
const
MatXpr<T,A>
& a )
315
{
316
typedef
MatXprUnaryOp< T, MatConstRef<T,MatXpr<T,A>
>,
317
OpNegate<T>
> ExprT;
318
319
return
MatXpr< T, ExprT >
(
320
ExprT(
MatConstRef
<T,
MatXpr<T,A>
>(a) ));
321
}
322
324
template
<
typename
T,
typename
A>
325
MatXpr
< T,
326
MatXprUnaryOp
<T,
327
MatConstRef<T,MatIndexable<T,A>
>,
328
OpNegate<T>
> >
329
operator-
(
const
MatIndexable<T,A>
& a )
330
{
331
typedef
MatXprUnaryOp< T, MatConstRef<T,MatIndexable<T,A>
>,
332
OpNegate<T>
> ExprT;
333
334
return
MatXpr< T, ExprT >
(
335
ExprT(
MatConstRef
<T,
MatIndexable<T,A>
>(a) ));
336
}
337
338
/****** SUBTRACTION FROM TRACE *******************/
340
template
<
typename
T,
typename
B>
341
MatXpr
< T,
342
MatXprScalDiagOp1
<T,
343
MatConstRef<T,MatIndexable<T,B>
>,
344
OpSubtract<T>
> >
345
operator-
( T a,
const
MatIndexable<T,B>
& b )
346
{
347
typedef
MatXprScalDiagOp1
< T,
348
MatConstRef<T,MatIndexable<T,B>
>,
349
OpSubtract<T>
> ExprT;
350
351
return
MatXpr< T, ExprT >
(
352
ExprT( a,
353
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
354
}
355
357
template
<
typename
T,
typename
B>
358
MatXpr
< T,
359
MatXprScalDiagOp2
<T,
360
MatConstRef<T,MatIndexable<T,B>
>,
361
OpSubtract<T>
> >
362
operator-
(
const
MatIndexable<T,B>
& b, T a )
363
{
364
typedef
MatXprScalDiagOp2
< T,
365
MatConstRef<T,MatIndexable<T,B>
>,
366
OpSubtract<T>
> ExprT;
367
368
return
MatXpr< T, ExprT >
(
369
ExprT(
MatConstRef
<T,
MatIndexable<T,B>
>(b) , a));
370
}
371
373
template
<
typename
T,
typename
B>
374
MatXpr
< T,
375
MatXprScalDiagOp1
<T,
376
MatConstRef<T,MatXpr<T,B>
>,
377
OpSubtract<T>
> >
378
operator-
( T a,
const
MatXpr<T,B>
& b )
379
{
380
typedef
MatXprScalDiagOp1
< T,
381
MatConstRef<T,MatXpr<T,B>
>,
382
OpSubtract<T>
> ExprT;
383
384
return
MatXpr< T, ExprT >
(
385
ExprT( a,
386
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
387
}
388
390
template
<
typename
T,
typename
B>
391
MatXpr
< T,
392
MatXprScalDiagOp2
<T,
393
MatConstRef<T,MatXpr<T,B>
>,
394
OpSubtract<T>
> >
395
operator-
(
const
MatXpr<T,B>
& b, T a )
396
{
397
typedef
MatXprScalDiagOp2
< T,
398
MatConstRef<T,MatXpr<T,B>
>,
399
OpSubtract<T>
> ExprT;
400
401
return
MatXpr< T, ExprT >
(
402
ExprT(
MatConstRef
<T,
MatXpr<T,B>
>(b) , a ));
403
}
404
406
template
<
typename
T,
typename
B>
407
MatXpr
< T,
408
MatXprScalOp
<T,
409
MatConstRef<T,MatIndexable<T,B>
>,
410
OpMultiply<T>
> >
411
operator*
( T a,
const
MatIndexable<T,B>
& b )
412
{
413
typedef
MatXprScalOp
< T,
414
MatConstRef<T,MatIndexable<T,B>
>,
415
OpMultiply<T>
> ExprT;
416
417
return
MatXpr< T, ExprT >
( ExprT( a,
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
418
}
419
421
template
<
typename
T,
typename
B>
422
MatXpr
< T,
423
MatXprScalOp
<T,
424
MatConstRef<T,MatIndexable<T,B>
>,
425
OpMultiply<T>
> >
426
operator*
(
int
a,
const
MatIndexable<T,B>
& b )
427
{
428
typedef
MatXprScalOp
< T,
429
MatConstRef<T,MatIndexable<T,B>
>,
430
OpMultiply<T>
> ExprT;
431
432
return
MatXpr< T, ExprT >
( ExprT(
static_cast<
T
>
(a),
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
433
}
434
436
template
<
typename
B>
437
MatXpr
<
Complex
,
438
MatXprScalOp
<
Complex
,
439
MatConstRef<Complex,MatIndexable<Complex,B>
>,
440
OpMultiply<Complex>
> >
441
operator*
(
double
a,
const
MatIndexable<Complex,B>
& b )
442
{
443
typedef
MatXprScalOp
<
Complex
,
444
MatConstRef<Complex,MatIndexable<Complex,B>
>,
445
OpMultiply<Complex>
> ExprT;
446
447
return
MatXpr< Complex, ExprT >
( ExprT( a,
MatConstRef
<
Complex
,
MatIndexable<Complex,B>
>(b) ));
448
}
449
451
template
<
typename
B>
452
MatXpr
<
Complex
,
453
MatXprScalOp
<
Complex
,
454
MatConstRef<Complex,MatXpr<Complex,B>
>,
455
OpMultiply<Complex>
> >
456
operator*
(
double
a,
const
MatXpr<Complex,B>
& b )
457
{
458
typedef
MatXprScalOp
<
Complex
,
459
MatConstRef<Complex,MatXpr<Complex,B>
>,
460
OpMultiply<Complex>
> ExprT;
461
462
return
MatXpr< Complex, ExprT >
( ExprT( a,
MatConstRef
<
Complex
,
MatXpr<Complex,B>
>(b) ));
463
}
464
466
template
<
typename
B>
467
MatXpr
<
Complex
,
468
MatXprScalOp
<
Complex
,
469
MatConstRef<Complex,MatIndexable<Complex,B>
>,
470
OpMultiply<Complex>
> >
471
operator*
(
const
MatIndexable<Complex,B>
& b ,
double
a)
472
{
473
typedef
MatXprScalOp
<
Complex
,
474
MatConstRef<Complex,MatIndexable<Complex,B>
>,
475
OpMultiply<Complex>
> ExprT;
476
477
return
MatXpr< Complex, ExprT >
( ExprT( a,
MatConstRef
<
Complex
,
MatIndexable<Complex,B>
>(b) ));
478
}
479
481
template
<
typename
B>
482
MatXpr
<
Complex
,
483
MatXprScalOp
<
Complex
,
484
MatConstRef<Complex,MatXpr<Complex,B>
>,
485
OpMultiply<Complex>
> >
486
operator*
(
const
MatXpr<Complex,B>
& b ,
double
a)
487
{
488
typedef
MatXprScalOp
<
Complex
,
489
MatConstRef<Complex,MatXpr<Complex,B>
>,
490
OpMultiply<Complex>
> ExprT;
491
492
return
MatXpr< Complex, ExprT >
( ExprT( a,
MatConstRef
<
Complex
,
MatXpr<Complex,B>
>(b) ));
493
}
494
495
497
template
<
typename
T,
typename
B>
498
MatXpr
< T,
499
MatXprScalOp
<T,
500
MatConstRef<T,MatIndexable<T,B>
>,
501
OpMultiply<T>
> >
502
operator*
(
const
MatIndexable<T,B>
& b, T a )
503
{
504
typedef
MatXprScalOp
< T,
505
MatConstRef<T,MatIndexable<T,B>
>,
506
OpMultiply<T>
> ExprT;
507
508
return
MatXpr< T, ExprT >
(
509
ExprT( a,
510
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
511
}
512
514
template
<
typename
T,
typename
B>
515
MatXpr
< T,
516
MatXprScalOp
<T,
517
MatConstRef<T,MatIndexable<T,B>
>,
518
OpMultiply<T>
> >
519
operator*
(
const
MatIndexable<T,B>
& b,
int
a )
520
{
521
typedef
MatXprScalOp
< T,
522
MatConstRef<T,MatIndexable<T,B>
>,
523
OpMultiply<T>
> ExprT;
524
525
return
MatXpr< T, ExprT >
(
526
ExprT(
static_cast<
T
>
(a),
527
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
528
}
529
531
template
<
typename
T,
typename
B>
532
MatXpr
< T,
533
MatXprScalOp
<T,
534
MatConstRef<T,MatXpr<T,B>
>,
535
OpMultiply<T>
> >
536
operator*
( T a,
const
MatXpr<T,B>
& b )
537
{
538
typedef
MatXprScalOp
< T,
539
MatConstRef<T,MatXpr<T,B>
>,
540
OpMultiply<T>
> ExprT;
541
542
return
MatXpr< T, ExprT >
(
543
ExprT( a,
544
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
545
}
546
548
template
<
typename
T,
typename
B>
549
MatXpr
< T,
550
MatXprScalOp
<T,
551
MatConstRef<T,MatXpr<T,B>
>,
552
OpMultiply<T>
> >
553
operator*
(
int
a,
const
MatXpr<T,B>
& b )
554
{
555
typedef
MatXprScalOp
< T,
556
MatConstRef<T,MatXpr<T,B>
>,
557
OpMultiply<T>
> ExprT;
558
559
return
MatXpr< T, ExprT >
(
560
ExprT(
static_cast<
T
>
(a),
561
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
562
}
563
565
template
<
typename
T,
typename
B>
566
MatXpr
< T,
567
MatXprScalOp
<T,
568
MatConstRef<T,MatXpr<T,B>
>,
569
OpMultiply<T>
> >
570
operator*
(
const
MatXpr<T,B>
& b, T a )
571
{
572
typedef
MatXprScalOp
< T,
573
MatConstRef<T,MatXpr<T,B>
>,
574
OpMultiply<T>
> ExprT;
575
576
return
MatXpr< T, ExprT >
(
577
ExprT( a,
578
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
579
}
580
582
template
<
typename
T,
typename
B>
583
MatXpr
< T,
584
MatXprScalOp
<T,
585
MatConstRef<T,MatXpr<T,B>
>,
586
OpMultiply<T>
> >
587
operator*
(
const
MatXpr<T,B>
& b,
int
a )
588
{
589
typedef
MatXprScalOp
< T,
590
MatConstRef<T,MatXpr<T,B>
>,
591
OpMultiply<T>
> ExprT;
592
593
return
MatXpr< T, ExprT >
(
594
ExprT(
static_cast<
T
>
(a),
595
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
596
}
597
598
/****** DIVIDE BY SCALAR ***************/
600
template
<
typename
T,
typename
B >
601
MatXpr< T, MatXprScalOp<T, MatConstRef<T,MatIndexable<T,B>
>,
OpMultiply<T>
> >
602
operator/
(
const
MatIndexable<T,B>
& b, T a )
603
{
604
typedef
MatXprScalOp< T, MatConstRef<T,MatIndexable<T,B>
>,
OpMultiply<T>
> ExprT;
605
606
return
MatXpr< T, ExprT >
(ExprT (1.0/a,
MatConstRef
<T,
MatIndexable<T,B>
>(b)) );
607
}
608
609
611
template
<
typename
T,
typename
B >
612
MatXpr< T, MatXprScalOp<T, MatConstRef<T,MatXpr<T,B>
>,
OpMultiply<T>
> >
613
operator/
(
const
MatXpr<T,B>
& b, T a )
614
{
615
typedef
MatXprScalOp< T, MatConstRef<T,MatXpr<T,B>
>,
OpMultiply<T>
> ExprT;
616
617
return
MatXpr< T, ExprT >
(ExprT (1.0/a,
MatConstRef
<T,
MatXpr<T,B>
>(b)) );
618
}
619
620
621
622
623
/************ MATRIX MULTIPLY ***************/
625
template
<
typename
T,
typename
A,
typename
B>
626
MatXpr
< T,
627
MatXprMatMultOp
<T,
628
MatConstRef<T,MatIndexable<T,A>
>,
629
MatConstRef<T,MatIndexable<T,B>
> > >
630
operator*
(
const
MatIndexable<T,A>
& a,
const
MatIndexable<T,B>
& b )
631
{
632
typedef
MatXprMatMultOp< T, MatConstRef<T,MatIndexable<T,A>
>,
633
MatConstRef<T,MatIndexable<T,B>
> > ExprT;
634
635
return
MatXpr< T, ExprT >
(
636
ExprT(
MatConstRef
<T,
MatIndexable<T,A>
>(a),
637
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
638
}
639
641
template
<
typename
T,
typename
A,
typename
B>
642
MatXpr
< T,
643
MatXprMatMultOp
<T,
644
MatConstRef<T,MatXpr<T,A>
>,
645
MatConstRef<T,MatIndexable<T,B>
> > >
646
operator*
(
const
MatXpr<T,A>
& a,
const
MatIndexable<T,B>
& b )
647
{
648
typedef
MatXprMatMultOp< T, MatConstRef<T,MatXpr<T,A>
>,
649
MatConstRef<T,MatIndexable<T,B>
> > ExprT;
650
651
return
MatXpr< T, ExprT >
(
652
ExprT(
MatConstRef
<T,
MatXpr<T,A>
>(a),
653
MatConstRef
<T,
MatIndexable<T,B>
>(b) ));
654
}
655
657
template
<
typename
T,
typename
A,
typename
B>
658
MatXpr
< T,
659
MatXprMatMultOp
<T,
660
MatConstRef<T,MatIndexable<T,A>
>,
661
MatConstRef<T,MatXpr<T,B>
> > >
662
operator*
(
const
MatIndexable<T,A>
& a,
const
MatXpr<T,B>
& b )
663
{
664
typedef
MatXprMatMultOp< T, MatConstRef<T,MatIndexable<T,A>
>,
665
MatConstRef<T,MatXpr<T,B>
> > ExprT;
666
667
return
MatXpr< T, ExprT >
(
668
ExprT(
MatConstRef
<T,
MatIndexable<T,A>
>(a),
669
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
670
}
671
673
template
<
typename
T,
typename
A,
typename
B>
674
MatXpr
< T,
675
MatXprMatMultOp
<T,
676
MatConstRef<T,MatXpr<T,A>
>,
677
MatConstRef<T,MatXpr<T,B>
> > >
678
operator*
(
const
MatXpr<T,A>
& a,
const
MatXpr<T,B>
& b )
679
{
680
typedef
MatXprMatMultOp< T, MatConstRef<T,MatXpr<T,A>
>,
681
MatConstRef<T,MatXpr<T,B>
> > ExprT;
682
683
return
MatXpr< T, ExprT >
(
684
ExprT(
MatConstRef
<T,
MatXpr<T,A>
>(a),
685
MatConstRef
<T,
MatXpr<T,B>
>(b) ));
686
}
687
689
template
<
typename
A,
typename
B>
690
MatXpr
<
Complex
,
691
MatXprMatMultOp
<
Complex
,
692
MatConstRef<Complex,MatIndexable<Complex,A>
>,
693
MatConstRef<double,MatIndexable<double,B>
> > >
694
operator*
(
const
MatIndexable<Complex,A>
& a,
const
MatIndexable<double,B>
& b )
695
{
696
typedef
MatXprMatMultOp< Complex, MatConstRef<Complex,MatIndexable<Complex,A>
>,
697
MatConstRef<double,MatIndexable<double,B>
> > ExprT;
698
699
return
MatXpr< Complex, ExprT >
(
700
ExprT(
MatConstRef
<
Complex
,
MatIndexable<Complex,A>
>(a),
701
MatConstRef
<
double
,
MatIndexable<double,B>
>(b) ));
702
}
703
705
template
<
typename
A,
typename
B>
706
MatXpr
<
Complex
,
707
MatXprMatMultOp
<
Complex
,
708
MatConstRef<Complex,MatXpr<Complex,A>
>,
709
MatConstRef<double,MatIndexable<double,B>
> > >
710
operator*
(
const
MatXpr<Complex,A>
& a,
const
MatIndexable<double,B>
& b )
711
{
712
typedef
MatXprMatMultOp< Complex, MatConstRef<Complex,MatXpr<Complex,A>
>,
713
MatConstRef<double,MatIndexable<double,B>
> > ExprT;
714
715
return
MatXpr< Complex, ExprT >
(
716
ExprT(
MatConstRef
<
Complex
,
MatXpr<Complex,A>
>(a),
717
MatConstRef
<
double
,
MatIndexable<double,B>
>(b) ));
718
}
719
721
template
<
typename
A,
typename
B>
722
MatXpr
<
Complex
,
723
MatXprMatMultOp
<
Complex
,
724
MatConstRef<Complex,MatIndexable<Complex,A>
>,
725
MatConstRef<double,MatXpr<double,B>
> > >
726
operator*
(
const
MatIndexable<Complex,A>
& a,
const
MatXpr<double,B>
& b )
727
{
728
typedef
MatXprMatMultOp< Complex, MatConstRef<Complex,MatIndexable<Complex,A>
>,
729
MatConstRef<double,MatXpr<double,B>
> > ExprT;
730
731
return
MatXpr< Complex, ExprT >
(
732
ExprT(
MatConstRef
<
Complex
,
MatIndexable<Complex,A>
>(a),
733
MatConstRef
<
double
,
MatXpr<double,B>
>(b) ));
734
}
735
737
template
<
typename
A,
typename
B>
738
MatXpr
<
Complex
,
739
MatXprMatMultOp
<
Complex
,
740
MatConstRef<Complex,MatXpr<Complex,A>
>,
741
MatConstRef<double,MatXpr<double,B>
> > >
742
operator*
(
const
MatXpr<Complex,A>
& a,
const
MatXpr<double,B>
& b )
743
{
744
typedef
MatXprMatMultOp< Complex, MatConstRef<Complex,MatXpr<Complex,A>
>,
745
MatConstRef<double,MatXpr<double,B>
> > ExprT;
746
747
return
MatXpr< Complex, ExprT >
(
748
ExprT(
MatConstRef
<
Complex
,
MatXpr<Complex,A>
>(a),
749
MatConstRef
<
double
,
MatXpr<double,B>
>(b) ));
750
}
751
752
// special 2
754
template
<
typename
A,
typename
B>
755
MatXpr
<
Complex
,
756
MatXprMatMultOp
<
Complex
,
757
MatConstRef<double,MatIndexable<double,A>
>,
758
MatConstRef<Complex,MatIndexable<Complex,B>
> > >
759
operator*
(
const
MatIndexable<double,A>
& a,
const
MatIndexable<Complex,B>
& b )
760
{
761
typedef
MatXprMatMultOp< Complex, MatConstRef<double,MatIndexable<double,A>
>,
762
MatConstRef<Complex,MatIndexable<Complex,B>
> > ExprT;
763
764
return
MatXpr< Complex, ExprT >
(
765
ExprT(
MatConstRef
<
double
,
MatIndexable<double,A>
>(a),
766
MatConstRef
<
Complex
,
MatIndexable<Complex,B>
>(b) ));
767
}
768
770
template
<
typename
A,
typename
B>
771
MatXpr
<
Complex
,
772
MatXprMatMultOp
<
Complex
,
773
MatConstRef<double,MatXpr<double,A>
>,
774
MatConstRef<Complex,MatIndexable<Complex,B>
> > >
775
operator*
(
const
MatXpr<double,A>
& a,
const
MatIndexable<Complex,B>
& b )
776
{
777
typedef
MatXprMatMultOp< Complex, MatConstRef<double,MatXpr<double,A>
>,
778
MatConstRef<Complex,MatIndexable<Complex,B>
> > ExprT;
779
780
return
MatXpr< Complex, ExprT >
(
781
ExprT(
MatConstRef
<
double
,
MatXpr<double,A>
>(a),
782
MatConstRef
<
Complex
,
MatIndexable<Complex,B>
>(b) ));
783
}
784
786
template
<
typename
A,
typename
B>
787
MatXpr
<
Complex
,
788
MatXprMatMultOp
<
Complex
,
789
MatConstRef<double,MatIndexable<double,A>
>,
790
MatConstRef<Complex,MatXpr<Complex,B>
> > >
791
operator*
(
const
MatIndexable<double,A>
& a,
const
MatXpr<Complex,B>
& b )
792
{
793
typedef
MatXprMatMultOp< Complex, MatConstRef<double,MatIndexable<double,A>
>,
794
MatConstRef<Complex,MatXpr<Complex,B>
> > ExprT;
795
796
return
MatXpr< Complex, ExprT >
(
797
ExprT(
MatConstRef
<
double
,
MatIndexable<double,A>
>(a),
798
MatConstRef
<
Complex
,
MatXpr<Complex,B>
>(b) ));
799
}
800
802
template
<
typename
A,
typename
B>
803
MatXpr
<
Complex
,
804
MatXprMatMultOp
<
Complex
,
805
MatConstRef<double,MatXpr<double,A>
>,
806
MatConstRef<Complex,MatXpr<Complex,B>
> > >
807
operator*
(
const
MatXpr<double,A>
& a,
const
MatXpr<Complex,B>
& b )
808
{
809
typedef
MatXprMatMultOp< Complex, MatConstRef<double,MatXpr<double,A>
>,
810
MatConstRef<Complex,MatXpr<Complex,B>
> > ExprT;
811
812
return
MatXpr< Complex, ExprT >
(
813
ExprT(
MatConstRef
<
double
,
MatXpr<double,A>
>(a),
814
MatConstRef
<
Complex
,
MatXpr<Complex,B>
>(b) ));
815
}
816
817
/************ MATRIX * VECTOR MULTIPLY ***************/
819
template
<
typename
T,
typename
A,
typename
B>
820
Xpr
< T,
821
XprMatMultOp
<T,
822
MatConstRef<T,MatIndexable<T,A>
>,
823
ConstRef<T,Indexable<T,B>
> > >
824
operator*
(
const
MatIndexable<T,A>
& a,
const
Indexable<T,B>
& b )
825
{
826
typedef
XprMatMultOp< T, MatConstRef<T,MatIndexable<T,A>
>,
827
ConstRef<T,Indexable<T,B>
> > ExprT;
828
829
return
Xpr< T, ExprT >
(
830
ExprT(
MatConstRef
<T,
MatIndexable<T,A>
>(a),
831
ConstRef
<T,
Indexable<T,B>
>(b) ));
832
}
833
835
template
<
typename
A,
typename
B>
836
Xpr
<
Complex
,
837
XprMatMultOp
<
Complex
,
838
MatConstRef<Complex,MatIndexable<Complex,A>
>,
839
ConstRef<double,Indexable<double,B>
> > >
840
operator*
(
const
MatIndexable<Complex,A>
& a,
const
Indexable<double,B>
& b )
841
{
842
typedef
XprMatMultOp< Complex, MatConstRef<Complex,MatIndexable<Complex,A>
>,
843
ConstRef<double,Indexable<double,B>
> > ExprT;
844
845
return
Xpr< Complex, ExprT >
(
846
ExprT(
MatConstRef
<
Complex
,
MatIndexable<Complex,A>
>(a),
847
ConstRef
<
double
,
Indexable<double,B>
>(b) ));
848
}
849
851
template
<
typename
A,
typename
B>
852
Xpr
<
Complex
,
853
XprMatMultOp
<
Complex
,
854
MatConstRef<double,MatIndexable<double,A>
>,
855
ConstRef<Complex,Indexable<Complex,B>
> > >
856
operator*
(
const
MatIndexable<double,A>
& a,
const
Indexable<Complex,B>
& b )
857
{
858
typedef
XprMatMultOp< Complex, MatConstRef<double,MatIndexable<double,A>
>,
859
ConstRef<Complex,Indexable<Complex,B>
> > ExprT;
860
861
return
Xpr< Complex, ExprT >
(
862
ExprT(
MatConstRef
<
double
,
MatIndexable<double,A>
>(a),
863
ConstRef
<
Complex
,
Indexable<Complex,B>
>(b) ));
864
}
865
866
867
#endif
Complex
drop-in replacement for the original home-grown Complex class
Definition:
mycomplex.h:17
ConstRef
const version of under-object for speed upgrade of linear algebra
Definition:
xpr-base.h:36
Indexable
provides indexing of xpr type objects
Definition:
xpr-base.h:79
MatConstRef
const version of xpr matrix
Definition:
xpr-base.h:209
MatIndexable
Indexable form of xpr matrix.
Definition:
xpr-base.h:373
MatXprBinOp
binary operator between two matrices
Definition:
xpr-base.h:220
MatXprMatMultOp
xpr Matrix multiplication
Definition:
xpr-base.h:252
MatXprOuterOp
outer form of xpr matrix operator
Definition:
xpr-base.h:236
MatXprScalDiagOp1
scalar operator on diagonal parts of xpr matrix
Definition:
xpr-base.h:341
MatXprScalDiagOp2
scalar operator on diagonal parts of xpr matrix - different place for const
Definition:
xpr-base.h:357
MatXprScalOp
scalar operator on xpr matrix
Definition:
xpr-base.h:325
MatXprUnaryOp
unary operator on an xpr matrix
Definition:
xpr-base.h:310
MatXpr
matrix form of xpr object
Definition:
xpr-base.h:191
OpAdd
Add two xpr objects.
Definition:
xpr-base.h:149
OpMultiply
multiply two xpr objects
Definition:
xpr-base.h:169
OpNegate
take the negative of an xpr object
Definition:
xpr-base.h:178
OpSubtract
subtract two xpr objects
Definition:
xpr-base.h:159
XprMatMultOp
another xpr matrix multiplication
Definition:
xpr-base.h:281
Xpr
Under-object for speed upgrade of linear algebra.
Definition:
xpr-base.h:25
mycomplex.h
complex numbers and operators between them
xpr-base.h
Symbolic under-object for vectors/matrices for speed upgrade. The linear algebra operations are often...
operator*
MatXpr< T, MatXprScalOp< T, MatConstRef< T, MatIndexable< T, B > >, OpMultiply< T > > > operator*(T a, const MatIndexable< T, B > &b)
multiply xpr matrix by a scalar
Definition:
xpr-matrix.h:411
outerProduct
MatXpr< T, MatXprOuterOp< T, ConstRef< T, Xpr< T, A > >, ConstRef< T, Xpr< T, B > >, OpMultiply< T > > > outerProduct(const Xpr< T, A > &a, const Xpr< T, B > &b)
outer product of xpr matrices
Definition:
xpr-matrix.h:242
operator-
MatXpr< T, MatXprBinOp< T, MatConstRef< T, MatIndexable< T, A > >, MatConstRef< T, MatIndexable< T, B > >, OpSubtract< T > > > operator-(const MatIndexable< T, A > &a, const MatIndexable< T, B > &b)
xpr matrix subtraction
Definition:
xpr-matrix.h:169
operator+
MatXpr< T, MatXprBinOp< T, MatConstRef< T, MatIndexable< T, A > >, MatConstRef< T, MatIndexable< T, B > >, OpAdd< T > > > operator+(const MatIndexable< T, A > &a, const MatIndexable< T, B > &b)
add two xpr matrices
Definition:
xpr-matrix.h:25
operator/
MatXpr< T, MatXprScalOp< T, MatConstRef< T, MatIndexable< T, B > >, OpMultiply< T > > > operator/(const MatIndexable< T, B > &b, T a)
divide xpr matrix by scalar
Definition:
xpr-matrix.h:602
Generated by
1.9.1