Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:24

0001 /*
0002  * BorderedBandMatrix.h
0003  *
0004  *  Created on: Aug 14, 2011
0005  *      Author: kleinwrt
0006  */
0007 
0008 
0009 /** \file
0010  *  BorderedBandMatrix definition.
0011  *
0012  *  \author Claus Kleinwort, DESY, 2011 (Claus.Kleinwort@desy.de)
0013  *
0014  *  \copyright
0015  *  Copyright (c) 2011 - 2016 Deutsches Elektronen-Synchroton,
0016  *  Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY \n\n
0017  *  This library is free software; you can redistribute it and/or modify
0018  *  it under the terms of the GNU Library General Public License as
0019  *  published by the Free Software Foundation; either version 2 of the
0020  *  License, or (at your option) any later version. \n\n
0021  *  This library is distributed in the hope that it will be useful,
0022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0024  *  GNU Library General Public License for more details. \n\n
0025  *  You should have received a copy of the GNU Library General Public
0026  *  License along with this program (see the file COPYING.LIB for more
0027  *  details); if not, write to the Free Software Foundation, Inc.,
0028  *  675 Mass Ave, Cambridge, MA 02139, USA.
0029  */
0030 
0031 #ifndef BORDEREDBANDMATRIX_H_
0032 #define BORDEREDBANDMATRIX_H_
0033 
0034 #include<iostream>
0035 #include<vector>
0036 #include<math.h>
0037 #include<cstdlib>
0038 #include "TVectorD.h"
0039 #include "TMatrixD.h"
0040 #include "TMatrixDSym.h"
0041 #include "VMatrix.h"
0042 
0043 //! Namespace for the general broken lines package
0044 namespace gbl {
0045 
0046 /// (Symmetric) Bordered Band Matrix.
0047 /**
0048  *  Separate storage of border, mixed and band parts (as vector<double>).
0049  *
0050  *\verbatim
0051  *  Example for matrix size=8 with border size and band width of two
0052  *
0053  *     +-                                 -+
0054  *     |  B11 B12 M13 M14 M15 M16 M17 M18  |
0055  *     |  B12 B22 M23 M24 M25 M26 M27 M28  |
0056  *     |  M13 M23 C33 C34 C35  0.  0.  0.  |
0057  *     |  M14 M24 C34 C44 C45 C46  0.  0.  |
0058  *     |  M15 M25 C35 C45 C55 C56 C57  0.  |
0059  *     |  M16 M26  0. C46 C56 C66 C67 C68  |
0060  *     |  M17 M27  0.  0. C57 C67 C77 C78  |
0061  *     |  M18 M28  0.  0.  0. C68 C78 C88  |
0062  *     +-                                 -+
0063  *
0064  *  Is stored as::
0065  *
0066  *     +-         -+     +-                         -+
0067  *     |  B11 B12  |     |  M13 M14 M15 M16 M17 M18  |
0068  *     |  B12 B22  |     |  M23 M24 M25 M26 M27 M28  |
0069  *     +-         -+     +-                         -+
0070  *
0071  *                       +-                         -+
0072  *                       |  C33 C44 C55 C66 C77 C88  |
0073  *                       |  C34 C45 C56 C67 C78  0.  |
0074  *                       |  C35 C46 C57 C68  0.  0.  |
0075  *                       +-                         -+
0076  *\endverbatim
0077  */
0078 
0079 class BorderedBandMatrix {
0080 public:
0081     BorderedBandMatrix();
0082     virtual ~BorderedBandMatrix();
0083     void resize(unsigned int nSize, unsigned int nBorder = 1,
0084             unsigned int nBand = 5);
0085     void solveAndInvertBorderedBand(const VVector &aRightHandSide,
0086             VVector &aSolution);
0087     void addBlockMatrix(double aWeight,
0088             const std::vector<unsigned int>* anIndex,
0089             const std::vector<double>* aVector);
0090     TMatrixDSym getBlockMatrix(const std::vector<unsigned int> &anIndex) const;
0091     void printMatrix() const;
0092 
0093 private:
0094     unsigned int numSize; ///< Matrix size
0095     unsigned int numBorder; ///< Border size
0096     unsigned int numBand; ///< Band width
0097     unsigned int numCol; ///< Band matrix size
0098     VSymMatrix theBorder; ///< Border part
0099     VMatrix theMixed; ///< Mixed part
0100     VMatrix theBand; ///< Band part
0101 
0102     void decomposeBand();
0103     VVector solveBand(const VVector &aRightHandSide) const;
0104     VMatrix solveBand(const VMatrix &aRightHandSide) const;
0105     VMatrix invertBand();
0106     VMatrix bandOfAVAT(const VMatrix &anArray,
0107             const VSymMatrix &aSymArray) const;
0108 };
0109 }
0110 #endif /* BORDEREDBANDMATRIX_H_ */