⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 block.cc

📁 大型并行量子化学软件;支持密度泛函(DFT)。可以进行各种量子化学计算。支持CHARMM并行计算。非常具有应用价值。
💻 CC
📖 第 1 页 / 共 2 页
字号:
//// block.cc//// Copyright (C) 1996 Limit Point Systems, Inc.//// Author: Curtis Janssen <cljanss@limitpt.com>// Maintainer: LPS//// This file is part of the SC Toolkit.//// The SC Toolkit is free software; you can redistribute it and/or modify// it under the terms of the GNU Library General Public License as published by// the Free Software Foundation; either version 2, or (at your option)// any later version.//// The SC Toolkit is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU Library General Public License for more details.//// You should have received a copy of the GNU Library General Public License// along with the SC Toolkit; see the file COPYING.LIB.  If not, write to// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.//// The U.S. Government is granted a limited license as per AL 91-7.//#ifdef __GNUC__#pragma implementation#endif#include <iostream>#include <string.h>#include <util/state/stateio.h>#include <math/scmat/block.h>#include <math/scmat/blkiter.h>#include <math/scmat/elemop.h>using namespace std;using namespace sc;/////////////////////////////////////////////////////////////////////////////// SCMatrixBlock member functionsstatic ClassDesc SCMatrixBlock_cd(  typeid(SCMatrixBlock),"SCMatrixBlock",1,"public SavableState",  0, 0, 0);SCMatrixBlock::SCMatrixBlock(){  blocki = blockj = -1;}SCMatrixBlock::SCMatrixBlock(StateIn&s):  SavableState(s){  s.get(blocki);  s.get(blockj);}voidSCMatrixBlock::save_data_state(StateOut&s){  s.put(blocki);  s.put(blockj);}SCMatrixBlock::~SCMatrixBlock(){}SCMatrixBlock *SCMatrixBlock::deepcopy() const{  ExEnv::errn() << "SCMatrixBlock of type " << class_name()       << " cannot be deep copied" << endl;  abort();  return 0;}double *SCMatrixBlock::dat(){  ExEnv::errn() << "SCMatrixBlock of type " << class_name()       << " cannot provide internal data" << endl;  abort();  return 0;}intSCMatrixBlock::ndat() const{  ExEnv::errn() << "SCMatrixBlock of type " << class_name()       << " cannot provide size of internal data" << endl;  abort();  return 0;}/////////////////////////////////////////////////////////////////////////////// SCMatrixBlockListLink member functionsSCMatrixBlockListLink::SCMatrixBlockListLink(SCMatrixBlock* b,                                             SCMatrixBlockListLink* l){  block(b);  next(l);}SCMatrixBlockListLink::~SCMatrixBlockListLink(){  if (_block) _block->dereference();  if (_block->nreference() == 0) delete _block;  for (SCMatrixBlockListLink *nexti, *i=_next; i; i = nexti) {      nexti = i->_next;      i->_next = 0;      delete i;    }}voidSCMatrixBlockListLink::block(SCMatrixBlock* b){  _block = b;  if (_block) _block->reference();}/////////////////////////////////////////////////////////////////////////////// SCMatrixBlockList member functionsstatic ClassDesc SCMatrixBlockList_cd(  typeid(SCMatrixBlockList),"SCMatrixBlockList",1,"public SavableState",  0, 0, create<SCMatrixBlockList>);SCMatrixBlockList::SCMatrixBlockList(){  _begin = 0;}SCMatrixBlockList::SCMatrixBlockList(StateIn& s):  SavableState(s){  int i, count;  Ref<SCMatrixBlock> b;  s.get(count);  _begin = 0;  for (i=0; i<count; i++) {      b << SavableState::restore_state(s);      append(b);    }}SCMatrixBlockList::~SCMatrixBlockList(){  if (_begin) delete _begin;}voidSCMatrixBlockList::save_data_state(StateOut&s){  int count = 0;  SCMatrixBlockListIter i;  for (i = begin(); i != end(); i++) count++;  s.put(count);  for (i = begin(); i != end(); i++) {      i.block()->save_state(s);    }}voidSCMatrixBlockList::insert(SCMatrixBlock* b){  _begin = new SCMatrixBlockListLink(b, _begin);}voidSCMatrixBlockList::append(SCMatrixBlock* b){  if (_begin == 0) {      _begin = new SCMatrixBlockListLink(b);    }  else {      SCMatrixBlockListLink* i;      for (i = _begin; i->next() != 0; i = i->next());      i->next(new SCMatrixBlockListLink(b));    }}SCMatrixBlockList *SCMatrixBlockList::deepcopy(){  SCMatrixBlockListIter i;  SCMatrixBlockList *ret = new SCMatrixBlockList();  for (i=begin(); i!=end(); i++) {      ret->append(i.block()->deepcopy());    }  return ret;}/////////////////////////////////////////////////////////////////////////////// SCMatrixRectBlock member functionsstatic ClassDesc SCMatrixRectBlock_cd(  typeid(SCMatrixRectBlock),"SCMatrixRectBlock",1,"public SCMatrixBlock",  0, 0, create<SCMatrixRectBlock>);SCMatrixRectBlock::SCMatrixRectBlock(int is, int ie, int js, int je):  istart(is),  jstart(js),  iend(ie),  jend(je){  data = new double[(ie-is)*(je-js)];}SCMatrixRectBlock::SCMatrixRectBlock(StateIn&s):  SCMatrixBlock(s){  s.get(istart);  s.get(jstart);  s.get(iend);  s.get(jend);  s.get(data);}voidSCMatrixRectBlock::save_data_state(StateOut&s){  SCMatrixBlock::save_data_state(s);  s.put(istart);  s.put(jstart);  s.put(iend);  s.put(jend);  s.put(data,(iend-istart)*(jend-jstart));}SCMatrixBlock *SCMatrixRectBlock::deepcopy() const{  SCMatrixRectBlock *ret = new SCMatrixRectBlock(istart,iend,jstart,jend);  ret->blocki = blocki;  ret->blockj = blockj;  memcpy(ret->data, data, sizeof(double)*ndat());  return ret;}double *SCMatrixRectBlock::dat(){  return data;}intSCMatrixRectBlock::ndat() const{  return (iend-istart)*(jend-jstart);}SCMatrixRectBlock::~SCMatrixRectBlock(){  delete[] data;}voidSCMatrixRectBlock::process(SCElementOp*op){  SCMatrixRectBlockIter i(this);  op->process(i);}voidSCMatrixRectBlock::process(SCElementOp2*op,                           SCMatrixBlock* b){  SCMatrixRectBlockIter i(this);  SCMatrixRectBlockIter j((SCMatrixRectBlock*)b);  op->process(i,j);}voidSCMatrixRectBlock::process(SCElementOp3*op,                           SCMatrixBlock* b1, SCMatrixBlock* b2){  SCMatrixRectBlockIter i(this);  SCMatrixRectBlockIter j((SCMatrixRectBlock*)b1);  SCMatrixRectBlockIter k((SCMatrixRectBlock*)b2);  op->process(i,j,k);}/////////////////////////////////////////////////////////////////////////////// SCMatrixRectSubBlock member functionsstatic ClassDesc SCMatrixRectSubBlock_cd(  typeid(SCMatrixRectSubBlock),"SCMatrixRectSubBlock",1,"public SCMatrixBlock",  0, 0, create<SCMatrixRectSubBlock>);SCMatrixRectSubBlock::SCMatrixRectSubBlock(int is, int ie, int istr,                                           int js, int je, double* d):  istart(is),  jstart(js),  iend(ie),  jend(je),  istride(istr),  data(d){}SCMatrixRectSubBlock::SCMatrixRectSubBlock(StateIn&s):  SCMatrixBlock(s){  s.get(istart);  s.get(istride);  s.get(jstart);  s.get(iend);  s.get(jend);  data = 0;}voidSCMatrixRectSubBlock::save_data_state(StateOut&s){  SCMatrixBlock::save_data_state(s);  s.put(istart);  s.put(istride);  s.put(jstart);  s.put(iend);  s.put(jend);}SCMatrixRectSubBlock::~SCMatrixRectSubBlock(){}voidSCMatrixRectSubBlock::process(SCElementOp*op){  SCMatrixRectSubBlockIter i(this);  op->process(i);}voidSCMatrixRectSubBlock::process(SCElementOp2*op,                              SCMatrixBlock* b){  SCMatrixRectSubBlockIter i(this);  SCMatrixRectSubBlockIter j((SCMatrixRectSubBlock*)b);  op->process(i,j);}voidSCMatrixRectSubBlock::process(SCElementOp3*op,                              SCMatrixBlock* b1,                              SCMatrixBlock* b2){  SCMatrixRectSubBlockIter i(this);  SCMatrixRectSubBlockIter j((SCMatrixRectSubBlock*)b1);  SCMatrixRectSubBlockIter k((SCMatrixRectSubBlock*)b2);  op->process(i,j,k);}/////////////////////////////////////////////////////////////////////////////// SCMatrixLTriBlock member functionsstatic ClassDesc SCMatrixLTriBlock_cd(  typeid(SCMatrixLTriBlock),"SCMatrixLTriBlock",1,"public SCMatrixBlock",  0, 0, create<SCMatrixLTriBlock>);SCMatrixLTriBlock::SCMatrixLTriBlock(int s,int e):  start(s),  end(e){  data = new double[((e-s)*(e-s+1))/2];}SCMatrixLTriBlock::SCMatrixLTriBlock(StateIn&s):  SCMatrixBlock(s){  s.get(start);  s.get(end);  s.get(data);}voidSCMatrixLTriBlock::save_data_state(StateOut&s){  SCMatrixBlock::save_data_state(s);  s.put(start);  s.put(end);  s.put(data,((end-start)*(end-start+1))/2);}SCMatrixBlock *SCMatrixLTriBlock::deepcopy() const{  SCMatrixLTriBlock *ret = new SCMatrixLTriBlock(start,end);  ret->blocki = blocki;  ret->blockj = blockj;  memcpy(ret->data, data, sizeof(double)*ndat());  return ret;}double *SCMatrixLTriBlock::dat(){  return data;}intSCMatrixLTriBlock::ndat() const{  return ((end-start)*(end-start+1))/2;}SCMatrixLTriBlock::~SCMatrixLTriBlock(){  delete[] data;}voidSCMatrixLTriBlock::process(SCElementOp*op){  SCMatrixLTriBlockIter i(this);  op->process(i);}voidSCMatrixLTriBlock::process(SCElementOp2*op,                           SCMatrixBlock* b){  SCMatrixLTriBlockIter i(this);  SCMatrixLTriBlockIter j((SCMatrixLTriBlock*)b);  op->process(i,j);}voidSCMatrixLTriBlock::process(SCElementOp3*op,                           SCMatrixBlock* b1, SCMatrixBlock* b2){  SCMatrixLTriBlockIter i(this);  SCMatrixLTriBlockIter j((SCMatrixLTriBlock*)b1);  SCMatrixLTriBlockIter k((SCMatrixLTriBlock*)b2);  op->process(i,j,k);}/////////////////////////////////////////////////////////////////////////////// SCMatrixLTriSubBlock member functionsstatic ClassDesc SCMatrixLTriSubBlock_cd(  typeid(SCMatrixLTriSubBlock),"SCMatrixLTriSubBlock",1,"public SCMatrixBlock",  0, 0, create<SCMatrixLTriSubBlock>);SCMatrixLTriSubBlock::SCMatrixLTriSubBlock(int is, int ie,                                           int js, int je,                                           double*d):  istart(is),  iend(ie),  jstart(js),  jend(je),  data(d){}SCMatrixLTriSubBlock::SCMatrixLTriSubBlock(StateIn&s):  SCMatrixBlock(s){  s.get(istart);  s.get(iend);  s.get(jstart);  s.get(jend);  data = 0;}voidSCMatrixLTriSubBlock::save_data_state(StateOut&s){  SCMatrixBlock::save_data_state(s);  s.put(istart);  s.put(iend);  s.put(jstart);  s.put(jend);}SCMatrixLTriSubBlock::~SCMatrixLTriSubBlock(){}voidSCMatrixLTriSubBlock::process(SCElementOp*op){  SCMatrixLTriSubBlockIter i(this);  op->process(i);}voidSCMatrixLTriSubBlock::process(SCElementOp2*op,                              SCMatrixBlock* b){  SCMatrixLTriSubBlockIter i(this);  SCMatrixLTriSubBlockIter j((SCMatrixLTriSubBlock*)b);  op->process(i,j);}voidSCMatrixLTriSubBlock::process(SCElementOp3*op,                              SCMatrixBlock* b1,                              SCMatrixBlock* b2){  SCMatrixLTriSubBlockIter i(this);  SCMatrixLTriSubBlockIter j((SCMatrixLTriSubBlock*)b1);  SCMatrixLTriSubBlockIter k((SCMatrixLTriSubBlock*)b2);  op->process(i,j,k);}/////////////////////////////////////////////////////////////////////////////// SCMatrixDiagBlock member functionsstatic ClassDesc SCMatrixDiagBlock_cd(  typeid(SCMatrixDiagBlock),"SCMatrixDiagBlock",1,"public SCMatrixBlock",  0, 0, create<SCMatrixDiagBlock>);SCMatrixDiagBlock::SCMatrixDiagBlock(int s, int e):  istart(s),  jstart(s),  iend(e){  data = new double[e-s];}SCMatrixDiagBlock::SCMatrixDiagBlock(int is, int ie,int js):  istart(is),  jstart(js),  iend(ie){  data = new double[ie-is];}SCMatrixDiagBlock::SCMatrixDiagBlock(StateIn&s):  SCMatrixBlock(s){  s.get(istart);  s.get(jstart);  s.get(iend);  s.get(data);}voidSCMatrixDiagBlock::save_data_state(StateOut&s){  SCMatrixBlock::save_data_state(s);  s.put(istart);  s.put(jstart);  s.put(iend);  s.put(data,iend-istart);}SCMatrixBlock *SCMatrixDiagBlock::deepcopy() const{  SCMatrixDiagBlock *ret = new SCMatrixDiagBlock(istart,iend,jstart);  ret->blocki = blocki;  ret->blockj = blockj;  memcpy(ret->data, data, sizeof(double)*ndat());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -