42 template <
class _vector1Type,
class _vector2Type>
44 const _vector2Type & vector2)
46 return (vector1.size() == vector2.size());
49 template <
class _container1Type,
class _container2Type>
51 const _container2Type & container2)
53 return (container1.sizes() == container2.sizes());
56 template <
class _vector1Type,
class _vector2Type>
58 const _vector2Type & vector2)
60 return ((vector1.stride() == 1) && (vector2.stride() == 1));
64 template <
class _matrix1Type,
class _matrix2Type>
66 const _matrix2Type & matrix2)
70 (matrix1.IsCompact() && matrix2.IsCompact()
71 && (matrix1.strides() == matrix2.strides()))
74 ((matrix1.row_stride() == 1) && matrix2.row_stride() == 1)
77 ((matrix1.col_stride() == 1) && matrix2.col_stride() == 1));
80 template <
class _nArray1Type,
class _nArray2Type>
82 const _nArray2Type & nArray2)
84 return (nArray1.IsCompact() && nArray2.IsCompact()
85 && (nArray1.strides() == nArray2.strides()));
93 template <
class _vector1Type,
class _vector2Type>
95 const _vector2Type & vector2)
99 cmnThrow(std::runtime_error(
"vctFastCopy: Vector sizes mismatch"));
103 template <
class _container1Type,
class _container2Type>
105 const _container2Type & container2)
109 cmnThrow(std::runtime_error(
"vctFastCopy: Container sizes mismatch"));
124 template <
class _vector1Type,
class _vector2Type>
126 const _vector2Type & vector2)
134 template <
class _matrix1Type,
class _matrix2Type>
136 const _matrix2Type & matrix2)
144 template <
class _nArray1Type,
class _nArray2Type>
146 const _nArray2Type & nArray2)
160 template <
class _destinationVectorType,
class _sourceVectorType>
161 inline static bool VectorCopy(_destinationVectorType & destination,
162 const _sourceVectorType & source,
163 bool performSafetyChecks)
165 typedef _sourceVectorType SourceVectorType;
166 typedef typename SourceVectorType::value_type
value_type;
168 if (performSafetyChecks) {
207 template <
class _destinationMatrixType,
class _sourceMatrixType>
208 inline static bool MatrixCopy(_destinationMatrixType & destination,
209 const _sourceMatrixType & source,
210 bool performSafetyChecks)
212 typedef _sourceMatrixType SourceMatrixType;
213 typedef typename SourceMatrixType::value_type
value_type;
215 if (performSafetyChecks) {
225 if (destination.IsCompact() && source.IsCompact()) {
229 typedef _destinationMatrixType DestinationMatrixType;
230 typedef _sourceMatrixType SourceMatrixType;
232 typedef typename DestinationMatrixType::size_type size_type;
233 typedef typename DestinationMatrixType::stride_type stride_type;
235 typedef typename DestinationMatrixType::pointer DestinationPointerType;
236 typedef typename SourceMatrixType::const_pointer SourcePointerType;
238 const size_type
rows = destination.rows();
239 const size_type
cols = destination.cols();
241 DestinationPointerType destinationPointer = destination.Pointer();
242 SourcePointerType sourcePointer = source.Pointer();
244 const stride_type destinationRowStride = destination.row_stride();
245 const stride_type sourceRowStride = source.row_stride();
246 const stride_type destinationColStride = destination.col_stride();
247 const stride_type sourceColStride = source.col_stride();
250 if ((destinationColStride == 1) && (sourceColStride == 1)) {
254 const DestinationPointerType destinationRowEnd = destinationPointer +
rows * destinationRowStride;
257 destinationPointer != destinationRowEnd;
258 destinationPointer += destinationRowStride, sourcePointer += sourceRowStride) {
259 cmnMemcpy(destinationPointer, sourcePointer, sizeOfRow);
265 const DestinationPointerType destinationColEnd = destinationPointer +
cols * destinationColStride;
268 destinationPointer != destinationColEnd;
269 destinationPointer += destinationColStride, sourcePointer += sourceColStride) {
270 cmnMemcpy(destinationPointer, sourcePointer, sizeOfCol);
283 template <
class _destinationNArrayType,
class _sourceNArrayType>
284 inline static bool NArrayCopy(_destinationNArrayType & destination,
285 const _sourceNArrayType & source,
286 bool performSafetyChecks)
288 typedef _sourceNArrayType SourceNArrayType;
289 typedef typename SourceNArrayType::value_type
value_type;
291 if (performSafetyChecks) {
Container class for fast copy related methods.
Definition vctFastCopy.h:36
static const bool SkipChecks
Definition vctFastCopy.h:118
static bool NArrayCopyCompatible(const _nArray1Type &nArray1, const _nArray2Type &nArray2)
Definition vctFastCopy.h:145
static bool MatrixCopyCompatible(const _matrix1Type &matrix1, const _matrix2Type &matrix2)
Definition vctFastCopy.h:135
static bool ContainerSizesCompatible(const _container1Type &container1, const _container2Type &container2)
Definition vctFastCopy.h:50
static bool NArrayCopy(_destinationNArrayType &destination, const _sourceNArrayType &source, bool performSafetyChecks)
Definition vctFastCopy.h:284
static bool NArrayStridesCompatible(const _nArray1Type &nArray1, const _nArray2Type &nArray2)
Definition vctFastCopy.h:81
static bool VectorCopyCompatible(const _vector1Type &vector1, const _vector2Type &vector2)
Definition vctFastCopy.h:125
static bool VectorStrideCompatible(const _vector1Type &vector1, const _vector2Type &vector2)
Definition vctFastCopy.h:57
static bool VectorCopy(_destinationVectorType &destination, const _sourceVectorType &source, bool performSafetyChecks)
Definition vctFastCopy.h:161
static bool VectorSizeCompatible(const _vector1Type &vector1, const _vector2Type &vector2)
Definition vctFastCopy.h:43
static void ThrowUnlessValidContainerSizes(const _container1Type &container1, const _container2Type &container2) CISST_THROW(std
Definition vctFastCopy.h:104
static bool MatrixCopy(_destinationMatrixType &destination, const _sourceMatrixType &source, bool performSafetyChecks)
Definition vctFastCopy.h:208
static const bool PerformChecks
Definition vctFastCopy.h:119
static void ThrowUnlessValidVectorSizes(const _vector1Type &vector1, const _vector2Type &vector2) CISST_THROW(std
Definition vctFastCopy.h:94
static bool MatrixStridesCompatible(const _matrix1Type &matrix1, const _matrix2Type &matrix2)
Definition vctFastCopy.h:65
Portability across compilers and operating systems tools.
#define CISST_THROW(exceptionParameter)
Somewhat portable compilation warning message. This works with very recent versions of gcc (4....
Definition cmnPortability.h:559
Declaration of cmnRequiresDeepCopy.
bool cmnRequiresDeepCopy(void)
Definition cmnRequiresDeepCopy.h:39
void cmnMemcpy(_elementType *destination, const _elementType *source, const size_t size)
Definition cmnRequiresDeepCopy.h:62
Declaration of the template function cmnThrow.
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition cmnThrow.h:76
size_type cols() const
Definition vctDynamicConstMatrixBase.h:243
size_type rows() const
Definition vctDynamicConstMatrixBase.h:238