cisst-saw
Loading...
Searching...
No Matches
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
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 _vctFixedSizeConstMatrixRef_h
23#define _vctFixedSizeConstMatrixRef_h
24
29
31
48template <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 */
57
58 typedef vctFixedSizeMatrixTraits<_elementType, _rows, _cols,
59 _rowStride, _colStride> MatrixTraits;
60
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
74
76 inline vctFixedSizeConstMatrixRef(pointer p) {
77 SetRef(p);
78 }
79
83 template <size_type __rows, size_type __cols, class __dataPtrType>
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
167template <vct::size_type _rows, vct::size_type _cols,
168 vct::stride_type _rowStride, vct::stride_type _colStride,
169 class _elementType, class _dataPtrType>
171vctFixedSizeConstMatrixBase<_rows, _cols, _rowStride, _colStride,
172 _elementType, _dataPtrType>::TransposeRef() const {
174}
175
176
177template <vct::size_type _rows, vct::size_type _cols,
178 vct::stride_type _rowStride, vct::stride_type _colStride,
179 class _elementType, class _dataPtrType>
181inline vctFixedSizeMatrixBase<_rows, _cols, _rowStride, _colStride,
182 _elementType, _dataPtrType>::TransposeRef(void) {
183 return RefTransposeType(this->Data);
184}
185
186
187#endif // _vctFixedSizeConstMatrixRef_h
188
Definition vctForwardDeclarations.h:145
BaseType::RefTransposeType RefTransposeType
Definition vctDynamicMatrixBase.h:69
A template for a fixed size matrix with fixed spacing in memory.
Definition vctFixedSizeConstMatrixBase.h:104
const_pointer Pointer(size_type rowIndex, size_type colIndex) const
Definition vctFixedSizeConstMatrixBase.h:329
size_type cols() const
Definition vctFixedSizeConstMatrixBase.h:282
size_type rows() const
Definition vctFixedSizeConstMatrixBase.h:277
vctFixedSizeConstMatrixRef< _elementType, _cols, _rows, _colStride, _rowStride > ConstRefTransposeType
Definition vctFixedSizeConstMatrixBase.h:187
DataType Data
Definition vctFixedSizeConstMatrixBase.h:216
Definition vctForwardDeclarations.h:106
A template for a fixed size matrix with fixed spacings in memory.
Definition vctFixedSizeMatrixBase.h:60
BaseType::RefTransposeType RefTransposeType
Definition vctFixedSizeMatrixBase.h:90
Define common container related types based on the properties of a fixed size container.
Definition vctFixedSizeMatrixTraits.h:47
vctFixedStrideMatrixConstIterator< _elementType, -_colStride, _cols, -_rowStride > const_reverse_iterator
Definition vctFixedSizeMatrixTraits.h:62
vctFixedStrideMatrixIterator< _elementType, _colStride, _cols, _rowStride > iterator
Definition vctFixedSizeMatrixTraits.h:53
vctFixedStrideMatrixConstIterator< _elementType, _colStride, _cols, _rowStride > const_iterator
Definition vctFixedSizeMatrixTraits.h:56
vctFixedStrideMatrixIterator< _elementType, -_colStride, _cols, -_rowStride > reverse_iterator
Definition vctFixedSizeMatrixTraits.h:59
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition cmnThrow.h:76
size_t size_type
Definition vctContainerTraits.h:35
ptrdiff_t stride_type
Definition vctContainerTraits.h:37
#define VCT_CONTAINER_TRAITS_TYPEDEFS(type)
Definition vctContainerTraits.h:50
OwnerType::const_iterator const_iterator
Definition vctDynamicConstMatrixBase.h:95
difference_type row_stride() const
Definition vctDynamicConstMatrixBase.h:263
OwnerType::iterator iterator
Definition vctDynamicConstMatrixBase.h:92
ConstRefTransposeType TransposeRef(void) const
Definition vctDynamicConstMatrixBase.h:980
size_type rows() const
Definition vctDynamicConstMatrixBase.h:238
OwnerType::const_reverse_iterator const_reverse_iterator
Definition vctDynamicConstMatrixBase.h:101
vctDynamicConstMatrixBase< _matrixOwnerType, _elementType > ThisType
Definition vctDynamicConstMatrixBase.h:86
OwnerType::reverse_iterator reverse_iterator
Definition vctDynamicConstMatrixBase.h:98
vctDynamicNArrayBase< vctDynamicNArrayOwner< _elementType, _dimension >, _elementType, _dimension > BaseType
Definition vctDynamicNArray.h:133
void SetRef(pointer p)
Definition vctFixedSizeConstMatrixRef.h:114
vctFixedSizeMatrixTraits< _elementType, _rows, _cols, _rowStride, _colStride > MatrixTraits
Definition vctFixedSizeConstMatrixRef.h:59
Declaration of vctFixedSizeMatrixBase.