Simbody
3.4
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
Vector_.h
Go to the documentation of this file.
1
#ifndef SimTK_SIMMATRIX_VECTOR_H_
2
#define SimTK_SIMMATRIX_VECTOR_H_
3
4
/* -------------------------------------------------------------------------- *
5
* Simbody(tm): SimTKcommon *
6
* -------------------------------------------------------------------------- *
7
* This is part of the SimTK biosimulation toolkit originating from *
8
* Simbios, the NIH National Center for Physics-Based Simulation of *
9
* Biological Structures at Stanford, funded under the NIH Roadmap for *
10
* Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11
* *
12
* Portions copyright (c) 2005-13 Stanford University and the Authors. *
13
* Authors: Michael Sherman *
14
* Contributors: *
15
* *
16
* Licensed under the Apache License, Version 2.0 (the "License"); you may *
17
* not use this file except in compliance with the License. You may obtain a *
18
* copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19
* *
20
* Unless required by applicable law or agreed to in writing, software *
21
* distributed under the License is distributed on an "AS IS" BASIS, *
22
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23
* See the License for the specific language governing permissions and *
24
* limitations under the License. *
25
* -------------------------------------------------------------------------- */
26
30
namespace
SimTK {
31
32
//==============================================================================
33
// VECTOR
34
//==============================================================================
50
template
<
class
ELT>
class
Vector_
:
public
VectorBase
<ELT> {
51
typedef
typename
CNT<ELT>::Scalar
S;
52
typedef
typename
CNT<ELT>::Number
Number
;
53
typedef
typename
CNT<ELT>::StdNumber
StdNumber
;
54
typedef
typename
CNT<ELT>::TNeg
ENeg
;
55
typedef
VectorBase<ELT>
Base
;
56
typedef
VectorBase<ENeg>
BaseNeg
;
57
public
:
58
// Uses default destructor.
59
67
Vector_
() :
Base
() {}
68
71
Vector_
(
const
Vector_
& src) :
Base
(src) {}
72
77
Vector_
(
const
Base
& src) :
Base
(src) {}
// e.g., VectorView
81
Vector_
(
const
BaseNeg
& src) :
Base
(src) {}
82
87
explicit
Vector_
(
int
m) :
Base
(m) { }
92
Vector_
(
int
m,
const
ELT* cppInitialValues) :
Base
(m, cppInitialValues) {}
95
Vector_
(
int
m,
const
ELT& initialValue) :
Base
(m, initialValue) {}
96
99
template
<
int
M>
100
explicit
Vector_
(
const
Vec<M,ELT>
& v) :
Base
(M) {
101
for
(
int
i = 0; i < M; ++i)
102
this->
updElt
(i, 0) = v(i);
103
}
117
Vector_
(
int
m,
const
S* cppData,
bool
)
118
:
Base
(m,
Base
::
CppNScalarsPerElement
, cppData) {}
123
Vector_
(
int
m, S* cppData,
bool
)
124
:
Base
(m,
Base
::
CppNScalarsPerElement
, cppData) {}
125
129
Vector_
(
int
m,
int
stride,
const
S* data,
bool
)
130
:
Base
(m, stride, data) {}
134
Vector_
(
int
m,
int
stride, S* data,
bool
)
135
:
Base
(m, stride, data) {}
142
Vector_
&
operator=
(
const
Vector_
& src)
143
{
Base::operator=
(src);
return
*
this
; }
144
148
template
<
class
EE>
Vector_
&
operator=
(
const
VectorBase<EE>
& src)
149
{
Base::operator=
(src);
return
*
this
; }
150
152
Vector_
&
operator=
(
const
ELT& v) {
Base::operator=
(v);
return
*
this
; }
153
157
template
<
class
EE>
Vector_
&
operator+=
(
const
VectorBase<EE>
& m)
158
{
Base::operator+=
(m);
return
*
this
; }
163
template
<
class
EE>
Vector_
&
operator-=
(
const
VectorBase<EE>
& m)
164
{
Base::operator-=
(m);
return
*
this
; }
165
168
Vector_
&
operator*=
(
const
StdNumber
& t) {
Base::operator*=
(t);
return
*
this
; }
171
Vector_
&
operator/=
(
const
StdNumber
& t) {
Base::operator/=
(t);
return
*
this
; }
172
176
Vector_
&
operator+=
(
const
ELT& b)
177
{ this->
elementwiseAddScalarInPlace
(b);
return
*
this
; }
181
Vector_
&
operator-=
(
const
ELT& b)
182
{ this->
elementwiseSubtractScalarInPlace
(b);
return
*
this
; }
191
std::string
toString
()
const
{
192
std::stringstream stream;
193
stream << (*this) ;
194
return
stream.str();
195
}
197
const
ELT&
get
(
int
i)
const
{
return
(*
this
)[i]; }
199
void
set
(
int
i,
const
ELT& value) { (*this)[i]=value; }
202
private
:
203
// NO DATA MEMBERS ALLOWED
204
};
205
206
}
//namespace SimTK
207
208
#endif // SimTK_SIMMATRIX_VECTOR_H_
SimTKcommon
BigMatrix
include
SimTKcommon
internal
Vector_.h
Generated on Tue Dec 2 2014 13:13:38 for Simbody by
1.8.1.2