Belle II Software development
PlainMatrixUtil Struct Reference

Utility functions for the PlainMatrix. More...

#include <PlainMatrixUtil.h>

Static Public Member Functions

template<class T , int M>
static PlainMatrix< T, M, M > Diag (const PlainMatrix< T, M, 1 > &diagEntries)
 Construct a diagonal matrix - currently private as it is unused.
 
template<class T , int K, int L, int M, int N>
static PlainMatrix< T, K+M, L+N > BlockStack (const PlainMatrix< T, K, L > &a, const PlainMatrix< T, M, N > &b)
 Construct a matrix from two independent blocks stacked along the diagonal.
 
template<class T , int K, int M, int N>
static PlainMatrix< T, K+M, N > VStack (const PlainMatrix< T, K, N > &a, const PlainMatrix< T, M, N > &b)
 Construct a matrix from two independent blocks stacked vertically.
 
template<class T , int M, int L, int N>
static PlainMatrix< T, M, L+N > HStack (const PlainMatrix< T, M, L > &a, const PlainMatrix< T, M, N > &b)
 Construct a matrix from two independent blocks stacked horizontally.
 

Detailed Description

Utility functions for the PlainMatrix.

Definition at line 20 of file PlainMatrixUtil.h.

Member Function Documentation

◆ BlockStack()

static PlainMatrix< T, K+M, L+N > BlockStack ( const PlainMatrix< T, K, L > &  a,
const PlainMatrix< T, M, N > &  b 
)
inlinestatic

Construct a matrix from two independent blocks stacked along the diagonal.

Definition at line 35 of file PlainMatrixUtil.h.

36 {
37 const int nRows = K + M;
38 // const int nCols = L + N;
39 PlainMatrix < T, K + M, L + N > result{{}}; // Value initialize to zero
40
41 const int nARows = K;
42 const int nACols = L;
43 for (int iACol = 0; iACol < nACols; ++iACol) {
44 std::copy(a.data() + iACol * nARows,
45 a.data() + (iACol + 1) * nARows,
46 result.data() + iACol * nRows);
47 }
48
49 const int nBRows = M;
50 const int nBCols = N;
51 const int skipA = nACols * nRows;
52 const int skipFront = nARows;
53 for (int iBCol = 0; iBCol < nBCols; ++iBCol) {
54 std::copy(b.data() + iBCol * nBRows,
55 b.data() + (iBCol + 1) * nBRows,
56 result.data() + skipA + skipFront + iBCol * nRows);
57 }
58 return result;
59 }
#define K(x)
macro autogenerated by FFTW

◆ Diag()

static PlainMatrix< T, M, M > Diag ( const PlainMatrix< T, M, 1 > &  diagEntries)
inlinestatic

Construct a diagonal matrix - currently private as it is unused.

Definition at line 24 of file PlainMatrixUtil.h.

25 {
26 PlainMatrix<T, M, M> result{{}}; // Value initialize to zero
27 for (size_t s = 0, i = 0; s < result.size(); s += M + 1, ++i)
28 result[s] = diagEntries(i, 0);
29 return result;
30 }

◆ HStack()

static PlainMatrix< T, M, L+N > HStack ( const PlainMatrix< T, M, L > &  a,
const PlainMatrix< T, M, N > &  b 
)
inlinestatic

Construct a matrix from two independent blocks stacked horizontally.

Definition at line 88 of file PlainMatrixUtil.h.

89 {
90 PlainMatrix < T, M, L + N > result;
91 std::copy(a.data(), a.data() + a.size(), result.data());
92 std::copy(b.data(), b.data() + b.size(), result.data() + a.size());
93 return result;
94 }

◆ VStack()

static PlainMatrix< T, K+M, N > VStack ( const PlainMatrix< T, K, N > &  a,
const PlainMatrix< T, M, N > &  b 
)
inlinestatic

Construct a matrix from two independent blocks stacked vertically.

Definition at line 64 of file PlainMatrixUtil.h.

65 {
66 const int nRows = K + M;
67 const int nCols = N;
68 PlainMatrix < T, K + M, N > result;
69
70 const int nARows = K;
71 const int nBRows = M;
72 const int skipFront = nARows;
73 for (int iCol = 0; iCol < nCols; ++iCol) {
74 std::copy(a.data() + iCol * nARows,
75 a.data() + (iCol + 1) * nARows,
76 result.data() + iCol * nRows);
77
78 std::copy(b.data() + iCol * nBRows,
79 b.data() + (iCol + 1) * nBRows,
80 result.data() + skipFront + iCol * nRows);
81 }
82 return result;
83 }

The documentation for this struct was generated from the following file: