MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
grad::RangeVector< T, N_SIZE > Class Template Reference

#include <gradient.h>

Inheritance diagram for grad::RangeVector< T, N_SIZE >:
Collaboration diagram for grad::RangeVector< T, N_SIZE >:

Public Types

typedef RangeVectorBase< T,
N_SIZE >::scalar_type 
scalar_type
 
typedef RangeVectorBase< T,
N_SIZE >::vector_type 
vector_type
 
- Public Types inherited from grad::RangeVectorBase< T, N_SIZE >
typedef T vector_type
 
typedef T scalar_type
 

Public Member Functions

 RangeVector ()
 
 RangeVector (const RangeVector &v)
 
template<typename T2 , index_type N_SIZE2>
 RangeVector (const RangeVector< T2, N_SIZE2 > &v)
 
 RangeVector (index_type iStartNew, index_type iEndNew, const scalar_type &dVal)
 
RangeVectoroperator= (const RangeVector &v)
 
template<typename T2 , index_type N_SIZE2>
RangeVectoroperator= (const RangeVector< T2, N_SIZE2 > &v)
 
void ResizeReset (index_type iStartNew, index_type iEndNew, const T &dVal)
 
void ResizePreserve (index_type iStartNew, index_type iEndNew)
 
void Reset ()
 
void Reserve (index_type iMaxSizeNew)
 
index_type iGetStartIndex () const
 
index_type iGetEndIndex () const
 
index_type iGetSize () const
 
index_type iGetStartIndexVector () const
 
index_type iGetEndIndexVector () const
 
index_type iGetSizeVector () const
 
scalar_type GetValue (index_type i) const
 
void SetValue (index_type i, const scalar_type &d)
 
vector_type GetVectorValue (index_type i) const
 
void SetVectorValue (index_type i, const vector_type &d)
 

Static Public Member Functions

static index_type iGetMaxSize ()
 
static index_type iGetMaxSizeVector ()
 
static bool bUseDynamicMem ()
 
- Static Public Member Functions inherited from grad::RangeVectorBase< T, N_SIZE >
static index_type iRoundStartIndexVector (index_type iStart)
 
static index_type iRoundEndIndexVector (index_type iEnd)
 

Static Public Attributes

static const index_type iVectorSize = RangeVectorBase<T, N_SIZE>::iVectorSize
 
static const index_type iMaxSizeVector = N_SIZE / iVectorSize + (N_SIZE % iVectorSize ? 1 : 0)
 
static const index_type iMaxSize = N_SIZE
 
- Static Public Attributes inherited from grad::RangeVectorBase< T, N_SIZE >
static const int iVectorSize = 1
 

Private Member Functions

void Initialize (index_type iStartNew, index_type iEndNew, const scalar_type &dVal)
 
template<typename T2 , index_type N_SIZE2>
void Copy (const RangeVector< T2, N_SIZE2 > &v)
 
template<typename T2 , index_type N_SIZE2>
void CopyData (const RangeVector< T2, N_SIZE2 > &v)
 
void CopyData (const RangeVector &v)
 

Private Attributes

union {
   scalar_type   rgArray [iMaxSize]
 
   vector_type   rgArrayVec [iMaxSizeVector]
 
}; 
 
index_type iStart
 
index_type iEnd
 
index_type iStartVec
 
index_type iEndVec
 

Detailed Description

template<typename T, index_type N_SIZE>
class grad::RangeVector< T, N_SIZE >

Definition at line 378 of file gradient.h.

Member Typedef Documentation

template<typename T, index_type N_SIZE>
typedef RangeVectorBase<T, N_SIZE>::scalar_type grad::RangeVector< T, N_SIZE >::scalar_type

Definition at line 381 of file gradient.h.

template<typename T, index_type N_SIZE>
typedef RangeVectorBase<T, N_SIZE>::vector_type grad::RangeVector< T, N_SIZE >::vector_type

Definition at line 382 of file gradient.h.

Constructor & Destructor Documentation

template<typename T, index_type N_SIZE>
grad::RangeVector< T, N_SIZE >::RangeVector ( )
inline

Definition at line 387 of file gradient.h.

387  {
388 #if GRADIENT_DEBUG > 0
389  Initialize(0, iMaxSize, RangeVectorTraits<scalar_type>::Invalid());
390 #endif
391  GRADIENT_ASSERT(bIsAligned());
392 
393  iStart = 0;
394  iEnd = 0;
395  iStartVec = 0;
396  iEndVec = 0;
397 
398  GRADIENT_ASSERT(bInvariant());
399  }
index_type iEnd
Definition: gradient.h:641
void Initialize(index_type iStartNew, index_type iEndNew, const scalar_type &dVal)
Definition: gradient.h:544
index_type iEndVec
Definition: gradient.h:641
index_type iStart
Definition: gradient.h:641
static const index_type iMaxSize
Definition: gradient.h:385
index_type iStartVec
Definition: gradient.h:641
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
template<typename T, index_type N_SIZE>
grad::RangeVector< T, N_SIZE >::RangeVector ( const RangeVector< T, N_SIZE > &  v)
inline

Definition at line 401 of file gradient.h.

401  {
402  GRADIENT_ASSERT(bIsAligned());
403 
404  Copy(v);
405 
406  GRADIENT_ASSERT(bInvariant());
407  }
void Copy(const RangeVector< T2, N_SIZE2 > &v)
Definition: gradient.h:559
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
template<typename T, index_type N_SIZE>
template<typename T2 , index_type N_SIZE2>
grad::RangeVector< T, N_SIZE >::RangeVector ( const RangeVector< T2, N_SIZE2 > &  v)
inline

Definition at line 410 of file gradient.h.

410  {
411  GRADIENT_ASSERT(bIsAligned());
412 
413  Copy(v);
414 
415  GRADIENT_ASSERT(bInvariant());
416  }
void Copy(const RangeVector< T2, N_SIZE2 > &v)
Definition: gradient.h:559
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
template<typename T, index_type N_SIZE>
grad::RangeVector< T, N_SIZE >::RangeVector ( index_type  iStartNew,
index_type  iEndNew,
const scalar_type dVal 
)
inlineexplicit

Definition at line 418 of file gradient.h.

418  {
419  GRADIENT_ASSERT(bIsAligned());
420 
421  Initialize(iStartNew, iEndNew, dVal);
422 
423  GRADIENT_ASSERT(bInvariant());
424  }
void Initialize(index_type iStartNew, index_type iEndNew, const scalar_type &dVal)
Definition: gradient.h:544
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Member Function Documentation

template<typename T, index_type N_SIZE>
static bool grad::RangeVector< T, N_SIZE >::bUseDynamicMem ( )
inlinestatic

Definition at line 538 of file gradient.h.

Referenced by grad::MapVector< N_SIZE >::bUseDynamicMem().

538 { return false; }
template<typename T, index_type N_SIZE>
template<typename T2 , index_type N_SIZE2>
void grad::RangeVector< T, N_SIZE >::Copy ( const RangeVector< T2, N_SIZE2 > &  v)
inlineprivate

Definition at line 559 of file gradient.h.

Referenced by grad::RangeVector< scalar_deriv_type, N_SIZE >::operator=(), grad::RangeVector< T, 0 >::operator=(), grad::RangeVector< scalar_deriv_type, N_SIZE >::RangeVector(), and grad::RangeVector< T, 0 >::RangeVector().

559  {
560  typedef typename MaxSizeCheck<iMaxSize >= RangeVector<T2, N_SIZE2>::iMaxSize>::CheckType check_iMaxSize;
561 
562  iStart = v.iGetStartIndex();
563  iEnd = v.iGetEndIndex();
566 
567  // This allows fast access without frequent index checking
568  array_fill(rgArray, rgArray + iStart, RangeVectorTraits<scalar_type>::Zero());
569  array_fill(rgArray + iEnd, rgArray + iMaxSize, RangeVectorTraits<scalar_type>::Zero());
570 
571  CopyData(v);
572  }
index_type iEnd
Definition: gradient.h:641
scalar_type rgArray[iMaxSize]
Definition: gradient.h:637
index_type iEndVec
Definition: gradient.h:641
static index_type iRoundEndIndexVector(index_type iEnd)
Definition: gradient.h:368
static index_type iRoundStartIndexVector(index_type iStart)
Definition: gradient.h:364
void CopyData(const RangeVector< T2, N_SIZE2 > &v)
Definition: gradient.h:575
index_type iStart
Definition: gradient.h:641
static const index_type iMaxSize
Definition: gradient.h:385
index_type iStartVec
Definition: gradient.h:641
void array_fill(T *first, T *const last, const T &val)
Definition: gradient.h:309
template<typename T, index_type N_SIZE>
template<typename T2 , index_type N_SIZE2>
void grad::RangeVector< T, N_SIZE >::CopyData ( const RangeVector< T2, N_SIZE2 > &  v)
inlineprivate

Definition at line 575 of file gradient.h.

Referenced by grad::RangeVector< scalar_deriv_type, N_SIZE >::Copy().

575  {
576  for (index_type i = iStart; i < iEnd; ++i) {
577  SetValue(i, v.GetValue(i));
578  }
579  }
index_type iEnd
Definition: gradient.h:641
integer index_type
Definition: gradient.h:104
index_type iStart
Definition: gradient.h:641
void SetValue(index_type i, const scalar_type &d)
Definition: gradient.h:511
template<typename T, index_type N_SIZE>
void grad::RangeVector< T, N_SIZE >::CopyData ( const RangeVector< T, N_SIZE > &  v)
inlineprivate

Definition at line 581 of file gradient.h.

581  {
582  array_copy(v.rgArrayVec + v.iStartVec, v.rgArrayVec + v.iEndVec, rgArrayVec + iStartVec);
583  }
vector_type rgArrayVec[iMaxSizeVector]
Definition: gradient.h:638
index_type iStartVec
Definition: gradient.h:641
T * array_copy(const T *first, const T *const last, T *result)
Definition: gradient.h:316
template<typename T, index_type N_SIZE>
scalar_type grad::RangeVector< T, N_SIZE >::GetValue ( index_type  i) const
inline

Definition at line 502 of file gradient.h.

Referenced by grad::RangeVector< T, 0 >::Copy(), grad::RangeVector< scalar_deriv_type, N_SIZE >::CopyData(), grad::MapVector< N_SIZE >::dGetGlobalVector(), grad::MapVector< N_SIZE >::dGetLocalVector(), and testRangeVector().

502  {
503  GRADIENT_ASSERT(i >= 0);
505  GRADIENT_ASSERT((i >= iGetStartIndex() && i < iGetEndIndex()) || rgArray[i] == RangeVectorTraits<scalar_type>::Zero());
506  GRADIENT_ASSERT(bIsAligned());
507 
508  return rgArray[i];
509  }
scalar_type rgArray[iMaxSize]
Definition: gradient.h:637
static const index_type iMaxSize
Definition: gradient.h:385
index_type iGetStartIndex() const
Definition: gradient.h:493
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
index_type iGetEndIndex() const
Definition: gradient.h:494
template<typename T, index_type N_SIZE>
vector_type grad::RangeVector< T, N_SIZE >::GetVectorValue ( index_type  i) const
inline

Definition at line 520 of file gradient.h.

Referenced by grad::MapVector< N_SIZE >::dGetLocalVectorVector(), and testRangeVector().

520  {
521  GRADIENT_ASSERT(i >= 0);
523  GRADIENT_ASSERT(bIsAligned());
524  //GRADIENT_ASSERT(i >= iStartVec && i < iEndVec || rgArrayVec[i] == RangeVectorTraits<vector_type>::Zero());
525 
526  return rgArrayVec[i];
527  }
static const index_type iMaxSizeVector
Definition: gradient.h:384
vector_type rgArrayVec[iMaxSizeVector]
Definition: gradient.h:638
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
template<typename T, index_type N_SIZE>
static index_type grad::RangeVector< T, N_SIZE >::iGetMaxSize ( )
inlinestatic
template<typename T, index_type N_SIZE>
static index_type grad::RangeVector< T, N_SIZE >::iGetMaxSizeVector ( )
inlinestatic

Definition at line 500 of file gradient.h.

Referenced by grad::MapVector< N_SIZE >::iGetMaxSizeVector().

500 { return iMaxSizeVector; }
static const index_type iMaxSizeVector
Definition: gradient.h:384
template<typename T, index_type N_SIZE>
index_type grad::RangeVector< T, N_SIZE >::iGetSize ( ) const
inline

Definition at line 495 of file gradient.h.

Referenced by grad::RangeVector< T, 0 >::end(), and grad::MapVector< N_SIZE >::iGetSize().

495 { return iEnd - iStart; }
index_type iEnd
Definition: gradient.h:641
index_type iStart
Definition: gradient.h:641
template<typename T, index_type N_SIZE>
index_type grad::RangeVector< T, N_SIZE >::iGetSizeVector ( ) const
inline
template<typename T, index_type N_SIZE>
void grad::RangeVector< T, N_SIZE >::Initialize ( index_type  iStartNew,
index_type  iEndNew,
const scalar_type dVal 
)
inlineprivate

Definition at line 544 of file gradient.h.

Referenced by grad::RangeVector< scalar_deriv_type, N_SIZE >::RangeVector(), grad::RangeVector< T, 0 >::RangeVector(), grad::RangeVector< scalar_deriv_type, N_SIZE >::ResizeReset(), and grad::RangeVector< T, 0 >::ResizeReset().

544  {
545  iStart = iStartNew;
546  iEnd = iEndNew;
547  iStartVec = iRoundStartIndexVector(iStartNew);
548  iEndVec = iRoundEndIndexVector(iEndNew);
549 
550  array_fill(rgArrayVec, rgArrayVec + iMaxSizeVector, RangeVectorTraits<vector_type>::Zero());
551 
552  if (dVal != RangeVectorTraits<scalar_type>::Zero())
553  {
554  array_fill(rgArray + iStart, rgArray + iEnd, dVal);
555  }
556  }
index_type iEnd
Definition: gradient.h:641
scalar_type rgArray[iMaxSize]
Definition: gradient.h:637
static const index_type iMaxSizeVector
Definition: gradient.h:384
index_type iEndVec
Definition: gradient.h:641
static index_type iRoundEndIndexVector(index_type iEnd)
Definition: gradient.h:368
static index_type iRoundStartIndexVector(index_type iStart)
Definition: gradient.h:364
index_type iStart
Definition: gradient.h:641
vector_type rgArrayVec[iMaxSizeVector]
Definition: gradient.h:638
index_type iStartVec
Definition: gradient.h:641
void array_fill(T *first, T *const last, const T &val)
Definition: gradient.h:309
template<typename T, index_type N_SIZE>
RangeVector& grad::RangeVector< T, N_SIZE >::operator= ( const RangeVector< T, N_SIZE > &  v)
inline

Definition at line 426 of file gradient.h.

426  {
427  GRADIENT_ASSERT(bIsAligned());
428 
429  GRADIENT_ASSERT(bInvariant());
430 
431  Copy(v);
432 
433  GRADIENT_ASSERT(bInvariant());
434 
435  return *this;
436  }
void Copy(const RangeVector< T2, N_SIZE2 > &v)
Definition: gradient.h:559
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
template<typename T, index_type N_SIZE>
template<typename T2 , index_type N_SIZE2>
RangeVector& grad::RangeVector< T, N_SIZE >::operator= ( const RangeVector< T2, N_SIZE2 > &  v)
inline

Definition at line 439 of file gradient.h.

439  {
440  GRADIENT_ASSERT(bIsAligned());
441 
442  GRADIENT_ASSERT(bInvariant());
443 
444  Copy(v);
445 
446  GRADIENT_ASSERT(bInvariant());
447 
448  return *this;
449  }
void Copy(const RangeVector< T2, N_SIZE2 > &v)
Definition: gradient.h:559
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
template<typename T, index_type N_SIZE>
void grad::RangeVector< T, N_SIZE >::Reserve ( index_type  iMaxSizeNew)
inline

Definition at line 487 of file gradient.h.

Referenced by grad::RangeVector< T, 0 >::Reserve(), grad::MapVector< N_SIZE >::Reserve(), and testRangeVector().

487  {
488  GRADIENT_ASSERT(bIsAligned());
489  GRADIENT_ASSERT(bInvariant());
490  GRADIENT_ASSERT(iMaxSizeNew <= iMaxSize);
491  }
static const index_type iMaxSize
Definition: gradient.h:385
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
template<typename T, index_type N_SIZE>
void grad::RangeVector< T, N_SIZE >::Reset ( void  )
inline

Definition at line 477 of file gradient.h.

Referenced by grad::RangeVector< T, 0 >::Initialize(), grad::MapVector< N_SIZE >::Reset(), and testRangeVector().

477  {
478  GRADIENT_ASSERT(bIsAligned());
479 
480  GRADIENT_ASSERT(bInvariant());
481  // Reset the data but preserve iStart and iEnd
482  array_fill(rgArrayVec + iStartVec, rgArrayVec + iEndVec, RangeVectorTraits<vector_type>::Zero());
483 
484  GRADIENT_ASSERT(bInvariant());
485  }
index_type iEndVec
Definition: gradient.h:641
vector_type rgArrayVec[iMaxSizeVector]
Definition: gradient.h:638
index_type iStartVec
Definition: gradient.h:641
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
void array_fill(T *first, T *const last, const T &val)
Definition: gradient.h:309
template<typename T, index_type N_SIZE>
void grad::RangeVector< T, N_SIZE >::ResizePreserve ( index_type  iStartNew,
index_type  iEndNew 
)
inline

Definition at line 461 of file gradient.h.

Referenced by grad::MapVector< N_SIZE >::ResizePreserve(), and testRangeVector().

461  {
462  GRADIENT_ASSERT(bIsAligned());
463 
464  GRADIENT_ASSERT(bInvariant());
465 
466  iStart = iStartNew;
467  iEnd = iEndNew;
468  iStartVec = iRoundStartIndexVector(iStartNew);
469  iEndVec = iRoundEndIndexVector(iEndNew);
470 
471  array_fill(rgArray, rgArray + iStart, RangeVectorTraits<scalar_type>::Zero());
472  array_fill(rgArray + iEnd, rgArray + iMaxSize, RangeVectorTraits<scalar_type>::Zero());
473 
474  GRADIENT_ASSERT(bInvariant());
475  }
index_type iEnd
Definition: gradient.h:641
scalar_type rgArray[iMaxSize]
Definition: gradient.h:637
index_type iEndVec
Definition: gradient.h:641
static index_type iRoundEndIndexVector(index_type iEnd)
Definition: gradient.h:368
static index_type iRoundStartIndexVector(index_type iStart)
Definition: gradient.h:364
index_type iStart
Definition: gradient.h:641
static const index_type iMaxSize
Definition: gradient.h:385
index_type iStartVec
Definition: gradient.h:641
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
void array_fill(T *first, T *const last, const T &val)
Definition: gradient.h:309
template<typename T, index_type N_SIZE>
void grad::RangeVector< T, N_SIZE >::ResizeReset ( index_type  iStartNew,
index_type  iEndNew,
const T &  dVal 
)
inline

Definition at line 451 of file gradient.h.

Referenced by grad::MapVector< N_SIZE >::ResizeReset(), and testRangeVector().

451  {
452  GRADIENT_ASSERT(bIsAligned());
453 
454  GRADIENT_ASSERT(bInvariant());
455 
456  Initialize(iStartNew, iEndNew, dVal);
457 
458  GRADIENT_ASSERT(bInvariant());
459  }
void Initialize(index_type iStartNew, index_type iEndNew, const scalar_type &dVal)
Definition: gradient.h:544
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
template<typename T, index_type N_SIZE>
void grad::RangeVector< T, N_SIZE >::SetValue ( index_type  i,
const scalar_type d 
)
inline

Definition at line 511 of file gradient.h.

Referenced by grad::RangeVector< T, 0 >::Copy(), grad::RangeVector< scalar_deriv_type, N_SIZE >::CopyData(), grad::MapVector< N_SIZE >::SetGlobalVector(), grad::MapVector< N_SIZE >::SetLocalVector(), and testRangeVector().

511  {
512  GRADIENT_ASSERT(i >= 0);
515  GRADIENT_ASSERT(bIsAligned());
516 
517  rgArray[i] = d;
518  }
scalar_type rgArray[iMaxSize]
Definition: gradient.h:637
static const index_type iMaxSize
Definition: gradient.h:385
index_type iGetStartIndex() const
Definition: gradient.h:493
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
index_type iGetEndIndex() const
Definition: gradient.h:494
template<typename T, index_type N_SIZE>
void grad::RangeVector< T, N_SIZE >::SetVectorValue ( index_type  i,
const vector_type d 
)
inline

Definition at line 529 of file gradient.h.

Referenced by grad::MapVector< N_SIZE >::SetLocalVectorVector(), and testRangeVector().

529  {
530  GRADIENT_ASSERT(i >= 0);
533  GRADIENT_ASSERT(bIsAligned());
534 
535  rgArrayVec[i] = d;
536  }
static const index_type iMaxSizeVector
Definition: gradient.h:384
index_type iGetStartIndexVector() const
Definition: gradient.h:497
index_type iGetEndIndexVector() const
Definition: gradient.h:498
vector_type rgArrayVec[iMaxSizeVector]
Definition: gradient.h:638
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Member Data Documentation

union { ... }
template<typename T, index_type N_SIZE>
const index_type grad::RangeVector< T, N_SIZE >::iVectorSize = RangeVectorBase<T, N_SIZE>::iVectorSize
static

The documentation for this class was generated from the following file: