| [0b990d] | 1 | // | 
|---|
|  | 2 | // block.cc | 
|---|
|  | 3 | // | 
|---|
|  | 4 | // Copyright (C) 1996 Limit Point Systems, Inc. | 
|---|
|  | 5 | // | 
|---|
|  | 6 | // Author: Curtis Janssen <cljanss@limitpt.com> | 
|---|
|  | 7 | // Maintainer: LPS | 
|---|
|  | 8 | // | 
|---|
|  | 9 | // This file is part of the SC Toolkit. | 
|---|
|  | 10 | // | 
|---|
|  | 11 | // The SC Toolkit is free software; you can redistribute it and/or modify | 
|---|
|  | 12 | // it under the terms of the GNU Library General Public License as published by | 
|---|
|  | 13 | // the Free Software Foundation; either version 2, or (at your option) | 
|---|
|  | 14 | // any later version. | 
|---|
|  | 15 | // | 
|---|
|  | 16 | // The SC Toolkit is distributed in the hope that it will be useful, | 
|---|
|  | 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 19 | // GNU Library General Public License for more details. | 
|---|
|  | 20 | // | 
|---|
|  | 21 | // You should have received a copy of the GNU Library General Public License | 
|---|
|  | 22 | // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to | 
|---|
|  | 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 
|---|
|  | 24 | // | 
|---|
|  | 25 | // The U.S. Government is granted a limited license as per AL 91-7. | 
|---|
|  | 26 | // | 
|---|
|  | 27 |  | 
|---|
|  | 28 | #ifdef __GNUC__ | 
|---|
|  | 29 | #pragma implementation | 
|---|
|  | 30 | #endif | 
|---|
|  | 31 |  | 
|---|
|  | 32 | #include <iostream> | 
|---|
|  | 33 | #include <string.h> | 
|---|
|  | 34 | #include <util/state/stateio.h> | 
|---|
|  | 35 | #include <math/scmat/block.h> | 
|---|
|  | 36 | #include <math/scmat/blkiter.h> | 
|---|
|  | 37 | #include <math/scmat/elemop.h> | 
|---|
|  | 38 |  | 
|---|
|  | 39 | using namespace std; | 
|---|
|  | 40 | using namespace sc; | 
|---|
|  | 41 |  | 
|---|
|  | 42 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 43 | // SCMatrixBlock member functions | 
|---|
|  | 44 |  | 
|---|
|  | 45 | static ClassDesc SCMatrixBlock_cd( | 
|---|
|  | 46 | typeid(SCMatrixBlock),"SCMatrixBlock",1,"public SavableState", | 
|---|
|  | 47 | 0, 0, 0); | 
|---|
|  | 48 |  | 
|---|
|  | 49 | SCMatrixBlock::SCMatrixBlock() | 
|---|
|  | 50 | { | 
|---|
|  | 51 | blocki = blockj = -1; | 
|---|
|  | 52 | } | 
|---|
|  | 53 |  | 
|---|
|  | 54 | SCMatrixBlock::SCMatrixBlock(StateIn&s): | 
|---|
|  | 55 | SavableState(s) | 
|---|
|  | 56 | { | 
|---|
|  | 57 | s.get(blocki); | 
|---|
|  | 58 | s.get(blockj); | 
|---|
|  | 59 | } | 
|---|
|  | 60 |  | 
|---|
|  | 61 | void | 
|---|
|  | 62 | SCMatrixBlock::save_data_state(StateOut&s) | 
|---|
|  | 63 | { | 
|---|
|  | 64 | s.put(blocki); | 
|---|
|  | 65 | s.put(blockj); | 
|---|
|  | 66 | } | 
|---|
|  | 67 |  | 
|---|
|  | 68 | SCMatrixBlock::~SCMatrixBlock() | 
|---|
|  | 69 | { | 
|---|
|  | 70 | } | 
|---|
|  | 71 |  | 
|---|
|  | 72 | SCMatrixBlock * | 
|---|
|  | 73 | SCMatrixBlock::deepcopy() const | 
|---|
|  | 74 | { | 
|---|
|  | 75 | ExEnv::errn() << "SCMatrixBlock of type " << class_name() | 
|---|
|  | 76 | << " cannot be deep copied" << endl; | 
|---|
|  | 77 | abort(); | 
|---|
|  | 78 | return 0; | 
|---|
|  | 79 | } | 
|---|
|  | 80 |  | 
|---|
|  | 81 | double * | 
|---|
|  | 82 | SCMatrixBlock::dat() | 
|---|
|  | 83 | { | 
|---|
|  | 84 | ExEnv::errn() << "SCMatrixBlock of type " << class_name() | 
|---|
|  | 85 | << " cannot provide internal data" << endl; | 
|---|
|  | 86 | abort(); | 
|---|
|  | 87 | return 0; | 
|---|
|  | 88 | } | 
|---|
|  | 89 |  | 
|---|
|  | 90 | int | 
|---|
|  | 91 | SCMatrixBlock::ndat() const | 
|---|
|  | 92 | { | 
|---|
|  | 93 | ExEnv::errn() << "SCMatrixBlock of type " << class_name() | 
|---|
|  | 94 | << " cannot provide size of internal data" << endl; | 
|---|
|  | 95 | abort(); | 
|---|
|  | 96 | return 0; | 
|---|
|  | 97 | } | 
|---|
|  | 98 |  | 
|---|
|  | 99 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 100 | // SCMatrixBlockListLink member functions | 
|---|
|  | 101 |  | 
|---|
|  | 102 | SCMatrixBlockListLink::SCMatrixBlockListLink(SCMatrixBlock* b, | 
|---|
|  | 103 | SCMatrixBlockListLink* l) | 
|---|
|  | 104 | { | 
|---|
|  | 105 | block(b); | 
|---|
|  | 106 | next(l); | 
|---|
|  | 107 | } | 
|---|
|  | 108 |  | 
|---|
|  | 109 | SCMatrixBlockListLink::~SCMatrixBlockListLink() | 
|---|
|  | 110 | { | 
|---|
|  | 111 | if (_block) _block->dereference(); | 
|---|
|  | 112 | if (_block->nreference() == 0) delete _block; | 
|---|
|  | 113 |  | 
|---|
|  | 114 | for (SCMatrixBlockListLink *nexti, *i=_next; i; i = nexti) { | 
|---|
|  | 115 | nexti = i->_next; | 
|---|
|  | 116 | i->_next = 0; | 
|---|
|  | 117 | delete i; | 
|---|
|  | 118 | } | 
|---|
|  | 119 | } | 
|---|
|  | 120 |  | 
|---|
|  | 121 | void | 
|---|
|  | 122 | SCMatrixBlockListLink::block(SCMatrixBlock* b) | 
|---|
|  | 123 | { | 
|---|
|  | 124 | _block = b; | 
|---|
|  | 125 | if (_block) _block->reference(); | 
|---|
|  | 126 | } | 
|---|
|  | 127 |  | 
|---|
|  | 128 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 129 | // SCMatrixBlockList member functions | 
|---|
|  | 130 |  | 
|---|
|  | 131 | static ClassDesc SCMatrixBlockList_cd( | 
|---|
|  | 132 | typeid(SCMatrixBlockList),"SCMatrixBlockList",1,"public SavableState", | 
|---|
|  | 133 | 0, 0, create<SCMatrixBlockList>); | 
|---|
|  | 134 |  | 
|---|
|  | 135 | SCMatrixBlockList::SCMatrixBlockList() | 
|---|
|  | 136 | { | 
|---|
|  | 137 | _begin = 0; | 
|---|
|  | 138 | } | 
|---|
|  | 139 |  | 
|---|
|  | 140 | SCMatrixBlockList::SCMatrixBlockList(StateIn& s): | 
|---|
|  | 141 | SavableState(s) | 
|---|
|  | 142 | { | 
|---|
|  | 143 | int i, count; | 
|---|
|  | 144 | Ref<SCMatrixBlock> b; | 
|---|
|  | 145 | s.get(count); | 
|---|
|  | 146 | _begin = 0; | 
|---|
|  | 147 | for (i=0; i<count; i++) { | 
|---|
|  | 148 | b << SavableState::restore_state(s); | 
|---|
|  | 149 | append(b); | 
|---|
|  | 150 | } | 
|---|
|  | 151 | } | 
|---|
|  | 152 |  | 
|---|
|  | 153 | SCMatrixBlockList::~SCMatrixBlockList() | 
|---|
|  | 154 | { | 
|---|
|  | 155 | if (_begin) delete _begin; | 
|---|
|  | 156 | } | 
|---|
|  | 157 |  | 
|---|
|  | 158 | void | 
|---|
|  | 159 | SCMatrixBlockList::save_data_state(StateOut&s) | 
|---|
|  | 160 | { | 
|---|
|  | 161 | int count = 0; | 
|---|
|  | 162 | SCMatrixBlockListIter i; | 
|---|
|  | 163 | for (i = begin(); i != end(); i++) count++; | 
|---|
|  | 164 | s.put(count); | 
|---|
|  | 165 | for (i = begin(); i != end(); i++) { | 
|---|
|  | 166 | i.block()->save_state(s); | 
|---|
|  | 167 | } | 
|---|
|  | 168 | } | 
|---|
|  | 169 |  | 
|---|
|  | 170 | void | 
|---|
|  | 171 | SCMatrixBlockList::insert(SCMatrixBlock* b) | 
|---|
|  | 172 | { | 
|---|
|  | 173 | _begin = new SCMatrixBlockListLink(b, _begin); | 
|---|
|  | 174 | } | 
|---|
|  | 175 |  | 
|---|
|  | 176 | void | 
|---|
|  | 177 | SCMatrixBlockList::append(SCMatrixBlock* b) | 
|---|
|  | 178 | { | 
|---|
|  | 179 | if (_begin == 0) { | 
|---|
|  | 180 | _begin = new SCMatrixBlockListLink(b); | 
|---|
|  | 181 | } | 
|---|
|  | 182 | else { | 
|---|
|  | 183 | SCMatrixBlockListLink* i; | 
|---|
|  | 184 | for (i = _begin; i->next() != 0; i = i->next()); | 
|---|
|  | 185 | i->next(new SCMatrixBlockListLink(b)); | 
|---|
|  | 186 | } | 
|---|
|  | 187 | } | 
|---|
|  | 188 |  | 
|---|
|  | 189 | SCMatrixBlockList * | 
|---|
|  | 190 | SCMatrixBlockList::deepcopy() | 
|---|
|  | 191 | { | 
|---|
|  | 192 | SCMatrixBlockListIter i; | 
|---|
|  | 193 | SCMatrixBlockList *ret = new SCMatrixBlockList(); | 
|---|
|  | 194 | for (i=begin(); i!=end(); i++) { | 
|---|
|  | 195 | ret->append(i.block()->deepcopy()); | 
|---|
|  | 196 | } | 
|---|
|  | 197 | return ret; | 
|---|
|  | 198 | } | 
|---|
|  | 199 |  | 
|---|
|  | 200 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 201 | // SCMatrixRectBlock member functions | 
|---|
|  | 202 |  | 
|---|
|  | 203 | static ClassDesc SCMatrixRectBlock_cd( | 
|---|
|  | 204 | typeid(SCMatrixRectBlock),"SCMatrixRectBlock",1,"public SCMatrixBlock", | 
|---|
|  | 205 | 0, 0, create<SCMatrixRectBlock>); | 
|---|
|  | 206 |  | 
|---|
|  | 207 | SCMatrixRectBlock::SCMatrixRectBlock(int is, int ie, int js, int je): | 
|---|
|  | 208 | istart(is), | 
|---|
|  | 209 | jstart(js), | 
|---|
|  | 210 | iend(ie), | 
|---|
|  | 211 | jend(je) | 
|---|
|  | 212 | { | 
|---|
|  | 213 | data = new double[(ie-is)*(je-js)]; | 
|---|
|  | 214 | } | 
|---|
|  | 215 |  | 
|---|
|  | 216 | SCMatrixRectBlock::SCMatrixRectBlock(StateIn&s): | 
|---|
|  | 217 | SCMatrixBlock(s) | 
|---|
|  | 218 | { | 
|---|
|  | 219 | s.get(istart); | 
|---|
|  | 220 | s.get(jstart); | 
|---|
|  | 221 | s.get(iend); | 
|---|
|  | 222 | s.get(jend); | 
|---|
|  | 223 | s.get(data); | 
|---|
|  | 224 | } | 
|---|
|  | 225 |  | 
|---|
|  | 226 | void | 
|---|
|  | 227 | SCMatrixRectBlock::save_data_state(StateOut&s) | 
|---|
|  | 228 | { | 
|---|
|  | 229 | SCMatrixBlock::save_data_state(s); | 
|---|
|  | 230 | s.put(istart); | 
|---|
|  | 231 | s.put(jstart); | 
|---|
|  | 232 | s.put(iend); | 
|---|
|  | 233 | s.put(jend); | 
|---|
|  | 234 | s.put(data,(iend-istart)*(jend-jstart)); | 
|---|
|  | 235 | } | 
|---|
|  | 236 |  | 
|---|
|  | 237 | SCMatrixBlock * | 
|---|
|  | 238 | SCMatrixRectBlock::deepcopy() const | 
|---|
|  | 239 | { | 
|---|
|  | 240 | SCMatrixRectBlock *ret = new SCMatrixRectBlock(istart,iend,jstart,jend); | 
|---|
|  | 241 | ret->blocki = blocki; | 
|---|
|  | 242 | ret->blockj = blockj; | 
|---|
|  | 243 | memcpy(ret->data, data, sizeof(double)*ndat()); | 
|---|
|  | 244 | return ret; | 
|---|
|  | 245 | } | 
|---|
|  | 246 |  | 
|---|
|  | 247 | double * | 
|---|
|  | 248 | SCMatrixRectBlock::dat() | 
|---|
|  | 249 | { | 
|---|
|  | 250 | return data; | 
|---|
|  | 251 | } | 
|---|
|  | 252 |  | 
|---|
|  | 253 | int | 
|---|
|  | 254 | SCMatrixRectBlock::ndat() const | 
|---|
|  | 255 | { | 
|---|
|  | 256 | return (iend-istart)*(jend-jstart); | 
|---|
|  | 257 | } | 
|---|
|  | 258 |  | 
|---|
|  | 259 | SCMatrixRectBlock::~SCMatrixRectBlock() | 
|---|
|  | 260 | { | 
|---|
|  | 261 | delete[] data; | 
|---|
|  | 262 | } | 
|---|
|  | 263 |  | 
|---|
|  | 264 | void | 
|---|
|  | 265 | SCMatrixRectBlock::process(SCElementOp*op) | 
|---|
|  | 266 | { | 
|---|
|  | 267 | SCMatrixRectBlockIter i(this); | 
|---|
|  | 268 | op->process(i); | 
|---|
|  | 269 | } | 
|---|
|  | 270 |  | 
|---|
|  | 271 | void | 
|---|
|  | 272 | SCMatrixRectBlock::process(SCElementOp2*op, | 
|---|
|  | 273 | SCMatrixBlock* b) | 
|---|
|  | 274 | { | 
|---|
|  | 275 | SCMatrixRectBlockIter i(this); | 
|---|
|  | 276 | SCMatrixRectBlockIter j((SCMatrixRectBlock*)b); | 
|---|
|  | 277 | op->process(i,j); | 
|---|
|  | 278 | } | 
|---|
|  | 279 |  | 
|---|
|  | 280 | void | 
|---|
|  | 281 | SCMatrixRectBlock::process(SCElementOp3*op, | 
|---|
|  | 282 | SCMatrixBlock* b1, SCMatrixBlock* b2) | 
|---|
|  | 283 | { | 
|---|
|  | 284 | SCMatrixRectBlockIter i(this); | 
|---|
|  | 285 | SCMatrixRectBlockIter j((SCMatrixRectBlock*)b1); | 
|---|
|  | 286 | SCMatrixRectBlockIter k((SCMatrixRectBlock*)b2); | 
|---|
|  | 287 | op->process(i,j,k); | 
|---|
|  | 288 | } | 
|---|
|  | 289 |  | 
|---|
|  | 290 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 291 | // SCMatrixRectSubBlock member functions | 
|---|
|  | 292 |  | 
|---|
|  | 293 | static ClassDesc SCMatrixRectSubBlock_cd( | 
|---|
|  | 294 | typeid(SCMatrixRectSubBlock),"SCMatrixRectSubBlock",1,"public SCMatrixBlock", | 
|---|
|  | 295 | 0, 0, create<SCMatrixRectSubBlock>); | 
|---|
|  | 296 |  | 
|---|
|  | 297 | SCMatrixRectSubBlock::SCMatrixRectSubBlock(int is, int ie, int istr, | 
|---|
|  | 298 | int js, int je, double* d): | 
|---|
|  | 299 | istart(is), | 
|---|
|  | 300 | jstart(js), | 
|---|
|  | 301 | iend(ie), | 
|---|
|  | 302 | jend(je), | 
|---|
|  | 303 | istride(istr), | 
|---|
|  | 304 | data(d) | 
|---|
|  | 305 | { | 
|---|
|  | 306 | } | 
|---|
|  | 307 |  | 
|---|
|  | 308 | SCMatrixRectSubBlock::SCMatrixRectSubBlock(StateIn&s): | 
|---|
|  | 309 | SCMatrixBlock(s) | 
|---|
|  | 310 | { | 
|---|
|  | 311 | s.get(istart); | 
|---|
|  | 312 | s.get(istride); | 
|---|
|  | 313 | s.get(jstart); | 
|---|
|  | 314 | s.get(iend); | 
|---|
|  | 315 | s.get(jend); | 
|---|
|  | 316 | data = 0; | 
|---|
|  | 317 | } | 
|---|
|  | 318 |  | 
|---|
|  | 319 | void | 
|---|
|  | 320 | SCMatrixRectSubBlock::save_data_state(StateOut&s) | 
|---|
|  | 321 | { | 
|---|
|  | 322 | SCMatrixBlock::save_data_state(s); | 
|---|
|  | 323 | s.put(istart); | 
|---|
|  | 324 | s.put(istride); | 
|---|
|  | 325 | s.put(jstart); | 
|---|
|  | 326 | s.put(iend); | 
|---|
|  | 327 | s.put(jend); | 
|---|
|  | 328 | } | 
|---|
|  | 329 |  | 
|---|
|  | 330 | SCMatrixRectSubBlock::~SCMatrixRectSubBlock() | 
|---|
|  | 331 | { | 
|---|
|  | 332 | } | 
|---|
|  | 333 |  | 
|---|
|  | 334 | void | 
|---|
|  | 335 | SCMatrixRectSubBlock::process(SCElementOp*op) | 
|---|
|  | 336 | { | 
|---|
|  | 337 | SCMatrixRectSubBlockIter i(this); | 
|---|
|  | 338 | op->process(i); | 
|---|
|  | 339 | } | 
|---|
|  | 340 |  | 
|---|
|  | 341 | void | 
|---|
|  | 342 | SCMatrixRectSubBlock::process(SCElementOp2*op, | 
|---|
|  | 343 | SCMatrixBlock* b) | 
|---|
|  | 344 | { | 
|---|
|  | 345 | SCMatrixRectSubBlockIter i(this); | 
|---|
|  | 346 | SCMatrixRectSubBlockIter j((SCMatrixRectSubBlock*)b); | 
|---|
|  | 347 | op->process(i,j); | 
|---|
|  | 348 | } | 
|---|
|  | 349 |  | 
|---|
|  | 350 | void | 
|---|
|  | 351 | SCMatrixRectSubBlock::process(SCElementOp3*op, | 
|---|
|  | 352 | SCMatrixBlock* b1, | 
|---|
|  | 353 | SCMatrixBlock* b2) | 
|---|
|  | 354 | { | 
|---|
|  | 355 | SCMatrixRectSubBlockIter i(this); | 
|---|
|  | 356 | SCMatrixRectSubBlockIter j((SCMatrixRectSubBlock*)b1); | 
|---|
|  | 357 | SCMatrixRectSubBlockIter k((SCMatrixRectSubBlock*)b2); | 
|---|
|  | 358 | op->process(i,j,k); | 
|---|
|  | 359 | } | 
|---|
|  | 360 |  | 
|---|
|  | 361 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 362 | // SCMatrixLTriBlock member functions | 
|---|
|  | 363 |  | 
|---|
|  | 364 | static ClassDesc SCMatrixLTriBlock_cd( | 
|---|
|  | 365 | typeid(SCMatrixLTriBlock),"SCMatrixLTriBlock",1,"public SCMatrixBlock", | 
|---|
|  | 366 | 0, 0, create<SCMatrixLTriBlock>); | 
|---|
|  | 367 |  | 
|---|
|  | 368 | SCMatrixLTriBlock::SCMatrixLTriBlock(int s,int e): | 
|---|
|  | 369 | start(s), | 
|---|
|  | 370 | end(e) | 
|---|
|  | 371 | { | 
|---|
|  | 372 | data = new double[((e-s)*(e-s+1))/2]; | 
|---|
|  | 373 | } | 
|---|
|  | 374 |  | 
|---|
|  | 375 | SCMatrixLTriBlock::SCMatrixLTriBlock(StateIn&s): | 
|---|
|  | 376 | SCMatrixBlock(s) | 
|---|
|  | 377 | { | 
|---|
|  | 378 | s.get(start); | 
|---|
|  | 379 | s.get(end); | 
|---|
|  | 380 | s.get(data); | 
|---|
|  | 381 | } | 
|---|
|  | 382 |  | 
|---|
|  | 383 | void | 
|---|
|  | 384 | SCMatrixLTriBlock::save_data_state(StateOut&s) | 
|---|
|  | 385 | { | 
|---|
|  | 386 | SCMatrixBlock::save_data_state(s); | 
|---|
|  | 387 | s.put(start); | 
|---|
|  | 388 | s.put(end); | 
|---|
|  | 389 | s.put(data,((end-start)*(end-start+1))/2); | 
|---|
|  | 390 | } | 
|---|
|  | 391 |  | 
|---|
|  | 392 | SCMatrixBlock * | 
|---|
|  | 393 | SCMatrixLTriBlock::deepcopy() const | 
|---|
|  | 394 | { | 
|---|
|  | 395 | SCMatrixLTriBlock *ret = new SCMatrixLTriBlock(start,end); | 
|---|
|  | 396 | ret->blocki = blocki; | 
|---|
|  | 397 | ret->blockj = blockj; | 
|---|
|  | 398 | memcpy(ret->data, data, sizeof(double)*ndat()); | 
|---|
|  | 399 | return ret; | 
|---|
|  | 400 | } | 
|---|
|  | 401 |  | 
|---|
|  | 402 | double * | 
|---|
|  | 403 | SCMatrixLTriBlock::dat() | 
|---|
|  | 404 | { | 
|---|
|  | 405 | return data; | 
|---|
|  | 406 | } | 
|---|
|  | 407 |  | 
|---|
|  | 408 | int | 
|---|
|  | 409 | SCMatrixLTriBlock::ndat() const | 
|---|
|  | 410 | { | 
|---|
|  | 411 | return ((end-start)*(end-start+1))/2; | 
|---|
|  | 412 | } | 
|---|
|  | 413 |  | 
|---|
|  | 414 | SCMatrixLTriBlock::~SCMatrixLTriBlock() | 
|---|
|  | 415 | { | 
|---|
|  | 416 | delete[] data; | 
|---|
|  | 417 | } | 
|---|
|  | 418 |  | 
|---|
|  | 419 | void | 
|---|
|  | 420 | SCMatrixLTriBlock::process(SCElementOp*op) | 
|---|
|  | 421 | { | 
|---|
|  | 422 | SCMatrixLTriBlockIter i(this); | 
|---|
|  | 423 | op->process(i); | 
|---|
|  | 424 | } | 
|---|
|  | 425 |  | 
|---|
|  | 426 | void | 
|---|
|  | 427 | SCMatrixLTriBlock::process(SCElementOp2*op, | 
|---|
|  | 428 | SCMatrixBlock* b) | 
|---|
|  | 429 | { | 
|---|
|  | 430 | SCMatrixLTriBlockIter i(this); | 
|---|
|  | 431 | SCMatrixLTriBlockIter j((SCMatrixLTriBlock*)b); | 
|---|
|  | 432 | op->process(i,j); | 
|---|
|  | 433 | } | 
|---|
|  | 434 |  | 
|---|
|  | 435 | void | 
|---|
|  | 436 | SCMatrixLTriBlock::process(SCElementOp3*op, | 
|---|
|  | 437 | SCMatrixBlock* b1, SCMatrixBlock* b2) | 
|---|
|  | 438 | { | 
|---|
|  | 439 | SCMatrixLTriBlockIter i(this); | 
|---|
|  | 440 | SCMatrixLTriBlockIter j((SCMatrixLTriBlock*)b1); | 
|---|
|  | 441 | SCMatrixLTriBlockIter k((SCMatrixLTriBlock*)b2); | 
|---|
|  | 442 | op->process(i,j,k); | 
|---|
|  | 443 | } | 
|---|
|  | 444 |  | 
|---|
|  | 445 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 446 | // SCMatrixLTriSubBlock member functions | 
|---|
|  | 447 |  | 
|---|
|  | 448 | static ClassDesc SCMatrixLTriSubBlock_cd( | 
|---|
|  | 449 | typeid(SCMatrixLTriSubBlock),"SCMatrixLTriSubBlock",1,"public SCMatrixBlock", | 
|---|
|  | 450 | 0, 0, create<SCMatrixLTriSubBlock>); | 
|---|
|  | 451 |  | 
|---|
|  | 452 | SCMatrixLTriSubBlock::SCMatrixLTriSubBlock(int is, int ie, | 
|---|
|  | 453 | int js, int je, | 
|---|
|  | 454 | double*d): | 
|---|
|  | 455 | istart(is), | 
|---|
|  | 456 | iend(ie), | 
|---|
|  | 457 | jstart(js), | 
|---|
|  | 458 | jend(je), | 
|---|
|  | 459 | data(d) | 
|---|
|  | 460 | { | 
|---|
|  | 461 | } | 
|---|
|  | 462 |  | 
|---|
|  | 463 | SCMatrixLTriSubBlock::SCMatrixLTriSubBlock(StateIn&s): | 
|---|
|  | 464 | SCMatrixBlock(s) | 
|---|
|  | 465 | { | 
|---|
|  | 466 | s.get(istart); | 
|---|
|  | 467 | s.get(iend); | 
|---|
|  | 468 | s.get(jstart); | 
|---|
|  | 469 | s.get(jend); | 
|---|
|  | 470 | data = 0; | 
|---|
|  | 471 | } | 
|---|
|  | 472 |  | 
|---|
|  | 473 | void | 
|---|
|  | 474 | SCMatrixLTriSubBlock::save_data_state(StateOut&s) | 
|---|
|  | 475 | { | 
|---|
|  | 476 | SCMatrixBlock::save_data_state(s); | 
|---|
|  | 477 | s.put(istart); | 
|---|
|  | 478 | s.put(iend); | 
|---|
|  | 479 | s.put(jstart); | 
|---|
|  | 480 | s.put(jend); | 
|---|
|  | 481 | } | 
|---|
|  | 482 |  | 
|---|
|  | 483 | SCMatrixLTriSubBlock::~SCMatrixLTriSubBlock() | 
|---|
|  | 484 | { | 
|---|
|  | 485 | } | 
|---|
|  | 486 |  | 
|---|
|  | 487 | void | 
|---|
|  | 488 | SCMatrixLTriSubBlock::process(SCElementOp*op) | 
|---|
|  | 489 | { | 
|---|
|  | 490 | SCMatrixLTriSubBlockIter i(this); | 
|---|
|  | 491 | op->process(i); | 
|---|
|  | 492 | } | 
|---|
|  | 493 |  | 
|---|
|  | 494 | void | 
|---|
|  | 495 | SCMatrixLTriSubBlock::process(SCElementOp2*op, | 
|---|
|  | 496 | SCMatrixBlock* b) | 
|---|
|  | 497 | { | 
|---|
|  | 498 | SCMatrixLTriSubBlockIter i(this); | 
|---|
|  | 499 | SCMatrixLTriSubBlockIter j((SCMatrixLTriSubBlock*)b); | 
|---|
|  | 500 | op->process(i,j); | 
|---|
|  | 501 | } | 
|---|
|  | 502 |  | 
|---|
|  | 503 | void | 
|---|
|  | 504 | SCMatrixLTriSubBlock::process(SCElementOp3*op, | 
|---|
|  | 505 | SCMatrixBlock* b1, | 
|---|
|  | 506 | SCMatrixBlock* b2) | 
|---|
|  | 507 | { | 
|---|
|  | 508 | SCMatrixLTriSubBlockIter i(this); | 
|---|
|  | 509 | SCMatrixLTriSubBlockIter j((SCMatrixLTriSubBlock*)b1); | 
|---|
|  | 510 | SCMatrixLTriSubBlockIter k((SCMatrixLTriSubBlock*)b2); | 
|---|
|  | 511 | op->process(i,j,k); | 
|---|
|  | 512 | } | 
|---|
|  | 513 |  | 
|---|
|  | 514 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 515 | // SCMatrixDiagBlock member functions | 
|---|
|  | 516 |  | 
|---|
|  | 517 | static ClassDesc SCMatrixDiagBlock_cd( | 
|---|
|  | 518 | typeid(SCMatrixDiagBlock),"SCMatrixDiagBlock",1,"public SCMatrixBlock", | 
|---|
|  | 519 | 0, 0, create<SCMatrixDiagBlock>); | 
|---|
|  | 520 |  | 
|---|
|  | 521 | SCMatrixDiagBlock::SCMatrixDiagBlock(int s, int e): | 
|---|
|  | 522 | istart(s), | 
|---|
|  | 523 | jstart(s), | 
|---|
|  | 524 | iend(e) | 
|---|
|  | 525 | { | 
|---|
|  | 526 | data = new double[e-s]; | 
|---|
|  | 527 | } | 
|---|
|  | 528 |  | 
|---|
|  | 529 | SCMatrixDiagBlock::SCMatrixDiagBlock(int is, int ie,int js): | 
|---|
|  | 530 | istart(is), | 
|---|
|  | 531 | jstart(js), | 
|---|
|  | 532 | iend(ie) | 
|---|
|  | 533 | { | 
|---|
|  | 534 | data = new double[ie-is]; | 
|---|
|  | 535 | } | 
|---|
|  | 536 |  | 
|---|
|  | 537 | SCMatrixDiagBlock::SCMatrixDiagBlock(StateIn&s): | 
|---|
|  | 538 | SCMatrixBlock(s) | 
|---|
|  | 539 | { | 
|---|
|  | 540 | s.get(istart); | 
|---|
|  | 541 | s.get(jstart); | 
|---|
|  | 542 | s.get(iend); | 
|---|
|  | 543 | s.get(data); | 
|---|
|  | 544 | } | 
|---|
|  | 545 |  | 
|---|
|  | 546 | void | 
|---|
|  | 547 | SCMatrixDiagBlock::save_data_state(StateOut&s) | 
|---|
|  | 548 | { | 
|---|
|  | 549 | SCMatrixBlock::save_data_state(s); | 
|---|
|  | 550 | s.put(istart); | 
|---|
|  | 551 | s.put(jstart); | 
|---|
|  | 552 | s.put(iend); | 
|---|
|  | 553 | s.put(data,iend-istart); | 
|---|
|  | 554 | } | 
|---|
|  | 555 |  | 
|---|
|  | 556 | SCMatrixBlock * | 
|---|
|  | 557 | SCMatrixDiagBlock::deepcopy() const | 
|---|
|  | 558 | { | 
|---|
|  | 559 | SCMatrixDiagBlock *ret = new SCMatrixDiagBlock(istart,iend,jstart); | 
|---|
|  | 560 | ret->blocki = blocki; | 
|---|
|  | 561 | ret->blockj = blockj; | 
|---|
|  | 562 | memcpy(ret->data, data, sizeof(double)*ndat()); | 
|---|
|  | 563 | return ret; | 
|---|
|  | 564 | } | 
|---|
|  | 565 |  | 
|---|
|  | 566 | double * | 
|---|
|  | 567 | SCMatrixDiagBlock::dat() | 
|---|
|  | 568 | { | 
|---|
|  | 569 | return data; | 
|---|
|  | 570 | } | 
|---|
|  | 571 |  | 
|---|
|  | 572 | int | 
|---|
|  | 573 | SCMatrixDiagBlock::ndat() const | 
|---|
|  | 574 | { | 
|---|
|  | 575 | return iend-istart; | 
|---|
|  | 576 | } | 
|---|
|  | 577 |  | 
|---|
|  | 578 | SCMatrixDiagBlock::~SCMatrixDiagBlock() | 
|---|
|  | 579 | { | 
|---|
|  | 580 | delete[] data; | 
|---|
|  | 581 | } | 
|---|
|  | 582 |  | 
|---|
|  | 583 | void | 
|---|
|  | 584 | SCMatrixDiagBlock::process(SCElementOp*op) | 
|---|
|  | 585 | { | 
|---|
|  | 586 | SCMatrixDiagBlockIter i(this); | 
|---|
|  | 587 | op->process(i); | 
|---|
|  | 588 | } | 
|---|
|  | 589 |  | 
|---|
|  | 590 | void | 
|---|
|  | 591 | SCMatrixDiagBlock::process(SCElementOp2*op, | 
|---|
|  | 592 | SCMatrixBlock* b) | 
|---|
|  | 593 | { | 
|---|
|  | 594 | SCMatrixDiagBlockIter i(this); | 
|---|
|  | 595 | SCMatrixDiagBlockIter j((SCMatrixDiagBlock*)b); | 
|---|
|  | 596 | op->process(i,j); | 
|---|
|  | 597 | } | 
|---|
|  | 598 |  | 
|---|
|  | 599 | void | 
|---|
|  | 600 | SCMatrixDiagBlock::process(SCElementOp3*op, | 
|---|
|  | 601 | SCMatrixBlock* b1, SCMatrixBlock* b2) | 
|---|
|  | 602 | { | 
|---|
|  | 603 | SCMatrixDiagBlockIter i(this); | 
|---|
|  | 604 | SCMatrixDiagBlockIter j((SCMatrixDiagBlock*)b1); | 
|---|
|  | 605 | SCMatrixDiagBlockIter k((SCMatrixDiagBlock*)b2); | 
|---|
|  | 606 | op->process(i,j,k); | 
|---|
|  | 607 | } | 
|---|
|  | 608 |  | 
|---|
|  | 609 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 610 | // SCMatrixDiagSubBlock member functions | 
|---|
|  | 611 |  | 
|---|
|  | 612 | static ClassDesc SCMatrixDiagSubBlock_cd( | 
|---|
|  | 613 | typeid(SCMatrixDiagSubBlock),"SCMatrixDiagSubBlock",1,"public SCMatrixBlock", | 
|---|
|  | 614 | 0, 0, create<SCMatrixDiagSubBlock>); | 
|---|
|  | 615 |  | 
|---|
|  | 616 | SCMatrixDiagSubBlock::SCMatrixDiagSubBlock(int s, int e, int o, | 
|---|
|  | 617 | double* d): | 
|---|
|  | 618 | istart(s), | 
|---|
|  | 619 | jstart(s), | 
|---|
|  | 620 | iend(e), | 
|---|
|  | 621 | offset(o), | 
|---|
|  | 622 | data(d) | 
|---|
|  | 623 | { | 
|---|
|  | 624 | } | 
|---|
|  | 625 |  | 
|---|
|  | 626 | SCMatrixDiagSubBlock::SCMatrixDiagSubBlock(int is, int ie, | 
|---|
|  | 627 | int js, int o, double* d): | 
|---|
|  | 628 | istart(is), | 
|---|
|  | 629 | jstart(js), | 
|---|
|  | 630 | iend(ie), | 
|---|
|  | 631 | offset(o), | 
|---|
|  | 632 | data(d) | 
|---|
|  | 633 | { | 
|---|
|  | 634 | } | 
|---|
|  | 635 |  | 
|---|
|  | 636 | SCMatrixDiagSubBlock::SCMatrixDiagSubBlock(StateIn&s): | 
|---|
|  | 637 | SCMatrixBlock(s) | 
|---|
|  | 638 | { | 
|---|
|  | 639 | s.get(istart); | 
|---|
|  | 640 | s.get(jstart); | 
|---|
|  | 641 | s.get(iend); | 
|---|
|  | 642 | s.get(offset); | 
|---|
|  | 643 | data = 0; | 
|---|
|  | 644 | } | 
|---|
|  | 645 |  | 
|---|
|  | 646 | void | 
|---|
|  | 647 | SCMatrixDiagSubBlock::save_data_state(StateOut&s) | 
|---|
|  | 648 | { | 
|---|
|  | 649 | SCMatrixBlock::save_data_state(s); | 
|---|
|  | 650 | s.put(istart); | 
|---|
|  | 651 | s.put(jstart); | 
|---|
|  | 652 | s.put(iend); | 
|---|
|  | 653 | s.put(offset); | 
|---|
|  | 654 | } | 
|---|
|  | 655 |  | 
|---|
|  | 656 | SCMatrixDiagSubBlock::~SCMatrixDiagSubBlock() | 
|---|
|  | 657 | { | 
|---|
|  | 658 | } | 
|---|
|  | 659 |  | 
|---|
|  | 660 | void | 
|---|
|  | 661 | SCMatrixDiagSubBlock::process(SCElementOp*op) | 
|---|
|  | 662 | { | 
|---|
|  | 663 | SCMatrixDiagSubBlockIter i(this); | 
|---|
|  | 664 | op->process(i); | 
|---|
|  | 665 | } | 
|---|
|  | 666 |  | 
|---|
|  | 667 | void | 
|---|
|  | 668 | SCMatrixDiagSubBlock::process(SCElementOp2*op, | 
|---|
|  | 669 | SCMatrixBlock* b) | 
|---|
|  | 670 | { | 
|---|
|  | 671 | SCMatrixDiagSubBlockIter i(this); | 
|---|
|  | 672 | SCMatrixDiagSubBlockIter j((SCMatrixDiagSubBlock*)b); | 
|---|
|  | 673 | op->process(i,j); | 
|---|
|  | 674 | } | 
|---|
|  | 675 |  | 
|---|
|  | 676 | void | 
|---|
|  | 677 | SCMatrixDiagSubBlock::process(SCElementOp3*op, | 
|---|
|  | 678 | SCMatrixBlock* b1, | 
|---|
|  | 679 | SCMatrixBlock* b2) | 
|---|
|  | 680 | { | 
|---|
|  | 681 | SCMatrixDiagSubBlockIter i(this); | 
|---|
|  | 682 | SCMatrixDiagSubBlockIter j((SCMatrixDiagSubBlock*)b1); | 
|---|
|  | 683 | SCMatrixDiagSubBlockIter k((SCMatrixDiagSubBlock*)b2); | 
|---|
|  | 684 | op->process(i,j,k); | 
|---|
|  | 685 | } | 
|---|
|  | 686 |  | 
|---|
|  | 687 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 688 | // SCVectorSimpleBlock member functions | 
|---|
|  | 689 |  | 
|---|
|  | 690 | static ClassDesc SCVectorSimpleBlock_cd( | 
|---|
|  | 691 | typeid(SCVectorSimpleBlock),"SCVectorSimpleBlock",1,"public SCMatrixBlock", | 
|---|
|  | 692 | 0, 0, create<SCVectorSimpleBlock>); | 
|---|
|  | 693 |  | 
|---|
|  | 694 | SCVectorSimpleBlock::SCVectorSimpleBlock(int s, int e): | 
|---|
|  | 695 | istart(s), | 
|---|
|  | 696 | iend(e) | 
|---|
|  | 697 | { | 
|---|
|  | 698 | data = new double[e-s]; | 
|---|
|  | 699 | } | 
|---|
|  | 700 |  | 
|---|
|  | 701 | SCVectorSimpleBlock::SCVectorSimpleBlock(StateIn&s): | 
|---|
|  | 702 | SCMatrixBlock(s) | 
|---|
|  | 703 | { | 
|---|
|  | 704 | s.get(istart); | 
|---|
|  | 705 | s.get(iend); | 
|---|
|  | 706 | s.get(data); | 
|---|
|  | 707 | } | 
|---|
|  | 708 |  | 
|---|
|  | 709 | void | 
|---|
|  | 710 | SCVectorSimpleBlock::save_data_state(StateOut&s) | 
|---|
|  | 711 | { | 
|---|
|  | 712 | SCMatrixBlock::save_data_state(s); | 
|---|
|  | 713 | s.put(istart); | 
|---|
|  | 714 | s.put(iend); | 
|---|
|  | 715 | s.put(data,iend-istart); | 
|---|
|  | 716 | } | 
|---|
|  | 717 |  | 
|---|
|  | 718 | SCMatrixBlock * | 
|---|
|  | 719 | SCVectorSimpleBlock::deepcopy() const | 
|---|
|  | 720 | { | 
|---|
|  | 721 | SCVectorSimpleBlock *ret = new SCVectorSimpleBlock(istart,iend); | 
|---|
|  | 722 | ret->blocki = blocki; | 
|---|
|  | 723 | ret->blockj = blockj; | 
|---|
|  | 724 | memcpy(ret->data, data, sizeof(double)*ndat()); | 
|---|
|  | 725 | return ret; | 
|---|
|  | 726 | } | 
|---|
|  | 727 |  | 
|---|
|  | 728 | double * | 
|---|
|  | 729 | SCVectorSimpleBlock::dat() | 
|---|
|  | 730 | { | 
|---|
|  | 731 | return data; | 
|---|
|  | 732 | } | 
|---|
|  | 733 |  | 
|---|
|  | 734 | int | 
|---|
|  | 735 | SCVectorSimpleBlock::ndat() const | 
|---|
|  | 736 | { | 
|---|
|  | 737 | return iend-istart; | 
|---|
|  | 738 | } | 
|---|
|  | 739 |  | 
|---|
|  | 740 | SCVectorSimpleBlock::~SCVectorSimpleBlock() | 
|---|
|  | 741 | { | 
|---|
|  | 742 | delete[] data; | 
|---|
|  | 743 | } | 
|---|
|  | 744 |  | 
|---|
|  | 745 | void | 
|---|
|  | 746 | SCVectorSimpleBlock::process(SCElementOp*op) | 
|---|
|  | 747 | { | 
|---|
|  | 748 | SCVectorSimpleBlockIter i(this); | 
|---|
|  | 749 | op->process(i); | 
|---|
|  | 750 | } | 
|---|
|  | 751 |  | 
|---|
|  | 752 | void | 
|---|
|  | 753 | SCVectorSimpleBlock::process(SCElementOp2*op, | 
|---|
|  | 754 | SCMatrixBlock* b) | 
|---|
|  | 755 | { | 
|---|
|  | 756 | SCVectorSimpleBlockIter i(this); | 
|---|
|  | 757 | SCVectorSimpleBlockIter j((SCVectorSimpleBlock*)b); | 
|---|
|  | 758 | op->process(i,j); | 
|---|
|  | 759 | } | 
|---|
|  | 760 |  | 
|---|
|  | 761 | void | 
|---|
|  | 762 | SCVectorSimpleBlock::process(SCElementOp3*op, | 
|---|
|  | 763 | SCMatrixBlock* b1, | 
|---|
|  | 764 | SCMatrixBlock* b2) | 
|---|
|  | 765 | { | 
|---|
|  | 766 | SCVectorSimpleBlockIter i(this); | 
|---|
|  | 767 | SCVectorSimpleBlockIter j((SCVectorSimpleBlock*)b1); | 
|---|
|  | 768 | SCVectorSimpleBlockIter k((SCVectorSimpleBlock*)b2); | 
|---|
|  | 769 | op->process(i,j,k); | 
|---|
|  | 770 | } | 
|---|
|  | 771 |  | 
|---|
|  | 772 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 773 | // SCVectorSimpleSubBlock member functions | 
|---|
|  | 774 |  | 
|---|
|  | 775 | static ClassDesc SCVectorSimpleSubBlock_cd( | 
|---|
|  | 776 | typeid(SCVectorSimpleSubBlock),"SCVectorSimpleSubBlock",1,"public SCMatrixBlock", | 
|---|
|  | 777 | 0, 0, create<SCVectorSimpleSubBlock>); | 
|---|
|  | 778 |  | 
|---|
|  | 779 | SCVectorSimpleSubBlock::SCVectorSimpleSubBlock(int s, int e, int o, | 
|---|
|  | 780 | double* d): | 
|---|
|  | 781 | istart(s), | 
|---|
|  | 782 | iend(e), | 
|---|
|  | 783 | offset(o), | 
|---|
|  | 784 | data(d) | 
|---|
|  | 785 | { | 
|---|
|  | 786 | } | 
|---|
|  | 787 |  | 
|---|
|  | 788 | SCVectorSimpleSubBlock::SCVectorSimpleSubBlock(StateIn&s): | 
|---|
|  | 789 | SCMatrixBlock(s) | 
|---|
|  | 790 | { | 
|---|
|  | 791 | s.get(istart); | 
|---|
|  | 792 | s.get(iend); | 
|---|
|  | 793 | s.get(offset); | 
|---|
|  | 794 | data = 0; | 
|---|
|  | 795 | } | 
|---|
|  | 796 |  | 
|---|
|  | 797 | void | 
|---|
|  | 798 | SCVectorSimpleSubBlock::save_data_state(StateOut&s) | 
|---|
|  | 799 | { | 
|---|
|  | 800 | SCMatrixBlock::save_data_state(s); | 
|---|
|  | 801 | s.put(istart); | 
|---|
|  | 802 | s.put(iend); | 
|---|
|  | 803 | s.put(offset); | 
|---|
|  | 804 | } | 
|---|
|  | 805 |  | 
|---|
|  | 806 | SCVectorSimpleSubBlock::~SCVectorSimpleSubBlock() | 
|---|
|  | 807 | { | 
|---|
|  | 808 | } | 
|---|
|  | 809 |  | 
|---|
|  | 810 | void | 
|---|
|  | 811 | SCVectorSimpleSubBlock::process(SCElementOp*op) | 
|---|
|  | 812 | { | 
|---|
|  | 813 | SCVectorSimpleSubBlockIter i(this); | 
|---|
|  | 814 | op->process(i); | 
|---|
|  | 815 | } | 
|---|
|  | 816 |  | 
|---|
|  | 817 | void | 
|---|
|  | 818 | SCVectorSimpleSubBlock::process(SCElementOp2*op, | 
|---|
|  | 819 | SCMatrixBlock* b) | 
|---|
|  | 820 | { | 
|---|
|  | 821 | SCVectorSimpleSubBlockIter i(this); | 
|---|
|  | 822 | SCVectorSimpleSubBlockIter j((SCVectorSimpleSubBlock*)b); | 
|---|
|  | 823 | op->process(i,j); | 
|---|
|  | 824 | } | 
|---|
|  | 825 |  | 
|---|
|  | 826 | void | 
|---|
|  | 827 | SCVectorSimpleSubBlock::process(SCElementOp3*op, | 
|---|
|  | 828 | SCMatrixBlock* b1, | 
|---|
|  | 829 | SCMatrixBlock* b2) | 
|---|
|  | 830 | { | 
|---|
|  | 831 | SCVectorSimpleSubBlockIter i(this); | 
|---|
|  | 832 | SCVectorSimpleSubBlockIter j((SCVectorSimpleSubBlock*)b1); | 
|---|
|  | 833 | SCVectorSimpleSubBlockIter k((SCVectorSimpleSubBlock*)b2); | 
|---|
|  | 834 | op->process(i,j,k); | 
|---|
|  | 835 | } | 
|---|
|  | 836 |  | 
|---|
|  | 837 | /////////////////////////////////////////////////////////////////////// | 
|---|
|  | 838 | // SCMatrixSubblockIter | 
|---|
|  | 839 |  | 
|---|
|  | 840 | SCMatrixSubblockIter::~SCMatrixSubblockIter() | 
|---|
|  | 841 | { | 
|---|
|  | 842 | } | 
|---|
|  | 843 |  | 
|---|
|  | 844 | /////////////////////////////////////////////////////////////////////// | 
|---|
|  | 845 | // SCMatrixSimpleSubblockIter | 
|---|
|  | 846 |  | 
|---|
|  | 847 | SCMatrixSimpleSubblockIter::SCMatrixSimpleSubblockIter( | 
|---|
|  | 848 | Access access_, | 
|---|
|  | 849 | const Ref<SCMatrixBlock> &b): | 
|---|
|  | 850 | SCMatrixSubblockIter(access_) | 
|---|
|  | 851 | { | 
|---|
|  | 852 | block_ = b; | 
|---|
|  | 853 | } | 
|---|
|  | 854 |  | 
|---|
|  | 855 | void | 
|---|
|  | 856 | SCMatrixSimpleSubblockIter::begin() | 
|---|
|  | 857 | { | 
|---|
|  | 858 | if (block_.nonnull()) ready_ = 1; | 
|---|
|  | 859 | else ready_ = 0; | 
|---|
|  | 860 | } | 
|---|
|  | 861 |  | 
|---|
|  | 862 | int | 
|---|
|  | 863 | SCMatrixSimpleSubblockIter::ready() | 
|---|
|  | 864 | { | 
|---|
|  | 865 | return ready_; | 
|---|
|  | 866 | } | 
|---|
|  | 867 |  | 
|---|
|  | 868 | void | 
|---|
|  | 869 | SCMatrixSimpleSubblockIter::next() | 
|---|
|  | 870 | { | 
|---|
|  | 871 | ready_ = 0; | 
|---|
|  | 872 | } | 
|---|
|  | 873 |  | 
|---|
|  | 874 | SCMatrixBlock * | 
|---|
|  | 875 | SCMatrixSimpleSubblockIter::block() | 
|---|
|  | 876 | { | 
|---|
|  | 877 | return block_.pointer(); | 
|---|
|  | 878 | } | 
|---|
|  | 879 |  | 
|---|
|  | 880 | /////////////////////////////////////////////////////////////////////// | 
|---|
|  | 881 | // SCMatrixListSubblockIter | 
|---|
|  | 882 |  | 
|---|
|  | 883 | SCMatrixListSubblockIter::SCMatrixListSubblockIter( | 
|---|
|  | 884 | Access access, | 
|---|
|  | 885 | const Ref<SCMatrixBlockList> &list | 
|---|
|  | 886 | ): | 
|---|
|  | 887 | SCMatrixSubblockIter(access), | 
|---|
|  | 888 | list_(list) | 
|---|
|  | 889 | { | 
|---|
|  | 890 | } | 
|---|
|  | 891 |  | 
|---|
|  | 892 | void | 
|---|
|  | 893 | SCMatrixListSubblockIter::begin() | 
|---|
|  | 894 | { | 
|---|
|  | 895 | iter_ = list_->begin(); | 
|---|
|  | 896 | } | 
|---|
|  | 897 |  | 
|---|
|  | 898 | int | 
|---|
|  | 899 | SCMatrixListSubblockIter::ready() | 
|---|
|  | 900 | { | 
|---|
|  | 901 | return iter_ != list_->end(); | 
|---|
|  | 902 | } | 
|---|
|  | 903 |  | 
|---|
|  | 904 | void | 
|---|
|  | 905 | SCMatrixListSubblockIter::next() | 
|---|
|  | 906 | { | 
|---|
|  | 907 | iter_++; | 
|---|
|  | 908 | } | 
|---|
|  | 909 |  | 
|---|
|  | 910 | SCMatrixBlock * | 
|---|
|  | 911 | SCMatrixListSubblockIter::block() | 
|---|
|  | 912 | { | 
|---|
|  | 913 | return iter_.block(); | 
|---|
|  | 914 | } | 
|---|
|  | 915 |  | 
|---|
|  | 916 | /////////////////////////////////////////////////////////////////////// | 
|---|
|  | 917 | // SCMatrixNullSubblockIter | 
|---|
|  | 918 |  | 
|---|
|  | 919 | SCMatrixNullSubblockIter::SCMatrixNullSubblockIter(): | 
|---|
|  | 920 | SCMatrixSubblockIter(None) | 
|---|
|  | 921 | { | 
|---|
|  | 922 | } | 
|---|
|  | 923 |  | 
|---|
|  | 924 | SCMatrixNullSubblockIter::SCMatrixNullSubblockIter(Access access): | 
|---|
|  | 925 | SCMatrixSubblockIter(access) | 
|---|
|  | 926 | { | 
|---|
|  | 927 | } | 
|---|
|  | 928 |  | 
|---|
|  | 929 | void | 
|---|
|  | 930 | SCMatrixNullSubblockIter::begin() | 
|---|
|  | 931 | { | 
|---|
|  | 932 | } | 
|---|
|  | 933 |  | 
|---|
|  | 934 | int | 
|---|
|  | 935 | SCMatrixNullSubblockIter::ready() | 
|---|
|  | 936 | { | 
|---|
|  | 937 | return 0; | 
|---|
|  | 938 | } | 
|---|
|  | 939 |  | 
|---|
|  | 940 | void | 
|---|
|  | 941 | SCMatrixNullSubblockIter::next() | 
|---|
|  | 942 | { | 
|---|
|  | 943 | } | 
|---|
|  | 944 |  | 
|---|
|  | 945 | SCMatrixBlock * | 
|---|
|  | 946 | SCMatrixNullSubblockIter::block() | 
|---|
|  | 947 | { | 
|---|
|  | 948 | return 0; | 
|---|
|  | 949 | } | 
|---|
|  | 950 |  | 
|---|
|  | 951 | /////////////////////////////////////////////////////////////////////// | 
|---|
|  | 952 | // SCMatrixCompositeSubblockIter | 
|---|
|  | 953 |  | 
|---|
|  | 954 | SCMatrixCompositeSubblockIter::SCMatrixCompositeSubblockIter( | 
|---|
|  | 955 | Ref<SCMatrixSubblockIter>& i1, | 
|---|
|  | 956 | Ref<SCMatrixSubblockIter>& i2): | 
|---|
|  | 957 | SCMatrixSubblockIter(None) | 
|---|
|  | 958 | { | 
|---|
|  | 959 | niters_ = 0; | 
|---|
|  | 960 | if (i1.nonnull()) { niters_++; } | 
|---|
|  | 961 | if (i2.nonnull()) { niters_++; } | 
|---|
|  | 962 | iters_ = new Ref<SCMatrixSubblockIter>[niters_]; | 
|---|
|  | 963 | iiter_ = 0; | 
|---|
|  | 964 | if (i1.nonnull()) { iters_[iiter_] = i1; iiter_++; } | 
|---|
|  | 965 | if (i2.nonnull()) { iters_[iiter_] = i2; iiter_++; } | 
|---|
|  | 966 |  | 
|---|
|  | 967 | if (niters_) access_ = iters_[0]->access(); | 
|---|
|  | 968 | for (int i=0; i<niters_; i++) { | 
|---|
|  | 969 | if (iters_[i]->access() != access_) { | 
|---|
|  | 970 | ExEnv::errn() << "SCMatrixCompositeSubblockIter: access not compatible" | 
|---|
|  | 971 | << endl; | 
|---|
|  | 972 | abort(); | 
|---|
|  | 973 | } | 
|---|
|  | 974 | } | 
|---|
|  | 975 | } | 
|---|
|  | 976 |  | 
|---|
|  | 977 | SCMatrixCompositeSubblockIter::SCMatrixCompositeSubblockIter( | 
|---|
|  | 978 | Access access_, | 
|---|
|  | 979 | int niters): | 
|---|
|  | 980 | SCMatrixSubblockIter(access_) | 
|---|
|  | 981 | { | 
|---|
|  | 982 | niters_ = niters; | 
|---|
|  | 983 | iters_ = new Ref<SCMatrixSubblockIter>[niters_]; | 
|---|
|  | 984 | } | 
|---|
|  | 985 |  | 
|---|
|  | 986 | SCMatrixCompositeSubblockIter::~SCMatrixCompositeSubblockIter() | 
|---|
|  | 987 | { | 
|---|
|  | 988 | delete[] iters_; | 
|---|
|  | 989 | } | 
|---|
|  | 990 |  | 
|---|
|  | 991 | void | 
|---|
|  | 992 | SCMatrixCompositeSubblockIter::set_iter(int i, | 
|---|
|  | 993 | const Ref<SCMatrixSubblockIter>& iter) | 
|---|
|  | 994 | { | 
|---|
|  | 995 | iters_[i] = iter; | 
|---|
|  | 996 | if (iters_[i]->access() != access_) { | 
|---|
|  | 997 | ExEnv::errn() << "SCMatrixCompositeSubblockIter: access not compatible" | 
|---|
|  | 998 | << endl; | 
|---|
|  | 999 | abort(); | 
|---|
|  | 1000 | } | 
|---|
|  | 1001 | } | 
|---|
|  | 1002 |  | 
|---|
|  | 1003 | void | 
|---|
|  | 1004 | SCMatrixCompositeSubblockIter::begin() | 
|---|
|  | 1005 | { | 
|---|
|  | 1006 | if (niters_ == 0) return; | 
|---|
|  | 1007 | iiter_ = 0; | 
|---|
|  | 1008 | iters_[iiter_]->begin(); | 
|---|
|  | 1009 | while (!iters_[iiter_]->ready()) { | 
|---|
|  | 1010 | if (iiter_ < niters_-1) { | 
|---|
|  | 1011 | iiter_++; | 
|---|
|  | 1012 | iters_[iiter_]->begin(); | 
|---|
|  | 1013 | } | 
|---|
|  | 1014 | else break; | 
|---|
|  | 1015 | } | 
|---|
|  | 1016 | } | 
|---|
|  | 1017 |  | 
|---|
|  | 1018 | int | 
|---|
|  | 1019 | SCMatrixCompositeSubblockIter::ready() | 
|---|
|  | 1020 | { | 
|---|
|  | 1021 | return iters_[iiter_]->ready(); | 
|---|
|  | 1022 | } | 
|---|
|  | 1023 |  | 
|---|
|  | 1024 | void | 
|---|
|  | 1025 | SCMatrixCompositeSubblockIter::next() | 
|---|
|  | 1026 | { | 
|---|
|  | 1027 | iters_[iiter_]->next(); | 
|---|
|  | 1028 | while (!iters_[iiter_]->ready()) { | 
|---|
|  | 1029 | if (iiter_ < niters_-1) { | 
|---|
|  | 1030 | iiter_++; | 
|---|
|  | 1031 | iters_[iiter_]->begin(); | 
|---|
|  | 1032 | } | 
|---|
|  | 1033 | else break; | 
|---|
|  | 1034 | } | 
|---|
|  | 1035 | } | 
|---|
|  | 1036 |  | 
|---|
|  | 1037 | SCMatrixBlock * | 
|---|
|  | 1038 | SCMatrixCompositeSubblockIter::block() | 
|---|
|  | 1039 | { | 
|---|
|  | 1040 | return iters_[iiter_]->block(); | 
|---|
|  | 1041 | } | 
|---|
|  | 1042 |  | 
|---|
|  | 1043 | /////////////////////////////////////////////////////////////////////// | 
|---|
|  | 1044 | // SCMatrixJointSubblockIter | 
|---|
|  | 1045 |  | 
|---|
|  | 1046 | SCMatrixJointSubblockIter::SCMatrixJointSubblockIter( | 
|---|
|  | 1047 | const Ref<SCMatrixSubblockIter>& i1, | 
|---|
|  | 1048 | const Ref<SCMatrixSubblockIter>& i2, | 
|---|
|  | 1049 | const Ref<SCMatrixSubblockIter>& i3, | 
|---|
|  | 1050 | const Ref<SCMatrixSubblockIter>& i4, | 
|---|
|  | 1051 | const Ref<SCMatrixSubblockIter>& i5): | 
|---|
|  | 1052 | SCMatrixSubblockIter(None) | 
|---|
|  | 1053 | { | 
|---|
|  | 1054 | niters_ = 0; | 
|---|
|  | 1055 | if (i1.nonnull()) { niters_++; } | 
|---|
|  | 1056 | if (i2.nonnull()) { niters_++; } | 
|---|
|  | 1057 | if (i3.nonnull()) { niters_++; } | 
|---|
|  | 1058 | if (i4.nonnull()) { niters_++; } | 
|---|
|  | 1059 | if (i5.nonnull()) { niters_++; } | 
|---|
|  | 1060 | iters_ = new Ref<SCMatrixSubblockIter>[niters_]; | 
|---|
|  | 1061 | int i = 0; | 
|---|
|  | 1062 | if (i1.nonnull()) { iters_[i] = i1; i++; } | 
|---|
|  | 1063 | if (i2.nonnull()) { iters_[i] = i2; i++; } | 
|---|
|  | 1064 | if (i3.nonnull()) { iters_[i] = i3; i++; } | 
|---|
|  | 1065 | if (i4.nonnull()) { iters_[i] = i4; i++; } | 
|---|
|  | 1066 | if (i5.nonnull()) { iters_[i] = i5; i++; } | 
|---|
|  | 1067 | } | 
|---|
|  | 1068 |  | 
|---|
|  | 1069 | SCMatrixJointSubblockIter::~SCMatrixJointSubblockIter() | 
|---|
|  | 1070 | { | 
|---|
|  | 1071 | delete[] iters_; | 
|---|
|  | 1072 | } | 
|---|
|  | 1073 |  | 
|---|
|  | 1074 | void | 
|---|
|  | 1075 | SCMatrixJointSubblockIter::begin() | 
|---|
|  | 1076 | { | 
|---|
|  | 1077 | for (int i=0; i<niters_; i++) { | 
|---|
|  | 1078 | iters_[i]->begin(); | 
|---|
|  | 1079 | } | 
|---|
|  | 1080 | } | 
|---|
|  | 1081 |  | 
|---|
|  | 1082 | int | 
|---|
|  | 1083 | SCMatrixJointSubblockIter::ready() | 
|---|
|  | 1084 | { | 
|---|
|  | 1085 | int nready = 0; | 
|---|
|  | 1086 | for (int i=0; i<niters_; i++) { | 
|---|
|  | 1087 | nready += (iters_[i]->ready()?1:0); | 
|---|
|  | 1088 | } | 
|---|
|  | 1089 |  | 
|---|
|  | 1090 | if (nready == niters_) | 
|---|
|  | 1091 | return 1; | 
|---|
|  | 1092 | else if (!nready) | 
|---|
|  | 1093 | return 0; | 
|---|
|  | 1094 |  | 
|---|
|  | 1095 | ExEnv::errn() << "SCMatrixJointSubblockIter: incompatible iterators" << endl; | 
|---|
|  | 1096 | abort(); | 
|---|
|  | 1097 | return 0; | 
|---|
|  | 1098 | } | 
|---|
|  | 1099 |  | 
|---|
|  | 1100 | void | 
|---|
|  | 1101 | SCMatrixJointSubblockIter::next() | 
|---|
|  | 1102 | { | 
|---|
|  | 1103 | for (int i=0; i<niters_; i++) { | 
|---|
|  | 1104 | iters_[i]->next(); | 
|---|
|  | 1105 | } | 
|---|
|  | 1106 | } | 
|---|
|  | 1107 |  | 
|---|
|  | 1108 | SCMatrixBlock * | 
|---|
|  | 1109 | SCMatrixJointSubblockIter::block() | 
|---|
|  | 1110 | { | 
|---|
|  | 1111 | return block(0); | 
|---|
|  | 1112 | } | 
|---|
|  | 1113 |  | 
|---|
|  | 1114 | SCMatrixBlock * | 
|---|
|  | 1115 | SCMatrixJointSubblockIter::block(int b) | 
|---|
|  | 1116 | { | 
|---|
|  | 1117 | return iters_[b]->block(); | 
|---|
|  | 1118 | } | 
|---|
|  | 1119 |  | 
|---|
|  | 1120 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 1121 |  | 
|---|
|  | 1122 | // Local Variables: | 
|---|
|  | 1123 | // mode: c++ | 
|---|
|  | 1124 | // c-file-style: "CLJ" | 
|---|
|  | 1125 | // End: | 
|---|