source: ThirdParty/mpqc_open/src/lib/math/scmat/blkiter.cc@ 1513599

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 1513599 was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 8.5 KB
Line 
1//
2// blkiter.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 <util/misc/formio.h>
33#include <math/scmat/blkiter.h>
34#include <math/scmat/block.h>
35
36using namespace sc;
37
38/////////////////////////////////////////////////////////////////////////////
39// SCMatrixBlockIter member functions
40
41SCMatrixBlockIter::~SCMatrixBlockIter()
42{
43}
44
45void
46SCMatrixBlockIter::accum(double a)
47{
48 set(get()+a);
49}
50
51/////////////////////////////////////////////////////////////////////////////
52// SCMatrixRectBlockIter member functions
53
54SCMatrixRectBlockIter::SCMatrixRectBlockIter(SCMatrixRectBlock*a):
55 block(a)
56{
57 reset();
58}
59
60void
61SCMatrixRectBlockIter::reset()
62{
63 block_index = 0;
64 i_ = block->istart;
65 j_ = block->jstart;
66}
67
68SCMatrixRectBlockIter::~SCMatrixRectBlockIter()
69{
70}
71
72int
73SCMatrixRectBlockIter::i()
74{
75 return i_;
76}
77
78int
79SCMatrixRectBlockIter::j()
80{
81 return j_;
82}
83
84double
85SCMatrixRectBlockIter::get()
86{
87 return block->data[block_index];
88}
89
90void
91SCMatrixRectBlockIter::set(double a)
92{
93 block->data[block_index] = a;
94}
95
96SCMatrixRectBlockIter::operator int()
97{
98 return (i_ < block->iend && j_ < block->jend);
99}
100
101void
102SCMatrixRectBlockIter::operator ++()
103{
104 j_++;
105 if (j_ >= block->jend) {
106 j_ = block->jstart;
107 i_++;
108 }
109 block_index++;
110}
111
112/////////////////////////////////////////////////////////////////////////////
113// SCMatrixRectSubBlockIter member functions
114
115SCMatrixRectSubBlockIter::SCMatrixRectSubBlockIter(SCMatrixRectSubBlock*a):
116 block(a)
117{
118 reset();
119}
120
121void
122SCMatrixRectSubBlockIter::reset()
123{
124 i_ = block->istart;
125 j_ = block->jstart;
126 block_index = i_ * block->istride + j_;
127}
128
129SCMatrixRectSubBlockIter::~SCMatrixRectSubBlockIter()
130{
131}
132
133int
134SCMatrixRectSubBlockIter::i()
135{
136 return i_;
137}
138
139int
140SCMatrixRectSubBlockIter::j()
141{
142 return j_;
143}
144
145double
146SCMatrixRectSubBlockIter::get()
147{
148 return block->data[block_index];
149}
150
151void
152SCMatrixRectSubBlockIter::set(double a)
153{
154 block->data[block_index] = a;
155}
156
157SCMatrixRectSubBlockIter::operator int()
158{
159 return (i_ < block->iend && j_ < block->jend);
160}
161
162void
163SCMatrixRectSubBlockIter::operator ++()
164{
165 j_++;
166 block_index++;
167 if (j_ >= block->jend) {
168 j_ = block->jstart;
169 i_++;
170 block_index += block->istride - (block->jend - block->jstart);
171 }
172}
173
174/////////////////////////////////////////////////////////////////////////////
175// SCMatrixLTriBlockIter member functions
176
177SCMatrixLTriBlockIter::SCMatrixLTriBlockIter(SCMatrixLTriBlock*a):
178 block(a)
179{
180 reset();
181}
182
183void
184SCMatrixLTriBlockIter::reset()
185{
186 block_index = 0;
187 i_ = block->start;
188 j_ = block->start;
189}
190
191SCMatrixLTriBlockIter::~SCMatrixLTriBlockIter()
192{
193}
194
195int
196SCMatrixLTriBlockIter::i()
197{
198 return i_;
199}
200
201int
202SCMatrixLTriBlockIter::j()
203{
204 return j_;
205}
206
207double
208SCMatrixLTriBlockIter::get()
209{
210 return block->data[block_index];
211}
212
213void
214SCMatrixLTriBlockIter::set(double a)
215{
216 block->data[block_index] = a;
217}
218
219SCMatrixLTriBlockIter::operator int()
220{
221 return (i_ < block->end);
222}
223
224void
225SCMatrixLTriBlockIter::operator ++()
226{
227 j_++;
228 if (j_ > i_) {
229 j_ = block->start;
230 i_++;
231 }
232 block_index++;
233}
234
235/////////////////////////////////////////////////////////////////////////////
236// SCMatrixLTriSubBlockIter member functions
237
238SCMatrixLTriSubBlockIter::SCMatrixLTriSubBlockIter(
239 SCMatrixLTriSubBlock*a):
240 block(a)
241{
242 reset();
243}
244
245void
246SCMatrixLTriSubBlockIter::reset()
247{
248 i_ = block->istart;
249 j_ = block->jstart;
250 block_index = (i_*(i_+1)>>1) + j_;
251}
252
253SCMatrixLTriSubBlockIter::~SCMatrixLTriSubBlockIter()
254{
255}
256
257int
258SCMatrixLTriSubBlockIter::i()
259{
260 return i_;
261}
262
263int
264SCMatrixLTriSubBlockIter::j()
265{
266 return j_;
267}
268
269double
270SCMatrixLTriSubBlockIter::get()
271{
272 return block->data[block_index];
273}
274
275void
276SCMatrixLTriSubBlockIter::set(double a)
277{
278 block->data[block_index] = a;
279}
280
281SCMatrixLTriSubBlockIter::operator int()
282{
283 return (i_ < block->iend);
284}
285
286void
287SCMatrixLTriSubBlockIter::operator ++()
288{
289 j_++;
290 block_index++;
291 if (j_ > i_) {
292 j_ = block->jstart;
293 i_++;
294 block_index += block->istart;
295 }
296 else if (j_ >= block->jend) {
297 j_ = block->jstart;
298 i_++;
299 block_index += i_ + block->jstart - block->jend;
300 }
301}
302
303/////////////////////////////////////////////////////////////////////////////
304// SCMatrixDiagBlockIter member functions
305
306SCMatrixDiagBlockIter::SCMatrixDiagBlockIter(SCMatrixDiagBlock*a):
307 block(a)
308{
309 reset();
310}
311
312void
313SCMatrixDiagBlockIter::reset()
314{
315 block_index = 0;
316 i_ = block->istart;
317}
318
319SCMatrixDiagBlockIter::~SCMatrixDiagBlockIter()
320{
321}
322
323int
324SCMatrixDiagBlockIter::i()
325{
326 return i_;
327}
328
329int
330SCMatrixDiagBlockIter::j()
331{
332 return i_ + block->jstart - block->istart;
333}
334
335double
336SCMatrixDiagBlockIter::get()
337{
338 return block->data[block_index];
339}
340
341void
342SCMatrixDiagBlockIter::set(double a)
343{
344 block->data[block_index] = a;
345}
346
347SCMatrixDiagBlockIter::operator int()
348{
349 return (i_ < block->iend);
350}
351
352void
353SCMatrixDiagBlockIter::operator ++()
354{
355 i_++;
356 block_index++;
357}
358
359/////////////////////////////////////////////////////////////////////////////
360// SCMatrixDiagSubBlockIter member functions
361
362SCMatrixDiagSubBlockIter::SCMatrixDiagSubBlockIter(SCMatrixDiagSubBlock*a):
363 block(a)
364{
365 reset();
366}
367
368void
369SCMatrixDiagSubBlockIter::reset()
370{
371 block_index = block->offset;
372 i_ = block->istart;
373}
374
375SCMatrixDiagSubBlockIter::~SCMatrixDiagSubBlockIter()
376{
377}
378
379int
380SCMatrixDiagSubBlockIter::i()
381{
382 return i_;
383}
384
385int
386SCMatrixDiagSubBlockIter::j()
387{
388 return i_ + block->jstart - block->istart;
389}
390
391double
392SCMatrixDiagSubBlockIter::get()
393{
394 return block->data[block_index];
395}
396
397void
398SCMatrixDiagSubBlockIter::set(double a)
399{
400 block->data[block_index] = a;
401}
402
403SCMatrixDiagSubBlockIter::operator int()
404{
405 return (i_ < block->iend);
406}
407
408void
409SCMatrixDiagSubBlockIter::operator ++()
410{
411 i_++;
412 block_index++;
413}
414
415/////////////////////////////////////////////////////////////////////////////
416// SCVectorSimpleBlockIter member functions
417
418SCVectorSimpleBlockIter::SCVectorSimpleBlockIter(SCVectorSimpleBlock*a):
419 block(a)
420{
421 reset();
422}
423
424void
425SCVectorSimpleBlockIter::reset()
426{
427 block_index = 0;
428 i_ = block->istart;
429}
430
431SCVectorSimpleBlockIter::~SCVectorSimpleBlockIter()
432{
433}
434
435int
436SCVectorSimpleBlockIter::i()
437{
438 return i_;
439}
440
441int
442SCVectorSimpleBlockIter::j()
443{
444 ExEnv::errn() << indent << "SCVectorSimpleBlockIter::j() attempted to find j value\n";
445 abort();
446 return 0;
447}
448
449double
450SCVectorSimpleBlockIter::get()
451{
452 return block->data[block_index];
453}
454
455void
456SCVectorSimpleBlockIter::set(double a)
457{
458 block->data[block_index] = a;
459}
460
461SCVectorSimpleBlockIter::operator int()
462{
463 return (i_ < block->iend);
464}
465
466void
467SCVectorSimpleBlockIter::operator ++()
468{
469 i_++;
470 block_index++;
471}
472
473/////////////////////////////////////////////////////////////////////////////
474// SCVectorSimpleSubBlockIter member functions
475
476SCVectorSimpleSubBlockIter::SCVectorSimpleSubBlockIter(
477 SCVectorSimpleSubBlock*a):
478 block(a)
479{
480 reset();
481}
482
483void
484SCVectorSimpleSubBlockIter::reset()
485{
486 block_index = block->offset;
487 i_ = block->istart;
488}
489
490SCVectorSimpleSubBlockIter::~SCVectorSimpleSubBlockIter()
491{
492}
493
494int
495SCVectorSimpleSubBlockIter::i()
496{
497 return i_;
498}
499
500int
501SCVectorSimpleSubBlockIter::j()
502{
503 ExEnv::errn() << indent
504 << "SCVectorSimpleSubBlockIter::j(): attempted to find j value\n";
505 abort();
506 return 0;
507}
508
509double
510SCVectorSimpleSubBlockIter::get()
511{
512 return block->data[block_index];
513}
514
515void
516SCVectorSimpleSubBlockIter::set(double a)
517{
518 block->data[block_index] = a;
519}
520
521SCVectorSimpleSubBlockIter::operator int()
522{
523 return (i_ < block->iend);
524}
525
526void
527SCVectorSimpleSubBlockIter::operator ++()
528{
529 i_++;
530 block_index++;
531}
532
533/////////////////////////////////////////////////////////////////////////////
534
535// Local Variables:
536// mode: c++
537// c-file-style: "CLJ"
538// End:
Note: See TracBrowser for help on using the repository browser.