cisst-saw
Loading...
Searching...
No Matches
vctDynamicCompactLoopEngines.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5
6 Author(s): Anton Deguet
7 Created on: 2007-07-07
8
9 (C) Copyright 2007-2013 Johns Hopkins University (JHU), All Rights
10 Reserved.
11
12--- begin cisst license - do not edit ---
13
14This software is provided "as is" under an open source license, with
15no warranty. The complete license can be found in license.txt and
16http://www.cisst.org/cisst/license.txt.
17
18--- end cisst license ---
19*/
20
21#pragma once
22#ifndef _vctDynamicCompactLoopEngines_h
23#define _vctDynamicCompactLoopEngines_h
24
29
32
57
58 public:
59
71 template<class _elementOperationType>
72 class CoCiCi {
73 public:
74 template<class _outputOwnerType, class _input1OwnerType, class _input2OwnerType>
75 static inline void Run(_outputOwnerType & outputOwner,
76 const _input1OwnerType & input1Owner,
77 const _input2OwnerType & input2Owner) {
78
79 typedef _outputOwnerType OutputOwnerType;
80 typedef typename OutputOwnerType::pointer OutputPointerType;
81 typedef typename OutputOwnerType::size_type size_type;
82
83 typedef _input1OwnerType Input1OwnerType;
84 typedef typename Input1OwnerType::const_pointer Input1PointerType;
85
86 typedef _input2OwnerType Input2OwnerType;
87 typedef typename Input2OwnerType::const_pointer Input2PointerType;
88
89 const size_type size = outputOwner.size();
90
91 OutputPointerType outputPointer = outputOwner.Pointer();
92 const OutputPointerType outputEnd = outputPointer + size;
93
94 Input1PointerType input1Pointer = input1Owner.Pointer();
95 Input2PointerType input2Pointer = input2Owner.Pointer();
96
97 for (;
98 outputPointer != outputEnd;
99 outputPointer++, input1Pointer++, input2Pointer++) {
100 *outputPointer = _elementOperationType::Operate(*input1Pointer, *input2Pointer);
101 }
102 }
103 };
104
105
117 template<class _elementOperationType>
118 class CioCi {
119 public:
120 template<class _inputOutputOwnerType, class _inputOwnerType>
121 static void Run(_inputOutputOwnerType & inputOutputOwner,
122 const _inputOwnerType & inputOwner) {
123
124 typedef _inputOutputOwnerType InputOutputOwnerType;
125 typedef typename InputOutputOwnerType::pointer InputOutputPointerType;
126 typedef typename InputOutputOwnerType::size_type size_type;
127
128 typedef _inputOwnerType InputOwnerType;
129 typedef typename InputOwnerType::const_pointer InputPointerType;
130
131 const size_type size = inputOutputOwner.size();
132
133 InputOutputPointerType inputOutputPointer = inputOutputOwner.Pointer();
134 const InputOutputPointerType inputOutputEnd = inputOutputPointer + size;
135
136 InputPointerType inputPointer = inputOwner.Pointer();
137
138 for (;
139 inputOutputPointer != inputOutputEnd;
140 inputOutputPointer++, inputPointer++) {
141 *inputOutputPointer = _elementOperationType::Operate(*inputOutputPointer, *inputPointer);
142 }
143 }
144 };
145
146
159 template<class _elementOperationType>
160 class CioCio {
161 public:
162 template<class _inputOutput1OwnerType, class _inputOutput2OwnerType>
163 static void Run(_inputOutput1OwnerType & inputOutput1Owner,
164 _inputOutput2OwnerType & inputOutput2Owner) {
165
166 typedef _inputOutput1OwnerType InputOutput1OwnerType;
167 typedef typename InputOutput1OwnerType::pointer InputOutput1PointerType;
168 typedef typename InputOutput1OwnerType::size_type size_type;
169
170 typedef _inputOutput2OwnerType InputOutput2OwnerType;
171 typedef typename InputOutput2OwnerType::pointer InputOutput2PointerType;
172
173 const size_type size = inputOutput1Owner.size();
174
175 InputOutput1PointerType inputOutput1Pointer = inputOutput1Owner.Pointer();
176 const InputOutput1PointerType inputOutput1End = inputOutput1Pointer + size;
177
178 InputOutput2PointerType inputOutput2Pointer = inputOutput2Owner.Pointer();
179
180 for (;
181 inputOutput1Pointer != inputOutput1End;
182 inputOutput1Pointer++, inputOutput2Pointer++) {
183 _elementOperationType::Operate(*inputOutput1Pointer, *inputOutput2Pointer);
184 }
185 }
186 };
187
188
200 template<class _elementOperationType>
201 class CoCiSi {
202 public:
203 template<class _outputOwnerType, class _inputOwnerType, class _inputScalarType>
204 static inline void Run(_outputOwnerType & outputOwner,
205 const _inputOwnerType & inputOwner,
206 const _inputScalarType inputScalar) {
207
208 typedef _outputOwnerType OutputOwnerType;
209 typedef typename OutputOwnerType::pointer OutputPointerType;
210 typedef typename OutputOwnerType::size_type size_type;
211
212 typedef _inputOwnerType InputOwnerType;
213 typedef typename InputOwnerType::const_pointer InputPointerType;
214
215 const size_type size = outputOwner.size();
216
217 OutputPointerType outputPointer = outputOwner.Pointer();
218 const OutputPointerType outputEnd = outputPointer + size;
219
220 InputPointerType inputPointer = inputOwner.Pointer();
221
222 for (;
223 outputPointer != outputEnd;
224 outputPointer++, inputPointer++) {
225 *outputPointer = _elementOperationType::Operate(*inputPointer, inputScalar);
226 }
227 }
228 };
229
230
242 template<class _elementOperationType>
243 class CoSiCi {
244 public:
245 template<class _outputOwnerType, class _inputScalarType, class _inputOwnerType>
246 static inline void Run(_outputOwnerType & outputOwner,
247 const _inputScalarType inputScalar,
248 const _inputOwnerType & inputOwner) {
249
250 typedef _outputOwnerType OutputOwnerType;
251 typedef typename OutputOwnerType::pointer OutputPointerType;
252 typedef typename OutputOwnerType::size_type size_type;
253
254 typedef _inputOwnerType InputOwnerType;
255 typedef typename InputOwnerType::const_pointer InputPointerType;
256
257 const size_type size = outputOwner.size();
258
259 OutputPointerType outputPointer = outputOwner.Pointer();
260 const OutputPointerType outputEnd = outputPointer + size;
261
262 InputPointerType inputPointer = inputOwner.Pointer();
263
264 for (;
265 outputPointer != outputEnd;
266 outputPointer++, inputPointer++) {
267 *outputPointer = _elementOperationType::Operate(inputScalar, *inputPointer);
268 }
269 }
270 };
271
272
285 template<class _elementOperationType>
286 class CioSi {
287 public:
288 template<class _inputOutputOwnerType, class _inputScalarType>
289 static void Run(_inputOutputOwnerType & inputOutputOwner,
290 const _inputScalarType inputScalar) {
291
292 typedef _inputOutputOwnerType InputOutputOwnerType;
293 typedef typename InputOutputOwnerType::pointer InputOutputPointerType;
294 typedef typename InputOutputOwnerType::size_type size_type;
295
296 const size_type size = inputOutputOwner.size();
297
298 InputOutputPointerType inputOutputPointer = inputOutputOwner.Pointer();
299 const InputOutputPointerType inputOutputEnd = inputOutputPointer + size;;
300
301 for (;
302 inputOutputPointer != inputOutputEnd;
303 inputOutputPointer++) {
304 _elementOperationType::Operate(*inputOutputPointer, inputScalar);
305 }
306 }
307 };
308
309
321 template<class _elementOperationType>
322 class CoCi {
323 public:
324 template<class _outputOwnerType, class _inputOwnerType>
325 static inline void Run(_outputOwnerType & outputOwner,
326 const _inputOwnerType & inputOwner) {
327
328 typedef _outputOwnerType OutputOwnerType;
329 typedef typename OutputOwnerType::pointer OutputPointerType;
330 typedef typename OutputOwnerType::size_type size_type;
331
332 typedef _inputOwnerType InputOwnerType;
333 typedef typename InputOwnerType::const_pointer InputPointerType;
334
335 OutputPointerType outputPointer = outputOwner.Pointer();
336 const size_type size = outputOwner.size();
337 const OutputPointerType outputEnd = outputPointer + size;
338
339 InputPointerType inputPointer = inputOwner.Pointer();
340
341 for (;
342 outputPointer != outputEnd;
343 outputPointer++, inputPointer++) {
344 *outputPointer = _elementOperationType::Operate(*inputPointer);
345 }
346 }
347 };
348
349
350
363 template<class _elementOperationType>
364 class Cio {
365 public:
366 template<class _inputOutputOwnerType>
367 static inline void Run(_inputOutputOwnerType & inputOutputOwner) {
368
369 typedef _inputOutputOwnerType InputOutputOwnerType;
370 typedef typename InputOutputOwnerType::pointer InputOutputPointerType;
371 typedef typename InputOutputOwnerType::size_type size_type;
372
373 const size_type size = inputOutputOwner.size();
374
375 InputOutputPointerType inputOutputPointer = inputOutputOwner.Pointer();
376 const InputOutputPointerType inputOutputEnd = inputOutputPointer + size;
377
378 for (;
379 inputOutputPointer != inputOutputEnd;
380 inputOutputPointer++) {
381 _elementOperationType::Operate(*inputOutputPointer);
382 }
383 }
384 };
385
386
387
400 template<class _incrementalOperationType, class _elementOperationType>
401 class SoCi {
402 public:
403 typedef typename _incrementalOperationType::OutputType OutputType;
404
405 template<class _inputOwnerType>
406 static OutputType Run(const _inputOwnerType & inputOwner) {
407
408 typedef _inputOwnerType InputOwnerType;
409 typedef typename InputOwnerType::const_pointer InputPointerType;
410 typedef typename InputOwnerType::size_type size_type;
411
412 const size_type size = inputOwner.size();
413 OutputType incrementalResult = _incrementalOperationType::NeutralElement();
414
415 InputPointerType inputPointer = inputOwner.Pointer();
416 const InputPointerType inputEnd = inputPointer + size;
417
418 for (;
419 inputPointer != inputEnd;
420 inputPointer++) {
421 incrementalResult = _incrementalOperationType::Operate(incrementalResult,
422 _elementOperationType::Operate(*inputPointer));
423 }
424 return incrementalResult;
425 }
426 };
427
428
444 template<class _incrementalOperationType, class _elementOperationType>
445 class SoCiCi {
446 public:
447 typedef typename _incrementalOperationType::OutputType OutputType;
448
449 template<class _input1OwnerType, class _input2OwnerType>
450 static inline OutputType Run(const _input1OwnerType & input1Owner,
451 const _input2OwnerType & input2Owner) {
452
453 typedef _input1OwnerType Input1OwnerType;
454 typedef typename Input1OwnerType::const_pointer Input1PointerType;
455 typedef typename Input1OwnerType::size_type size_type;
456
457 typedef _input2OwnerType Input2OwnerType;
458 typedef typename Input2OwnerType::const_pointer Input2PointerType;
459
460 const size_type size = input1Owner.size();
461
462 OutputType incrementalResult = _incrementalOperationType::NeutralElement();
463
464 Input1PointerType input1Pointer = input1Owner.Pointer();
465 const Input1PointerType input1End = input1Pointer + size;
466
467 Input2PointerType input2Pointer = input2Owner.Pointer();
468
469 for (;
470 input1Pointer != input1End;
471 input1Pointer++, input2Pointer++) {
472 incrementalResult = _incrementalOperationType::Operate(incrementalResult,
473 _elementOperationType::Operate(*input1Pointer,
474 *input2Pointer));
475 }
476 return incrementalResult;
477 }
478 };
479
480
496 template<class _ioElementOperationType, class _scalarElementOperationType>
497 class CioSiCi {
498 public:
499 template<class _ioOwnerType, class _inputScalarType, class _inputOwnerType>
500 static inline void Run(_ioOwnerType & ioOwner,
501 const _inputScalarType inputScalar, const _inputOwnerType & inputOwner)
502 {
503 typedef _ioOwnerType IoOwnerType;
504 typedef typename IoOwnerType::pointer IoPointerType;
505 typedef typename IoOwnerType::size_type size_type;
506
507 typedef _inputOwnerType InputOwnerType;
508 typedef typename InputOwnerType::const_pointer InputPointerType;
509
510 const size_type size = ioOwner.size();
511
512 IoPointerType ioPointer = ioOwner.Pointer();
513 const IoPointerType ioEnd = ioPointer + size;
514
515 InputPointerType inputPointer = inputOwner.Pointer();
516
517 for (;
518 ioPointer != ioEnd;
519 ioPointer++, inputPointer++)
520 {
521 _ioElementOperationType::Operate(*ioPointer,
522 _scalarElementOperationType::Operate(inputScalar, *inputPointer));
523 }
524 }
525
526 };
527
528
529
545 template<class _ioElementOperationType, class _ownerElementOperationType>
546 class CioCiCi {
547 public:
548 template<class _ioOwnerType, class _input1OwnerType, class _input2OwnerType>
549 static inline void Run(_ioOwnerType & ioOwner,
550 const _input1OwnerType & input1Owner, const _input2OwnerType & input2Owner)
551 {
552 typedef _ioOwnerType IoOwnerType;
553 typedef typename IoOwnerType::pointer IoPointerType;
554 typedef typename IoOwnerType::size_type size_type;
555
556 typedef _input1OwnerType Input1OwnerType;
557 typedef typename Input1OwnerType::const_pointer Input1PointerType;
558
559 typedef _input2OwnerType Input2OwnerType;
560 typedef typename Input2OwnerType::const_pointer Input2PointerType;
561
562 const size_type size = ioOwner.size();
563
564 IoPointerType ioPointer = ioOwner.Pointer();
565 const IoPointerType ioEnd = ioPointer + size;
566
567 Input1PointerType input1Pointer = input1Owner.Pointer();
568 Input2PointerType input2Pointer = input2Owner.Pointer();
569
570 for (;
571 ioPointer != ioEnd;
572 ioPointer++, input1Pointer++, input2Pointer++)
573 {
574 _ioElementOperationType::Operate(*ioPointer,
575 _ownerElementOperationType::Operate(*input1Pointer, *input2Pointer));
576 }
577 }
578
579 };
580
581
597 template<class _incrementalOperationType, class _elementOperationType>
598 class SoCiSi {
599 public:
600 typedef typename _incrementalOperationType::OutputType OutputType;
601
602 template<class _inputOwnerType, class _inputScalarType>
603 static inline OutputType Run(const _inputOwnerType & inputOwner,
604 const _inputScalarType & inputScalar) {
605
606 typedef _inputOwnerType InputOwnerType;
607 typedef typename InputOwnerType::const_pointer InputPointerType;
608 typedef typename InputOwnerType::size_type size_type;
609
610 const size_type size = inputOwner.size();
611 OutputType incrementalResult = _incrementalOperationType::NeutralElement();
612
613 InputPointerType inputPointer = inputOwner.Pointer();
614 const InputPointerType inputEnd = inputPointer + size;
615
616 for (;
617 inputPointer != inputEnd;
618 inputPointer++) {
619 incrementalResult = _incrementalOperationType::Operate(incrementalResult,
620 _elementOperationType::Operate(*inputPointer, inputScalar));
621 }
622 return incrementalResult;
623 }
624 };
625
626
627 class MinAndMax {
628 public:
629 template<class _inputOwnerType>
630 static void Run(const _inputOwnerType & inputOwner, typename _inputOwnerType::value_type & minValue,
631 typename _inputOwnerType::value_type & maxValue)
632 {
633 typedef _inputOwnerType InputOwnerType;
634 typedef typename InputOwnerType::const_pointer InputPointerType;
635 typedef typename InputOwnerType::size_type size_type;
636 typedef typename InputOwnerType::value_type value_type;
637
638 InputPointerType inputPointer = inputOwner.Pointer();
639
640 const size_type size = inputOwner.size();
641 const InputPointerType inputEnd = inputPointer + size;
642
643 value_type minElement, maxElement;
644 maxElement = minElement = *inputPointer;
645
646 for (;
647 inputPointer != inputEnd;
648 inputPointer++) {
649 const value_type element = *inputPointer;
650 if (element < minElement) {
651 minElement = element;
652 } else if (maxElement < element) {
653 maxElement = element;
654 }
655 }
656 minValue = minElement;
657 maxValue = maxElement;
658 }
659 };
660
661};
662
663
664#endif // _vctDynamicCompactLoopEngines_h
665
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:546
static void Run(_ioOwnerType &ioOwner, const _input1OwnerType &input1Owner, const _input2OwnerType &input2Owner)
Definition vctDynamicCompactLoopEngines.h:549
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:118
static void Run(_inputOutputOwnerType &inputOutputOwner, const _inputOwnerType &inputOwner)
Definition vctDynamicCompactLoopEngines.h:121
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:160
static void Run(_inputOutput1OwnerType &inputOutput1Owner, _inputOutput2OwnerType &inputOutput2Owner)
Definition vctDynamicCompactLoopEngines.h:163
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:364
static void Run(_inputOutputOwnerType &inputOutputOwner)
Definition vctDynamicCompactLoopEngines.h:367
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:497
static void Run(_ioOwnerType &ioOwner, const _inputScalarType inputScalar, const _inputOwnerType &inputOwner)
Definition vctDynamicCompactLoopEngines.h:500
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:286
static void Run(_inputOutputOwnerType &inputOutputOwner, const _inputScalarType inputScalar)
Definition vctDynamicCompactLoopEngines.h:289
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:72
static void Run(_outputOwnerType &outputOwner, const _input1OwnerType &input1Owner, const _input2OwnerType &input2Owner)
Definition vctDynamicCompactLoopEngines.h:75
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:322
static void Run(_outputOwnerType &outputOwner, const _inputOwnerType &inputOwner)
Definition vctDynamicCompactLoopEngines.h:325
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:201
static void Run(_outputOwnerType &outputOwner, const _inputOwnerType &inputOwner, const _inputScalarType inputScalar)
Definition vctDynamicCompactLoopEngines.h:204
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:243
static void Run(_outputOwnerType &outputOwner, const _inputScalarType inputScalar, const _inputOwnerType &inputOwner)
Definition vctDynamicCompactLoopEngines.h:246
Definition vctDynamicCompactLoopEngines.h:627
static void Run(const _inputOwnerType &inputOwner, typename _inputOwnerType::value_type &minValue, typename _inputOwnerType::value_type &maxValue)
Definition vctDynamicCompactLoopEngines.h:630
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:445
_incrementalOperationType::OutputType OutputType
Definition vctDynamicCompactLoopEngines.h:447
static OutputType Run(const _input1OwnerType &input1Owner, const _input2OwnerType &input2Owner)
Definition vctDynamicCompactLoopEngines.h:450
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:401
_incrementalOperationType::OutputType OutputType
Definition vctDynamicCompactLoopEngines.h:403
static OutputType Run(const _inputOwnerType &inputOwner)
Definition vctDynamicCompactLoopEngines.h:406
Implement operation of the form for compact containers.
Definition vctDynamicCompactLoopEngines.h:598
_incrementalOperationType::OutputType OutputType
Definition vctDynamicCompactLoopEngines.h:600
static OutputType Run(const _inputOwnerType &inputOwner, const _inputScalarType &inputScalar)
Definition vctDynamicCompactLoopEngines.h:603
Container class for the loop based engines for compact containers.
Definition vctDynamicCompactLoopEngines.h:56
Portability across compilers and operating systems tools.
Declaration of the template function cmnThrow.
size_type size(void) const
Definition vctDynamicConstMatrixBase.h:228