cisst-saw
Loading...
Searching...
No Matches
mtsMatrix.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 Author(s): Anton Deguet
6 Created on: 2009-04-29
7
8 (C) Copyright 2009-2023 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19
20#ifndef _mtsMatrix_h
21#define _mtsMatrix_h
22
27
28// Always include last
30
31template <class _elementType>
33 public vctDynamicMatrix<_elementType> {
34 // declare services, requires dynamic creation
35 CMN_DECLARE_SERVICES_EXPORT(CMN_DYNAMIC_CREATION, CMN_LOG_ALLOW_DEFAULT);
36public:
37 /* defines useful types */
39 enum {DIMENSION = 2};
41
44
47
49 inline mtsMatrix(void):
51 MatrixType(0, 0)
52 {}
53
55 inline mtsMatrix(size_type rows, size_type cols):
58 {
59 MatrixType::Zeros();
60 }
61
62 inline mtsMatrix(const nsize_type & size):
65 {
66 MatrixType::Zeros();
67 }
68
72 inline ThisType & operator = (const MatrixType & data) {
73 MatrixType::SetSize(data.rows(), data.cols(), data.StorageOrder());
74 MatrixType::Assign(data);
75 return *this;
76 }
77
79 inline mtsMatrix(const ThisType & otherMatrix):
80 mtsGenericObject(otherMatrix),
81 MatrixType(otherMatrix)
82 {}
83
85 inline mtsMatrix(const MatrixType & otherMatrix):
87 MatrixType(otherMatrix)
88 {}
89
92 inline ~mtsMatrix() {}
93
95 virtual std::string ToString(void) const {
96 std::stringstream outputStream;
97 this->ToStream(outputStream);
98 return outputStream.str();
99 }
100
102 void ToStream(std::ostream & outputStream) const override {
103 mtsGenericObject::ToStream(outputStream);
104 outputStream << std::endl;
105 MatrixType::ToStream(outputStream);
106 }
107
109 void ToStreamRaw(std::ostream & outputStream, const char delimiter = ' ',
110 bool headerOnly = false, const std::string & headerPrefix = "") const override {
111 mtsGenericObject::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
112 outputStream << delimiter;
113 MatrixType::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
114 }
115
117 void SerializeRaw(std::ostream & outputStream) const override
118 {
119 mtsGenericObject::SerializeRaw(outputStream);
120 MatrixType::SerializeRaw(outputStream);
121 }
122
124 void DeSerializeRaw(std::istream & inputStream) override
125 {
127 MatrixType::DeSerializeRaw(inputStream);
128 }
129
130};
131
132
133// define some basic vectors
136
139
142
145
148
151
154
157
160
163
166
167#endif // _mtsMatrix_h
virtual void SerializeRaw(std::ostream &outputStream) const
virtual void ToStream(std::ostream &outputStream) const
mtsGenericObject(void)
Definition mtsGenericObject.h:77
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter=' ', bool headerOnly=false, const std::string &headerPrefix="") const
virtual void DeSerializeRaw(std::istream &inputStream)
Definition mtsMatrix.h:33
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
VCT_NARRAY_TRAITS_TYPEDEFS(DIMENSION)
mtsMatrix(size_type rows, size_type cols)
Definition mtsMatrix.h:55
void ToStream(std::ostream &outputStream) const override
Definition mtsMatrix.h:102
mtsMatrix(const nsize_type &size)
Definition mtsMatrix.h:62
void DeSerializeRaw(std::istream &inputStream) override
Definition mtsMatrix.h:124
virtual std::string ToString(void) const
Definition mtsMatrix.h:95
void SerializeRaw(std::ostream &outputStream) const override
Definition mtsMatrix.h:117
ThisType & operator=(const MatrixType &data)
Definition mtsMatrix.h:72
@ DIMENSION
Definition mtsMatrix.h:39
mtsMatrix(const MatrixType &otherMatrix)
Definition mtsMatrix.h:85
mtsMatrix< value_type > ThisType
Definition mtsMatrix.h:43
mtsMatrix(void)
Definition mtsMatrix.h:49
~mtsMatrix()
Definition mtsMatrix.h:92
vctDynamicMatrix< value_type > MatrixType
Definition mtsMatrix.h:46
mtsMatrix(const ThisType &otherMatrix)
Definition mtsMatrix.h:79
void ToStreamRaw(std::ostream &outputStream, const char delimiter=' ', bool headerOnly=false, const std::string &headerPrefix="") const override
Definition mtsMatrix.h:109
Definition vctForwardDeclarations.h:157
Class register definitions and log macros.
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199
const int CMN_DYNAMIC_CREATION
Definition cmnClassRegisterMacros.h:328
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76
Rules of exporting.
Forward declarations and #define for cisstMultiTask.
mtsMatrix< float > mtsFloatMat
Definition mtsMatrix.h:137
mtsMatrix< short > mtsShortMat
Definition mtsMatrix.h:152
mtsMatrix< unsigned long > mtsULongMat
Definition mtsMatrix.h:143
mtsMatrix< long > mtsLongMat
Definition mtsMatrix.h:140
mtsMatrix< bool > mtsBoolMat
Definition mtsMatrix.h:164
mtsMatrix< char > mtsCharMat
Definition mtsMatrix.h:158
mtsMatrix< unsigned short > mtsUShortMat
Definition mtsMatrix.h:155
mtsMatrix< unsigned int > mtsUIntMat
Definition mtsMatrix.h:149
mtsMatrix< double > mtsDoubleMat
Definition mtsMatrix.h:134
mtsMatrix< int > mtsIntMat
Definition mtsMatrix.h:146
mtsMatrix< unsigned char > mtsUCharMat
Definition mtsMatrix.h:161
size_type cols() const
Definition vctDynamicConstMatrixBase.h:243
size_type size(void) const
Definition vctDynamicConstMatrixBase.h:228
size_type rows() const
Definition vctDynamicConstMatrixBase.h:238
Declaration of vctDynamicMatrix.