ATLAS Offline Software
Loading...
Searching...
No Matches
ProjectionMatricesSet.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6// ProjectionMatricesSet.cxx, (c) ATLAS Detector software
8
10#include <cmath>
11
13 m_maxdim(maxdim)
14{
15
16 // the number of projection matrices is 2**(maxdim),
17 // it is the possible number of binary numbers of with maxdim digits
18 int numMatrices = int(pow(2,m_maxdim));
19
20 for (int imatx=0; imatx<numMatrices; ++imatx){
21
22 std::vector<int> accessorInt(m_maxdim);
23 std::vector<bool> parameterTag(m_maxdim);
24 unsigned int cols = 0;
25 for (int itag = 0, ipos = 1; itag < m_maxdim; ++itag, ipos *= 2) {
26 bool bit = (imatx & ipos);
27 parameterTag[itag] = bit;
28 if (bit) {
29 ++cols;
30 }
31 }
32
33 //By default set zero
34 Amg::MatrixX reduction;
35 reduction.setZero();
36 Amg::MatrixX expansion;
37 expansion.setZero();
38 if (cols){
39 // rows and cols - initialized to zero
40 reduction = Amg::MatrixX(m_maxdim, cols);
41 reduction.setZero();
42 // go through the rows and fill them
43 int reduc = 0;
44 for (int irow = 0; irow<m_maxdim; irow++)
45 {
46 int icol = irow - reduc;
47 // avoids couting to col 4 for int(0b01111) = 15 matrix
48 icol = (icol < int(cols)) ? icol : cols-1;
49 reduction(irow,icol) = parameterTag[irow] ? 1. : 0.;
50 if (!parameterTag[irow])
51 {
52 accessorInt[irow] = -100;
53 ++reduc;
54 } else {
55 accessorInt[irow] = reduc;
56 }
57 }
58 // the expansion matrix is the transposed reduction matrix
59 expansion = Amg::MatrixX(reduction.transpose());
60 }
61 // store them
62 m_reductions.push_back(reduction);
63 m_expansions.push_back(expansion);
64 m_accessors.push_back(accessorInt);
65 }
66
67}
constexpr int pow(int base, int exp) noexcept
std::vector< std::vector< int > > m_accessors
std::vector< Amg::MatrixX > m_expansions
std::vector< Amg::MatrixX > m_reductions
ProjectionMatricesSet(int maxdim)
Explicit constructor for 1-dimensional vector.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.