📄 blkiter.cc
字号:
//// blkiter.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 <util/misc/formio.h>#include <math/scmat/blkiter.h>#include <math/scmat/block.h>using namespace sc;/////////////////////////////////////////////////////////////////////////////// SCMatrixBlockIter member functionsSCMatrixBlockIter::~SCMatrixBlockIter(){}voidSCMatrixBlockIter::accum(double a){ set(get()+a);}/////////////////////////////////////////////////////////////////////////////// SCMatrixRectBlockIter member functionsSCMatrixRectBlockIter::SCMatrixRectBlockIter(SCMatrixRectBlock*a): block(a){ reset();}voidSCMatrixRectBlockIter::reset(){ block_index = 0; i_ = block->istart; j_ = block->jstart;}SCMatrixRectBlockIter::~SCMatrixRectBlockIter(){}intSCMatrixRectBlockIter::i(){ return i_;}intSCMatrixRectBlockIter::j(){ return j_;}doubleSCMatrixRectBlockIter::get(){ return block->data[block_index];}voidSCMatrixRectBlockIter::set(double a){ block->data[block_index] = a;}SCMatrixRectBlockIter::operator int(){ return (i_ < block->iend && j_ < block->jend);}voidSCMatrixRectBlockIter::operator ++(){ j_++; if (j_ >= block->jend) { j_ = block->jstart; i_++; } block_index++;}/////////////////////////////////////////////////////////////////////////////// SCMatrixRectSubBlockIter member functionsSCMatrixRectSubBlockIter::SCMatrixRectSubBlockIter(SCMatrixRectSubBlock*a): block(a){ reset();}voidSCMatrixRectSubBlockIter::reset(){ i_ = block->istart; j_ = block->jstart; block_index = i_ * block->istride + j_;}SCMatrixRectSubBlockIter::~SCMatrixRectSubBlockIter(){}intSCMatrixRectSubBlockIter::i(){ return i_;}intSCMatrixRectSubBlockIter::j(){ return j_;}doubleSCMatrixRectSubBlockIter::get(){ return block->data[block_index];}voidSCMatrixRectSubBlockIter::set(double a){ block->data[block_index] = a;}SCMatrixRectSubBlockIter::operator int(){ return (i_ < block->iend && j_ < block->jend);}voidSCMatrixRectSubBlockIter::operator ++(){ j_++; block_index++; if (j_ >= block->jend) { j_ = block->jstart; i_++; block_index += block->istride - (block->jend - block->jstart); }}/////////////////////////////////////////////////////////////////////////////// SCMatrixLTriBlockIter member functionsSCMatrixLTriBlockIter::SCMatrixLTriBlockIter(SCMatrixLTriBlock*a): block(a){ reset();}voidSCMatrixLTriBlockIter::reset(){ block_index = 0; i_ = block->start; j_ = block->start;}SCMatrixLTriBlockIter::~SCMatrixLTriBlockIter(){}intSCMatrixLTriBlockIter::i(){ return i_;}intSCMatrixLTriBlockIter::j(){ return j_;}doubleSCMatrixLTriBlockIter::get(){ return block->data[block_index];}voidSCMatrixLTriBlockIter::set(double a){ block->data[block_index] = a;}SCMatrixLTriBlockIter::operator int(){ return (i_ < block->end);}voidSCMatrixLTriBlockIter::operator ++(){ j_++; if (j_ > i_) { j_ = block->start; i_++; } block_index++;}/////////////////////////////////////////////////////////////////////////////// SCMatrixLTriSubBlockIter member functionsSCMatrixLTriSubBlockIter::SCMatrixLTriSubBlockIter( SCMatrixLTriSubBlock*a): block(a){ reset();}voidSCMatrixLTriSubBlockIter::reset(){ i_ = block->istart; j_ = block->jstart; block_index = (i_*(i_+1)>>1) + j_;}SCMatrixLTriSubBlockIter::~SCMatrixLTriSubBlockIter(){}intSCMatrixLTriSubBlockIter::i(){ return i_;}intSCMatrixLTriSubBlockIter::j(){ return j_;}doubleSCMatrixLTriSubBlockIter::get(){ return block->data[block_index];}voidSCMatrixLTriSubBlockIter::set(double a){ block->data[block_index] = a;}SCMatrixLTriSubBlockIter::operator int(){ return (i_ < block->iend);}voidSCMatrixLTriSubBlockIter::operator ++(){ j_++; block_index++; if (j_ > i_) { j_ = block->jstart; i_++; block_index += block->istart; } else if (j_ >= block->jend) { j_ = block->jstart; i_++; block_index += i_ + block->jstart - block->jend; }}/////////////////////////////////////////////////////////////////////////////// SCMatrixDiagBlockIter member functionsSCMatrixDiagBlockIter::SCMatrixDiagBlockIter(SCMatrixDiagBlock*a): block(a){ reset();}voidSCMatrixDiagBlockIter::reset(){ block_index = 0; i_ = block->istart;}SCMatrixDiagBlockIter::~SCMatrixDiagBlockIter(){}intSCMatrixDiagBlockIter::i(){ return i_;}intSCMatrixDiagBlockIter::j(){ return i_ + block->jstart - block->istart;}doubleSCMatrixDiagBlockIter::get(){ return block->data[block_index];}voidSCMatrixDiagBlockIter::set(double a){ block->data[block_index] = a;}SCMatrixDiagBlockIter::operator int(){ return (i_ < block->iend);}voidSCMatrixDiagBlockIter::operator ++(){ i_++; block_index++;}/////////////////////////////////////////////////////////////////////////////// SCMatrixDiagSubBlockIter member functionsSCMatrixDiagSubBlockIter::SCMatrixDiagSubBlockIter(SCMatrixDiagSubBlock*a): block(a){ reset();}voidSCMatrixDiagSubBlockIter::reset(){ block_index = block->offset; i_ = block->istart;}SCMatrixDiagSubBlockIter::~SCMatrixDiagSubBlockIter(){}intSCMatrixDiagSubBlockIter::i(){ return i_;}intSCMatrixDiagSubBlockIter::j(){ return i_ + block->jstart - block->istart;}doubleSCMatrixDiagSubBlockIter::get(){ return block->data[block_index];}voidSCMatrixDiagSubBlockIter::set(double a){ block->data[block_index] = a;}SCMatrixDiagSubBlockIter::operator int(){ return (i_ < block->iend);}voidSCMatrixDiagSubBlockIter::operator ++(){ i_++; block_index++;}/////////////////////////////////////////////////////////////////////////////// SCVectorSimpleBlockIter member functionsSCVectorSimpleBlockIter::SCVectorSimpleBlockIter(SCVectorSimpleBlock*a): block(a){ reset();}voidSCVectorSimpleBlockIter::reset(){ block_index = 0; i_ = block->istart;}SCVectorSimpleBlockIter::~SCVectorSimpleBlockIter(){}intSCVectorSimpleBlockIter::i(){ return i_;}intSCVectorSimpleBlockIter::j(){ ExEnv::errn() << indent << "SCVectorSimpleBlockIter::j() attempted to find j value\n"; abort(); return 0;}doubleSCVectorSimpleBlockIter::get(){ return block->data[block_index];}voidSCVectorSimpleBlockIter::set(double a){ block->data[block_index] = a;}SCVectorSimpleBlockIter::operator int(){ return (i_ < block->iend);}voidSCVectorSimpleBlockIter::operator ++(){ i_++; block_index++;}/////////////////////////////////////////////////////////////////////////////// SCVectorSimpleSubBlockIter member functionsSCVectorSimpleSubBlockIter::SCVectorSimpleSubBlockIter( SCVectorSimpleSubBlock*a): block(a){ reset();}voidSCVectorSimpleSubBlockIter::reset(){ block_index = block->offset; i_ = block->istart;}SCVectorSimpleSubBlockIter::~SCVectorSimpleSubBlockIter(){}intSCVectorSimpleSubBlockIter::i(){ return i_;}intSCVectorSimpleSubBlockIter::j(){ ExEnv::errn() << indent << "SCVectorSimpleSubBlockIter::j(): attempted to find j value\n"; abort(); return 0;}doubleSCVectorSimpleSubBlockIter::get(){ return block->data[block_index];}voidSCVectorSimpleSubBlockIter::set(double a){ block->data[block_index] = a;}SCVectorSimpleSubBlockIter::operator int(){ return (i_ < block->iend);}voidSCVectorSimpleSubBlockIter::operator ++(){ i_++; block_index++;}/////////////////////////////////////////////////////////////////////////////// Local Variables:// mode: c++// c-file-style: "CLJ"// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -