Belle II Software development
PlainMatrixUtil.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackFindingCDC/numerics/PlainMatrix.h>
11
12namespace Belle2 {
17 namespace TrackFindingCDC {
18
21
23 template <class T, int M>
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 }
31
33 template <class T, int K, int L, int M, int N>
34 static PlainMatrix < T, K + M, L + N >
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 }
60
62 template <class T, int K, int M, int N>
63 static PlainMatrix < T, K + M, N >
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 }
84
86 template <class T, int M, int L, int N>
87 static PlainMatrix < T, M, L + N >
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 }
95 };
96 }
98}
#define K(x)
macro autogenerated by FFTW
A matrix implementation to be used as an interface typ through out the track finder.
Definition: PlainMatrix.h:40
Abstract base class for different kinds of events.
Utility functions for the PlainMatrix.
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.
static PlainMatrix< T, M, M > Diag(const PlainMatrix< T, M, 1 > &diagEntries)
Construct a diagonal matrix - currently private as it is unused.
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.
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.