File size: 23,864 Bytes
68ce2fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-    */
/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */

/*

  Author(s):	Anton Deguet
  Created on:	2007-07-07

  (C) Copyright 2007-2013 Johns Hopkins University (JHU), All Rights
  Reserved.

--- begin cisst license - do not edit ---

This software is provided "as is" under an open source license, with
no warranty.  The complete license can be found in license.txt and
http://www.cisst.org/cisst/license.txt.

--- end cisst license ---
*/

#pragma once
#ifndef _vctDynamicCompactLoopEngines_h
#define _vctDynamicCompactLoopEngines_h

/*!
  \file
  \brief Declaration of vctDynamicCompactLoopEngines
 */

#include <cisstCommon/cmnPortability.h>
#include <cisstCommon/cmnThrow.h>

/*!  \brief Container class for the loop based engines for compact
  containers.

  These engines are a simplified version of those found in
  vctDynamicVectorLoopEngines, vctDynamicMatrixLoopEngines and
  vctDynamicNArrayLoopEngines.  They can only operate on compact
  containers and provided that all parameters have the same memory
  layout, i.e. the same strides.  In this specific cases, a single
  loop can be used to operate on all the elements as opposed to nested
  loops or more complicated structures (as for NArrays).  This results
  on a significant speed gain.  Furthermore, as the stride is always
  "one", the operator "++" can be used which in some compilation mode
  can provide a slight speed boost.

  \note These engines don't perform any layout check as this is done
  by the other engines.

  \note These engines operate directly on the owners as the engines
  calling them already a pointer on the owner.

  \sa vctDynamicVectorLoopEngines, vctDynamicMatrixLoopEngines,
  vctDynamicNArrayLoopEngines.
*/
class vctDynamicCompactLoopEngines {

 public:

    /*!  \brief Implement operation of the form \f$v_o = op(v_{i1},
      v_{i2})\f$ for compact containers.

      This class uses a loop to perform binary vector operations
      of the form
      \f[
      v_o = \mathrm{op}(v_{i1}, v_{i2})
      \f]

      \param _elementOperationType The type of the binary operation.
    */
    template<class _elementOperationType>
    class CoCiCi {
    public:
        template<class _outputOwnerType, class _input1OwnerType, class _input2OwnerType>
        static inline void Run(_outputOwnerType & outputOwner,
                               const _input1OwnerType & input1Owner,
                               const _input2OwnerType & input2Owner) {

            typedef _outputOwnerType OutputOwnerType;
            typedef typename OutputOwnerType::pointer OutputPointerType;
            typedef typename OutputOwnerType::size_type size_type;

            typedef _input1OwnerType Input1OwnerType;
            typedef typename Input1OwnerType::const_pointer Input1PointerType;

            typedef _input2OwnerType Input2OwnerType;
            typedef typename Input2OwnerType::const_pointer Input2PointerType;

            const size_type size = outputOwner.size();

            OutputPointerType outputPointer = outputOwner.Pointer();
            const OutputPointerType outputEnd = outputPointer + size;

            Input1PointerType input1Pointer = input1Owner.Pointer();
            Input2PointerType input2Pointer = input2Owner.Pointer();

            for (;
                 outputPointer != outputEnd;
                 outputPointer++, input1Pointer++, input2Pointer++) {
                *outputPointer = _elementOperationType::Operate(*input1Pointer, *input2Pointer);
            }
        }
    };


    /*!  \brief Implement operation of the form \f$v_{io} = op(v_{io},
      v_i)\f$ for compact containers.

      This class uses a loop to perform binary vector operations
      of the form
      \f[
      v_{io} = \mathrm{op}(v_{io}, v_{i})
      \f]

      \param _elementOperationType The type of the binary operation.
    */
    template<class _elementOperationType>
    class CioCi {
    public:
        template<class _inputOutputOwnerType, class _inputOwnerType>
        static void Run(_inputOutputOwnerType & inputOutputOwner,
                        const _inputOwnerType & inputOwner) {

            typedef _inputOutputOwnerType InputOutputOwnerType;
            typedef typename InputOutputOwnerType::pointer InputOutputPointerType;
            typedef typename InputOutputOwnerType::size_type size_type;

            typedef _inputOwnerType InputOwnerType;
            typedef typename InputOwnerType::const_pointer InputPointerType;

            const size_type size = inputOutputOwner.size();

            InputOutputPointerType inputOutputPointer = inputOutputOwner.Pointer();
            const InputOutputPointerType inputOutputEnd = inputOutputPointer + size;

            InputPointerType inputPointer = inputOwner.Pointer();

            for (;
                 inputOutputPointer != inputOutputEnd;
                 inputOutputPointer++, inputPointer++) {
                *inputOutputPointer = _elementOperationType::Operate(*inputOutputPointer, *inputPointer);
            }
        }
    };


    /*!  \brief Implement operation of the form \f$(v_{1}, v_{2}) =
      op(v_{1}, v_{2})\f$ for compact containers.

      This class uses a loop to perform binary vector operations
      of the form
      \f[
      (v_{1}, v_{2}) = \mathrm{op}(v_{1}, v_{2})
      \f]

      \param _elementOperationType The type of the binary operation that inputs and
      rewrites corresponding elements in both vectors.
    */
    template<class _elementOperationType>
    class CioCio {
    public:
        template<class _inputOutput1OwnerType, class _inputOutput2OwnerType>
        static void Run(_inputOutput1OwnerType & inputOutput1Owner,
                        _inputOutput2OwnerType & inputOutput2Owner) {

            typedef _inputOutput1OwnerType InputOutput1OwnerType;
            typedef typename InputOutput1OwnerType::pointer InputOutput1PointerType;
            typedef typename InputOutput1OwnerType::size_type size_type;

            typedef _inputOutput2OwnerType InputOutput2OwnerType;
            typedef typename InputOutput2OwnerType::pointer InputOutput2PointerType;

            const size_type size = inputOutput1Owner.size();

            InputOutput1PointerType inputOutput1Pointer = inputOutput1Owner.Pointer();
            const InputOutput1PointerType inputOutput1End = inputOutput1Pointer + size;

            InputOutput2PointerType inputOutput2Pointer = inputOutput2Owner.Pointer();

            for (;
                 inputOutput1Pointer != inputOutput1End;
                 inputOutput1Pointer++, inputOutput2Pointer++) {
                _elementOperationType::Operate(*inputOutput1Pointer, *inputOutput2Pointer);
            }
        }
    };


    /*!  \brief Implement operation of the form \f$vo = op(vi, si)\f$
      for compact containers.

      This class uses a loop to perform binary vector operations
      of the form
      \f[
      v_o = \mathrm{op}(v_i, s_i)
      \f]

      \param _elementOperationType The type of the binary operation.
    */
    template<class _elementOperationType>
    class CoCiSi {
    public:
        template<class _outputOwnerType, class _inputOwnerType, class _inputScalarType>
        static inline void Run(_outputOwnerType & outputOwner,
                               const _inputOwnerType & inputOwner,
                               const _inputScalarType inputScalar) {

            typedef _outputOwnerType OutputOwnerType;
            typedef typename OutputOwnerType::pointer OutputPointerType;
            typedef typename OutputOwnerType::size_type size_type;

            typedef _inputOwnerType InputOwnerType;
            typedef typename InputOwnerType::const_pointer InputPointerType;

            const size_type size = outputOwner.size();

            OutputPointerType outputPointer = outputOwner.Pointer();
            const OutputPointerType outputEnd = outputPointer + size;

            InputPointerType inputPointer = inputOwner.Pointer();

            for (;
                 outputPointer != outputEnd;
                 outputPointer++, inputPointer++) {
                *outputPointer = _elementOperationType::Operate(*inputPointer, inputScalar);
            }
        }
    };


    /*!  \brief Implement operation of the form \f$vo = op(si, vi)\f$ for
      compact containers.

      This class uses a loop to perform binary vector operations
      of the form
      \f[
      v_o = \mathrm{op}(s_i, v_i)
      \f]

      \param _elementOperationType The type of the binary operation.
    */
    template<class _elementOperationType>
    class CoSiCi {
    public:
        template<class _outputOwnerType, class _inputScalarType, class _inputOwnerType>
        static inline void Run(_outputOwnerType & outputOwner,
                               const _inputScalarType inputScalar,
                               const _inputOwnerType & inputOwner) {

            typedef _outputOwnerType OutputOwnerType;
            typedef typename OutputOwnerType::pointer OutputPointerType;
            typedef typename OutputOwnerType::size_type size_type;

            typedef _inputOwnerType InputOwnerType;
            typedef typename InputOwnerType::const_pointer InputPointerType;

            const size_type size = outputOwner.size();

            OutputPointerType outputPointer = outputOwner.Pointer();
            const OutputPointerType outputEnd = outputPointer + size;

            InputPointerType inputPointer = inputOwner.Pointer();

            for (;
                 outputPointer != outputEnd;
                 outputPointer++, inputPointer++) {
                *outputPointer = _elementOperationType::Operate(inputScalar, *inputPointer);
            }
        }
    };


    /*!  \brief Implement operation of the form \f$ v_{io} =
      op(v_{io}, s_i)\f$ for compact containers.

      This class uses a loop to perform binary vector
      operations of the form

      \f[
      v_{io} = \mathrm{op}(v_{io}, s_{i})
      \f]

      \param _elementOperationType the type of the binary operation
    */
    template<class _elementOperationType>
    class CioSi {
    public:
        template<class _inputOutputOwnerType, class _inputScalarType>
        static void Run(_inputOutputOwnerType & inputOutputOwner,
                        const _inputScalarType inputScalar) {

            typedef _inputOutputOwnerType InputOutputOwnerType;
            typedef typename InputOutputOwnerType::pointer InputOutputPointerType;
            typedef typename InputOutputOwnerType::size_type size_type;

            const size_type size = inputOutputOwner.size();

            InputOutputPointerType inputOutputPointer = inputOutputOwner.Pointer();
            const InputOutputPointerType inputOutputEnd = inputOutputPointer + size;;

            for (;
                 inputOutputPointer != inputOutputEnd;
                 inputOutputPointer++) {
                _elementOperationType::Operate(*inputOutputPointer, inputScalar);
            }
        }
    };


    /*!  \brief Implement operation of the form \f$v_o = op(v_i)\f$ for
      compact containers.

      This class uses a loop to perform unary vector operations
      of the form
      \f[
      v_{o} = \mathrm{op}(v_{i})
      \f]

      \param _elementOperationType The type of the unary operation.
    */
    template<class _elementOperationType>
    class CoCi {
    public:
        template<class _outputOwnerType, class _inputOwnerType>
        static inline void Run(_outputOwnerType & outputOwner,
                               const _inputOwnerType & inputOwner) {

            typedef _outputOwnerType OutputOwnerType;
            typedef typename OutputOwnerType::pointer OutputPointerType;
            typedef typename OutputOwnerType::size_type size_type;

            typedef _inputOwnerType InputOwnerType;
            typedef typename InputOwnerType::const_pointer InputPointerType;

            OutputPointerType outputPointer = outputOwner.Pointer();
            const size_type size = outputOwner.size();
            const OutputPointerType outputEnd = outputPointer + size;

            InputPointerType inputPointer = inputOwner.Pointer();

            for (;
                 outputPointer != outputEnd;
                 outputPointer++, inputPointer++) {
                *outputPointer = _elementOperationType::Operate(*inputPointer);
            }
        }
    };



    /*!  \brief Implement operation of the form \f$v_{io} =
      op(v_{io})\f$ for compact containers

      This class uses a loop to perform unary store back vector
      operations of the form

      \f[
      v_{io} = \mathrm{op}(v_{io})
      \f]

      \param _elementOperationType The type of the unary operation.
    */
    template<class _elementOperationType>
    class Cio {
    public:
        template<class _inputOutputOwnerType>
        static inline void Run(_inputOutputOwnerType & inputOutputOwner) {

            typedef _inputOutputOwnerType InputOutputOwnerType;
            typedef typename InputOutputOwnerType::pointer InputOutputPointerType;
            typedef typename InputOutputOwnerType::size_type size_type;

            const size_type size = inputOutputOwner.size();

            InputOutputPointerType inputOutputPointer = inputOutputOwner.Pointer();
            const InputOutputPointerType inputOutputEnd = inputOutputPointer + size;

            for (;
                 inputOutputPointer != inputOutputEnd;
                 inputOutputPointer++) {
                _elementOperationType::Operate(*inputOutputPointer);
            }
        }
    };



    /*!  \brief Implement operation of the form \f$s_o =
      op_{incr}(op(v_i))\f$ for compact containers

      This class uses a loop to perform incremental
      unary vector operations of the form

      \f[
      s_o = \mathrm{op_{incr}(\mathrm{op}(v_i))}
      \f]

      \param _elementOperationType The type of the unary operation.
    */
    template<class _incrementalOperationType, class _elementOperationType>
    class SoCi {
    public:
        typedef typename _incrementalOperationType::OutputType OutputType;

        template<class _inputOwnerType>
        static OutputType Run(const _inputOwnerType & inputOwner) {

            typedef _inputOwnerType InputOwnerType;
            typedef typename InputOwnerType::const_pointer InputPointerType;
            typedef typename InputOwnerType::size_type size_type;

            const size_type size = inputOwner.size();
            OutputType incrementalResult = _incrementalOperationType::NeutralElement();

            InputPointerType inputPointer = inputOwner.Pointer();
            const InputPointerType inputEnd = inputPointer + size;

            for (;
                 inputPointer != inputEnd;
                 inputPointer++) {
                incrementalResult = _incrementalOperationType::Operate(incrementalResult,
                                                                       _elementOperationType::Operate(*inputPointer));
            }
            return incrementalResult;
        }
    };


    /*!  \brief Implement operation of the form \f$s_o =
      op_{incr}(op(v_{i1}, v_{i2}))\f$ for compact containers.

      This class uses a loop to perform incremental binary vector
      operations of the form

      \f[
      s_o = \mathrm{op_{incr}(\mathrm{op}(v_{i1}, v_{i2}))}
      \f]

      \param _incrementalOperationType The type of the incremental
      operation.

      \param _elementOperationType The type of the unary operation.
    */
    template<class _incrementalOperationType, class _elementOperationType>
    class SoCiCi {
    public:
        typedef typename _incrementalOperationType::OutputType OutputType;

        template<class _input1OwnerType, class _input2OwnerType>
        static inline OutputType Run(const _input1OwnerType & input1Owner,
                                     const _input2OwnerType & input2Owner) {

            typedef _input1OwnerType Input1OwnerType;
            typedef typename Input1OwnerType::const_pointer Input1PointerType;
            typedef typename Input1OwnerType::size_type size_type;

            typedef _input2OwnerType Input2OwnerType;
            typedef typename Input2OwnerType::const_pointer Input2PointerType;

            const size_type size = input1Owner.size();

            OutputType incrementalResult = _incrementalOperationType::NeutralElement();

            Input1PointerType input1Pointer = input1Owner.Pointer();
            const Input1PointerType input1End = input1Pointer + size;

            Input2PointerType input2Pointer = input2Owner.Pointer();

            for (;
                 input1Pointer != input1End;
                 input1Pointer++, input2Pointer++) {
                incrementalResult = _incrementalOperationType::Operate(incrementalResult,
                                                                       _elementOperationType::Operate(*input1Pointer,
                                                                                                      *input2Pointer));
            }
            return incrementalResult;
        }
    };


    /*!  \brief Implement operation of the form \f$v_{io} =
      op_{io}(v_{io}, op_{sv}(s, v_i))\f$ for compact containers.

      This class uses template specialization to perform store-back
      vector-scalar-vector operations

      \f[
      v_{io} = \mathrm{op_{io}}(V_{io}, \mathrm{op_{sv}}(s, v_i))
      \f]

      \param _ioOperationType The type of the store-back operation.

      \param _scalarOwnerElementOperationType The type of the
	  operation between scalar and input vector.
    */
	template<class _ioElementOperationType, class _scalarElementOperationType>
	class CioSiCi {
	public:
        template<class _ioOwnerType, class _inputScalarType, class _inputOwnerType>
        static inline void Run(_ioOwnerType & ioOwner,
                               const _inputScalarType inputScalar, const _inputOwnerType & inputOwner)
		{
			typedef _ioOwnerType IoOwnerType;
			typedef typename IoOwnerType::pointer IoPointerType;
			typedef typename IoOwnerType::size_type size_type;

            typedef _inputOwnerType InputOwnerType;
            typedef typename InputOwnerType::const_pointer InputPointerType;

            const size_type size = ioOwner.size();

            IoPointerType ioPointer = ioOwner.Pointer();
            const IoPointerType ioEnd = ioPointer + size;

            InputPointerType inputPointer = inputOwner.Pointer();

            for (;
                 ioPointer != ioEnd;
                 ioPointer++, inputPointer++)
			{
				_ioElementOperationType::Operate(*ioPointer,
                                                 _scalarElementOperationType::Operate(inputScalar, *inputPointer));
            }
		}

	};



    /*!  \brief Implement operation of the form \f$v_{io} =
      op_{io}(v_{io}, op_{vv}(v_{i1}, v_{i2}))\f$ for compact containers.

      This class uses template specialization to perform store-back
      vector-vector-vector operations

      \f[
      v_{io} = \mathrm{op_{io}}(V_{io}, \mathrm{op_{vv}}(v_{i1}, v_{i2}))
      \f]

      \param _ioOperationType The type of the store-back operation.

      \param _ownerElementOperationType The type of the
	  element wise operation between input vectors.
    */
	template<class _ioElementOperationType, class _ownerElementOperationType>
	class CioCiCi {
	public:
        template<class _ioOwnerType, class _input1OwnerType, class _input2OwnerType>
        static inline void Run(_ioOwnerType & ioOwner,
                               const _input1OwnerType & input1Owner, const _input2OwnerType & input2Owner)
		{
			typedef _ioOwnerType IoOwnerType;
			typedef typename IoOwnerType::pointer IoPointerType;
			typedef typename IoOwnerType::size_type size_type;

            typedef _input1OwnerType Input1OwnerType;
            typedef typename Input1OwnerType::const_pointer Input1PointerType;

            typedef _input2OwnerType Input2OwnerType;
            typedef typename Input2OwnerType::const_pointer Input2PointerType;

            const size_type size = ioOwner.size();

            IoPointerType ioPointer = ioOwner.Pointer();
            const IoPointerType ioEnd = ioPointer + size;

            Input1PointerType input1Pointer = input1Owner.Pointer();
            Input2PointerType input2Pointer = input2Owner.Pointer();

            for (;
                 ioPointer != ioEnd;
                 ioPointer++, input1Pointer++, input2Pointer++)
			{
				_ioElementOperationType::Operate(*ioPointer,
                                                 _ownerElementOperationType::Operate(*input1Pointer, *input2Pointer));
            }
		}

	};


    /*!  \brief Implement operation of the form \f$s_o =
      op_{incr}(op(v_i, s_i))\f$ for compact containers.

      This class uses a loop to perform incremental
      binary vector operations of the form

      \f[
      s_o = \mathrm{op_{incr}(\mathrm{op}(v_i, s_i))}
      \f]

      \param _incrementalOperationType The type of the incremental
      operation.

      \param _elementOperationType The type of the unary operation.
    */
    template<class _incrementalOperationType, class _elementOperationType>
    class SoCiSi {
    public:
        typedef typename _incrementalOperationType::OutputType OutputType;

        template<class _inputOwnerType, class _inputScalarType>
        static inline OutputType Run(const _inputOwnerType & inputOwner,
                                     const _inputScalarType & inputScalar) {

            typedef _inputOwnerType InputOwnerType;
            typedef typename InputOwnerType::const_pointer InputPointerType;
            typedef typename InputOwnerType::size_type size_type;

            const size_type size = inputOwner.size();
            OutputType incrementalResult = _incrementalOperationType::NeutralElement();

            InputPointerType inputPointer = inputOwner.Pointer();
            const InputPointerType inputEnd = inputPointer + size;

            for (;
                 inputPointer != inputEnd;
                 inputPointer++) {
                incrementalResult = _incrementalOperationType::Operate(incrementalResult,
                                                                       _elementOperationType::Operate(*inputPointer, inputScalar));
            }
            return incrementalResult;
        }
    };


    class MinAndMax {
    public:
        template<class _inputOwnerType>
        static void Run(const _inputOwnerType & inputOwner, typename _inputOwnerType::value_type & minValue,
                        typename _inputOwnerType::value_type & maxValue)
        {
            typedef _inputOwnerType InputOwnerType;
            typedef typename InputOwnerType::const_pointer InputPointerType;
            typedef typename InputOwnerType::size_type size_type;
            typedef typename InputOwnerType::value_type value_type;

            InputPointerType inputPointer = inputOwner.Pointer();

            const size_type size = inputOwner.size();
            const InputPointerType inputEnd = inputPointer + size;

            value_type minElement, maxElement;
            maxElement = minElement = *inputPointer;

            for (;
                 inputPointer != inputEnd;
                 inputPointer++) {
                const value_type element = *inputPointer;
                if (element < minElement) {
                    minElement = element;
                } else if (maxElement < element) {
                    maxElement = element;
                }
            }
            minValue = minElement;
            maxValue = maxElement;
        }
    };

};


#endif  // _vctDynamicCompactLoopEngines_h