ergo
|
00001 /* Ergo, version 3.2, a program for linear scaling electronic structure 00002 * calculations. 00003 * Copyright (C) 2012 Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek. 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 * 00018 * Primary academic reference: 00019 * KohnâSham Density Functional Theory Electronic Structure Calculations 00020 * with Linearly Scaling Computational Time and Memory Usage, 00021 * Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek, 00022 * J. Chem. Theory Comput. 7, 340 (2011), 00023 * <http://dx.doi.org/10.1021/ct100611z> 00024 * 00025 * For further information about Ergo, see <http://www.ergoscf.org>. 00026 */ 00027 00028 #ifndef MAT_SIZESANDBLOCKS 00029 #define MAT_SIZESANDBLOCKS 00030 #include "matInclude.h" 00031 namespace mat{ 00032 00037 class SizesAndBlocks { 00038 public: 00040 SizesAndBlocks() 00041 :nBlocks(0), nScalars(0), offset(0), nTotalScalars(0) {} 00043 SizesAndBlocks(SizesAndBlocks const & other); 00048 SizesAndBlocks(std::vector<int> const & blockSizesInp, 00049 int const nScalarsInp) 00050 : nBlocks(0), 00051 nScalars(nScalarsInp), offset(0), nTotalScalars(nScalarsInp) { 00052 setup(blockSizesInp); 00053 } 00055 SizesAndBlocks& operator= 00056 (SizesAndBlocks const & other); 00057 00058 bool operator==(SizesAndBlocks const & other) const; 00059 00060 SizesAndBlocks 00061 getSizesAndBlocksForLowerLevel(int const blockNumber) const; 00062 00063 inline bool is_empty() const {return blockSizes.empty();} 00064 inline int const & getNBlocks() const {return nBlocks;} 00065 inline int const & getNScalars() const {return nScalars;} 00066 void getBlockSizeVector(std::vector<int> & blockSizesCopy) const; 00071 inline int whichBlock(int const globalIndex) const { 00072 return (globalIndex - offset) / blockSizes[0]; /* Integer division */ 00073 } 00074 00075 inline int getOffset() const {return offset;} 00076 inline int getNTotalScalars() const {return nTotalScalars;} 00077 ~SizesAndBlocks() {} 00078 protected: 00079 std::vector<int> blockSizes; 00087 int nBlocks; 00092 int nScalars; 00093 int offset; 00094 int nTotalScalars; 00096 SizesAndBlocks(std::vector<int> const & blockSizesInp, 00097 int const nScalarsInp, 00098 int const offsetInp, 00099 int const nTotalScalarsInp) 00100 : nBlocks(0), 00101 nScalars(nScalarsInp), offset(offsetInp), 00102 nTotalScalars(nTotalScalarsInp) { 00103 setup(blockSizesInp); 00104 } 00105 00106 void setup(std::vector<int> const & blockSizesInp); 00107 00108 private: 00109 }; /* end of class SizesAndBlocks */ 00110 00111 } /* end namespace mat */ 00112 #endif