cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vctFixedSizeConstMatrixRef.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): Ofri Sadowsky
7  Created on: 2003-11-04
8 
9  (C) Copyright 2003-2007 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 */
20 
21 #pragma once
22 #ifndef _vctFixedSizeConstMatrixRef_h
23 #define _vctFixedSizeConstMatrixRef_h
24 
31 
48 template <class _elementType, vct::size_type _rows, vct::size_type _cols,
49  vct::stride_type _rowStride, vct::stride_type _colStride>
51  <_rows, _cols,_rowStride, _colStride, _elementType,
52  typename vctFixedSizeMatrixTraits<_elementType, _rows, _cols, _rowStride, _colStride>::pointer>
53 {
54  public:
55  /* define most types from vctContainerTraits */
56  VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType);
57 
58  typedef vctFixedSizeMatrixTraits<_elementType, _rows, _cols,
59  _rowStride, _colStride> MatrixTraits;
60 
61  typedef typename MatrixTraits::iterator iterator;
65 
66  typedef vctFixedSizeConstMatrixRef<value_type, _rows, _cols,
67  _rowStride, _colStride> ThisType;
68  typedef vctFixedSizeConstMatrixBase<_rows, _cols, _rowStride, _colStride, value_type,
69  typename MatrixTraits::pointer> BaseType;
70 
73  {}
74 
76  inline vctFixedSizeConstMatrixRef(pointer p) {
77  SetRef(p);
78  }
79 
83  template <size_type __rows, size_type __cols, class __dataPtrType>
85  {
86  SetRef(matrix, 0, 0);
87  }
88 
91  template <size_type __rows, size_type __cols, class __dataPtrType>
93  size_type startRow, size_type startCol)
94  {
95  SetRef(matrix, startRow, startCol);
96  }
97 
100  template <class __matrixOwnerType>
102  size_type startRow, size_type startCol)
103  {
104  SetRef(matrix, startRow, startCol);
105  }
106 
109  inline vctFixedSizeConstMatrixRef(const_pointer p) {
110  SetRef(p);
111  }
112 
114  inline void SetRef(pointer p) {
115  this->Data = p;
116  }
117 
119  inline void SetRef(const_pointer p) {
120  this->Data = const_cast<pointer>(p);
121  }
122 
132  template <size_type __rows, size_type __cols, class __dataPtrType>
134  size_type startRow, size_type startCol)
135  {
136  if ((startRow + this->rows() > matrix.rows()) || (startCol + this->cols() > matrix.cols())) {
137  cmnThrow(std::out_of_range("vctFixedSizeConstMatrixRef SetRef out of range"));
138  }
139  SetRef(matrix.Pointer(startRow, startCol));
140  }
141 
151  template <class __matrixOwnerType>
153  size_type startRow, size_type startCol)
154  {
155  if ((this->row_stride() != matrix.row_stride()) || (this->col_stride() == matrix.col_stride())) {
156  cmnThrow(std::runtime_error("vctFixedSizeconstMatrixRef SetRef with incompatible stride(s)"));
157  }
158  if ((startRow + this->rows() > matrix.rows()) || (startCol + this->cols() > matrix.cols())) {
159  cmnThrow(std::out_of_range("vctFixedSizeConstMatrixRef SetRef out of range"));
160  }
161  SetRef(matrix.Pointer(startRow, startCol));
162  }
163 
164 };
165 
166 
167 template <vct::size_type _rows, vct::size_type _cols,
168  vct::stride_type _rowStride, vct::stride_type _colStride,
169  class _elementType, class _dataPtrType>
171 vctFixedSizeConstMatrixBase<_rows, _cols, _rowStride, _colStride,
172  _elementType, _dataPtrType>::TransposeRef() const {
173  return ConstRefTransposeType(Data);
174 }
175 
176 
177 template <vct::size_type _rows, vct::size_type _cols,
178  vct::stride_type _rowStride, vct::stride_type _colStride,
179  class _elementType, class _dataPtrType>
181 inline vctFixedSizeMatrixBase<_rows, _cols, _rowStride, _colStride,
182  _elementType, _dataPtrType>::TransposeRef(void) {
183  return RefTransposeType(this->Data);
184 }
185 
186 
187 #endif // _vctFixedSizeConstMatrixRef_h
188 
A template for a fixed size matrix with fixed spacing in memory.
Definition: vctFixedSizeConstMatrixBase.h:103
vctFixedSizeConstMatrixRef(const vctFixedSizeConstMatrixBase< __rows, __cols, _rowStride, _colStride, _elementType, __dataPtrType > &matrix)
Definition: vctFixedSizeConstMatrixRef.h:84
void SetRef(pointer p)
Definition: vctFixedSizeConstMatrixRef.h:114
Declaration of vctFixedSizeMatrixBase.
size_t size_type
Definition: vctContainerTraits.h:35
vctFixedSizeConstMatrixRef(const_pointer p)
Definition: vctFixedSizeConstMatrixRef.h:109
vctFixedSizeConstMatrixRef()
Definition: vctFixedSizeConstMatrixRef.h:72
Definition: vctFixedStrideMatrixIterator.h:361
vctFixedSizeConstMatrixBase< _rows, _cols, _rowStride, _colStride, value_type, typename MatrixTraits::pointer > BaseType
Definition: vctFixedSizeConstMatrixRef.h:69
Matrix iterator.
Definition: vctFixedStrideMatrixIterator.h:90
Definition: vctDynamicConstMatrixBase.h:77
A template for a fixed size matrix with fixed spacings in memory.
Definition: vctFixedSizeMatrixBase.h:58
size_type rows() const
Definition: vctDynamicConstMatrixBase.h:238
An implementation of the ``abstract'' vctFixedSizeMatrixBase.
Definition: vctFixedSizeMatrixRef.h:46
size_type cols() const
Definition: vctDynamicConstMatrixBase.h:243
vctFixedSizeMatrixTraits< _elementType, _rows, _cols, _rowStride, _colStride > MatrixTraits
Definition: vctFixedSizeConstMatrixRef.h:59
const_pointer Pointer(index_type rowIndex, index_type colIndex) const
Definition: vctDynamicConstMatrixBase.h:306
#define cmnThrow(a)
Definition: MinimalCmn.h:4
void SetRef(const vctFixedSizeConstMatrixBase< __rows, __cols, _rowStride, _colStride, _elementType, __dataPtrType > &matrix, size_type startRow, size_type startCol)
Definition: vctFixedSizeConstMatrixRef.h:133
MatrixTraits::const_reverse_iterator const_reverse_iterator
Definition: vctFixedSizeConstMatrixRef.h:64
MatrixTraits::iterator iterator
Definition: vctFixedSizeConstMatrixRef.h:61
ptrdiff_t stride_type
Definition: vctContainerTraits.h:37
difference_type row_stride() const
Definition: vctDynamicConstMatrixBase.h:263
An implementation of the ``abstract'' vctFixedSizeConstMatrixBase.
Definition: vctFixedSizeConstMatrixRef.h:50
difference_type col_stride() const
Definition: vctDynamicConstMatrixBase.h:268
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
void SetRef(const vctDynamicConstMatrixBase< __matrixOwnerType, _elementType > &matrix, size_type startRow, size_type startCol)
Definition: vctFixedSizeConstMatrixRef.h:152
MatrixTraits::reverse_iterator reverse_iterator
Definition: vctFixedSizeConstMatrixRef.h:63
void SetRef(const_pointer p)
Definition: vctFixedSizeConstMatrixRef.h:119
Define common container related types based on the properties of a fixed size container.
Definition: vctFixedSizeMatrixTraits.h:46
MatrixTraits::const_iterator const_iterator
Definition: vctFixedSizeConstMatrixRef.h:62
vctFixedSizeConstMatrixRef(const vctDynamicConstMatrixBase< __matrixOwnerType, _elementType > &matrix, size_type startRow, size_type startCol)
Definition: vctFixedSizeConstMatrixRef.h:101
vctFixedSizeConstMatrixRef< value_type, _rows, _cols, _rowStride, _colStride > ThisType
Definition: vctFixedSizeConstMatrixRef.h:67
vctFixedSizeConstMatrixRef(const vctFixedSizeConstMatrixBase< __rows, __cols, _rowStride, _colStride, _elementType, __dataPtrType > &matrix, size_type startRow, size_type startCol)
Definition: vctFixedSizeConstMatrixRef.h:92
vctFixedSizeConstMatrixRef(pointer p)
Definition: vctFixedSizeConstMatrixRef.h:76