Simbody 3.7
VectorBase.h
Go to the documentation of this file.
1#ifndef SimTK_SIMMATRIX_VECTORBASE_H_
2#define SimTK_SIMMATRIX_VECTORBASE_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
31namespace SimTK {
32
33//==============================================================================
34// VECTOR BASE
35//==============================================================================
42template <class ELT> class VectorBase : public MatrixBase<ELT> {
43 typedef MatrixBase<ELT> Base;
44 typedef typename Base::ScalarNormSq ScalarNormSq;
45 typedef typename Base::EAbs EAbs;
46 typedef typename CNT<ELT>::Scalar Scalar;
47 typedef typename CNT<ELT>::Number Number;
48 typedef typename CNT<ELT>::StdNumber StdNumber;
49 typedef VectorBase<ELT> T;
53public:
54 // ------------------------------------------------------------------------
64
67 explicit VectorBase(int m=0) : Base(MatrixCommitment::Vector(), m, 1) {}
68
72 VectorBase(const VectorBase& source) : Base(source) {}
73
75 VectorBase(const TNeg& source) : Base(source) {}
76
79 VectorBase(int m, const ELT& initialValue)
80 : Base(MatrixCommitment::Vector(),m,1,initialValue) {}
81
86 VectorBase(int m, const ELT* cppInitialValues)
87 : Base(MatrixCommitment::Vector(),m,1,cppInitialValues) {}
89
90 // ------------------------------------------------------------------------
99
101 VectorBase(int m, int stride, const Scalar* s)
102 : Base(MatrixCommitment::Vector(m), MatrixCharacter::Vector(m),stride,s) { }
104 VectorBase(int m, int stride, Scalar* s)
105 : Base(MatrixCommitment::Vector(m), MatrixCharacter::Vector(m),stride,s) { }
107
108 // ------------------------------------------------------------------------
115
118 : Base(MatrixCommitment::Vector(), h,s) { }
121 : Base(MatrixCommitment::Vector(), h,s) { }
124 : Base(MatrixCommitment::Vector(), h,d) { }
126
127 // This gives the resulting vector type when (v[i] op P) is applied to each element.
128 // It will have element types which are the regular composite result of ELT op P.
129 template <class P> struct EltResult {
134 };
135
139 Base::operator=(b); return *this;
140 }
141
142 // default destructor
143
144
145 VectorBase& operator*=(const StdNumber& t) { Base::operator*=(t); return *this; }
146 VectorBase& operator/=(const StdNumber& t) { Base::operator/=(t); return *this; }
147 VectorBase& operator+=(const VectorBase& r) { Base::operator+=(r); return *this; }
148 VectorBase& operator-=(const VectorBase& r) { Base::operator-=(r); return *this; }
149
150
151 template <class EE> VectorBase& operator=(const VectorBase<EE>& b)
152 { Base::operator=(b); return *this; }
153 template <class EE> VectorBase& operator+=(const VectorBase<EE>& b)
154 { Base::operator+=(b); return *this; }
155 template <class EE> VectorBase& operator-=(const VectorBase<EE>& b)
156 { Base::operator-=(b); return *this; }
157
158
162 VectorBase& operator=(const ELT& t) { Base::setTo(t); return *this; }
163
168 template <class EE> VectorBase& rowScaleInPlace(const VectorBase<EE>& v)
169 { Base::template rowScaleInPlace<EE>(v); return *this; }
170 template <class EE> inline void rowScale(const VectorBase<EE>& v, typename EltResult<EE>::Mul& out) const
171 { Base::rowScale(v,out); }
172 template <class EE> inline typename EltResult<EE>::Mul rowScale(const VectorBase<EE>& v) const
173 { typename EltResult<EE>::Mul out(nrow()); Base::rowScale(v,out); return out; }
174
180 normRMS(int* worstOne=0) const {
183 "Vector::normRMS() only defined for scalar elements.");
184 const int n = nrow();
185 if (n == 0) {
186 if (worstOne) *worstOne = -1;
187 return typename CNT<ScalarNormSq>::TSqrt(0);
188 }
189
190 ScalarNormSq sumsq = 0;
191 if (worstOne) {
192 *worstOne = 0;
193 ScalarNormSq maxsq = 0;
194 for (int i=0; i<n; ++i) {
195 const ScalarNormSq v2 = square((*this)[i]);
196 if (v2 > maxsq) maxsq=v2, *worstOne=i;
197 sumsq += v2;
198 }
199 } else { // don't track the worst element
200 for (int i=0; i<n; ++i) {
201 const ScalarNormSq v2 = square((*this)[i]);
202 sumsq += v2;
203 }
204 }
205
206 return CNT<ScalarNormSq>::sqrt(sumsq/n);
207 }
208
214 template <class EE>
216 weightedNormRMS(const VectorBase<EE>& w, int* worstOne=0) const {
219 "Vector::weightedNormRMS() only defined for scalar elements"
220 " and weights.");
221 const int n = nrow();
222 assert(w.nrow()==n);
223 if (n == 0) {
224 if (worstOne) *worstOne = -1;
225 return typename CNT<ScalarNormSq>::TSqrt(0);
226 }
227
228 ScalarNormSq sumsq = 0;
229 if (worstOne) {
230 *worstOne = 0;
231 ScalarNormSq maxsq = 0;
232 for (int i=0; i<n; ++i) {
233 const ScalarNormSq wv2 = square(w[i]*(*this)[i]);
234 if (wv2 > maxsq) maxsq=wv2, *worstOne=i;
235 sumsq += wv2;
236 }
237 } else { // don't track the worst element
238 for (int i=0; i<n; ++i) {
239 const ScalarNormSq wv2 = square(w[i]*(*this)[i]);
240 sumsq += wv2;
241 }
242 }
243
244 return CNT<ScalarNormSq>::sqrt(sumsq/n);
245 }
246
251 EAbs normInf(int* worstOne=0) const {
254 "Vector::normInf() only defined for scalar elements.");
255 const int n = nrow();
256 if (n == 0) {
257 if (worstOne) *worstOne = -1;
258 return EAbs(0);
259 }
260
261 EAbs maxabs = 0;
262 if (worstOne) {
263 *worstOne = 0;
264 for (int i=0; i<n; ++i) {
265 const EAbs a = std::abs((*this)[i]);
266 if (a > maxabs) maxabs=a, *worstOne=i;
267 }
268 } else { // don't track the worst element
269 for (int i=0; i<n; ++i) {
270 const EAbs a = std::abs((*this)[i]);
271 if (a > maxabs) maxabs=a;
272 }
273 }
274
275 return maxabs;
276 }
277
283 template <class EE>
284 EAbs weightedNormInf(const VectorBase<EE>& w, int* worstOne=0) const {
287 "Vector::weightedNormInf() only defined for scalar elements"
288 " and weights.");
289 const int n = nrow();
290 assert(w.nrow()==n);
291 if (n == 0) {
292 if (worstOne) *worstOne = -1;
293 return EAbs(0);
294 }
295
296 EAbs maxabs = 0;
297 if (worstOne) {
298 *worstOne = 0;
299 for (int i=0; i<n; ++i) {
300 const EAbs wv = std::abs(w[i]*(*this)[i]);
301 if (wv > maxabs) maxabs=wv, *worstOne=i;
302 }
303 } else { // don't track the worst element
304 for (int i=0; i<n; ++i) {
305 const EAbs wv = std::abs(w[i]*(*this)[i]);
306 if (wv > maxabs) maxabs=wv;
307 }
308 }
309
310 return maxabs;
311 }
312
316 return *this;
317 }
318
320 void elementwiseInvert(VectorBase<typename CNT<ELT>::TInvert>& out) const {
322 }
323
328 return out;
329 }
330
331 // elementwise multiply
333 { Base::template elementwiseMultiplyInPlace<EE>(r); return *this; }
334 template <class EE> inline void elementwiseMultiply(const VectorBase<EE>& v, typename EltResult<EE>::Mul& out) const
335 { Base::template elementwiseMultiply<EE>(v,out); }
336 template <class EE> inline typename EltResult<EE>::Mul elementwiseMultiply(const VectorBase<EE>& v) const
337 { typename EltResult<EE>::Mul out(nrow()); Base::template elementwiseMultiply<EE>(v,out); return out; }
338
339 // elementwise multiply from left
341 { Base::template elementwiseMultiplyFromLeftInPlace<EE>(r); return *this; }
342 template <class EE> inline void
344 const VectorBase<EE>& v,
346 {
347 Base::template elementwiseMultiplyFromLeft<EE>(v,out);
348 }
349 template <class EE> inline typename VectorBase<EE>::template EltResult<ELT>::Mul
351 {
353 Base::template elementwiseMultiplyFromLeft<EE>(v,out);
354 return out;
355 }
356
357 // elementwise divide
359 { Base::template elementwiseDivideInPlace<EE>(r); return *this; }
360 template <class EE> inline void elementwiseDivide(const VectorBase<EE>& v, typename EltResult<EE>::Dvd& out) const
361 { Base::template elementwiseDivide<EE>(v,out); }
362 template <class EE> inline typename EltResult<EE>::Dvd elementwiseDivide(const VectorBase<EE>& v) const
363 { typename EltResult<EE>::Dvd out(nrow()); Base::template elementwiseDivide<EE>(v,out); return out; }
364
365 // elementwise divide from left
367 { Base::template elementwiseDivideFromLeftInPlace<EE>(r); return *this; }
368 template <class EE> inline void
370 const VectorBase<EE>& v,
372 {
373 Base::template elementwiseDivideFromLeft<EE>(v,out);
374 }
375 template <class EE> inline typename VectorBase<EE>::template EltResult<ELT>::Dvd
377 {
379 Base::template elementwiseDivideFromLeft<EE>(v,out);
380 return out;
381 }
382
383 // Implicit conversions are allowed to Vector or Matrix, but not to RowVector.
384 operator const Vector_<ELT>&() const { return *reinterpret_cast<const Vector_<ELT>*>(this); }
385 operator Vector_<ELT>&() { return *reinterpret_cast< Vector_<ELT>*>(this); }
386 operator const VectorView_<ELT>&() const { return *reinterpret_cast<const VectorView_<ELT>*>(this); }
387 operator VectorView_<ELT>&() { return *reinterpret_cast< VectorView_<ELT>*>(this); }
388
389 operator const Matrix_<ELT>&() const { return *reinterpret_cast<const Matrix_<ELT>*>(this); }
390 operator Matrix_<ELT>&() { return *reinterpret_cast< Matrix_<ELT>*>(this); }
391 operator const MatrixView_<ELT>&() const { return *reinterpret_cast<const MatrixView_<ELT>*>(this); }
392 operator MatrixView_<ELT>&() { return *reinterpret_cast< MatrixView_<ELT>*>(this); }
393
394
395 // size() for Vectors is Base::nelt() but returns int instead of ptrdiff_t.
396 int size() const {
397 assert(Base::nelt() <= (ptrdiff_t)std::numeric_limits<int>::max());
398 assert(Base::ncol()==1);
399 return (int)Base::nelt();
400 }
401 int nrow() const {assert(Base::ncol()==1); return Base::nrow();}
402 int ncol() const {assert(Base::ncol()==1); return Base::ncol();}
403 ptrdiff_t nelt() const {assert(Base::ncol()==1); return Base::nelt();}
404
405 // Override MatrixBase operators to return the right shape
406 TAbs abs() const {TAbs result; Base::abs(result); return result;}
407
408 // Override MatrixBase indexing operators
409 const ELT& operator[](int i) const {return *reinterpret_cast<const ELT*>(Base::getHelper().getElt(i));}
410 ELT& operator[](int i) {return *reinterpret_cast<ELT*> (Base::updHelper().updElt(i));}
411 const ELT& operator()(int i) const {return *reinterpret_cast<const ELT*>(Base::getHelper().getElt(i));}
412 ELT& operator()(int i) {return *reinterpret_cast<ELT*> (Base::updHelper().updElt(i));}
413
414 // Block (contiguous subvector) view creation
415 VectorView_<ELT> operator()(int i, int m) const {return Base::operator()(i,0,m,1).getAsVectorView();}
416 VectorView_<ELT> operator()(int i, int m) {return Base::operator()(i,0,m,1).updAsVectorView();}
417
418 // Indexed view creation (arbitrary subvector). Indices must be
419 // monotonically increasing.
420 VectorView_<ELT> index(const Array_<int>& indices) const {
422 Base::getHelper(), indices);
423 return VectorView_<ELT>(h);
424 }
427 Base::updHelper(), indices);
428 return VectorView_<ELT>(h);
429 }
430
431 VectorView_<ELT> operator()(const Array_<int>& indices) const {return index(indices);}
432 VectorView_<ELT> operator()(const Array_<int>& indices) {return updIndex(indices);}
433
434 // Hermitian transpose.
435 THerm transpose() const {return Base::transpose().getAsRowVectorView();}
436 THerm updTranspose() {return Base::updTranspose().updAsRowVectorView();}
437
438 THerm operator~() const {return transpose();}
440
441 const VectorBase& operator+() const {return *this; }
442
443 // Negation
444
445 const TNeg& negate() const {return *reinterpret_cast<const TNeg*>(this); }
446 TNeg& updNegate() {return *reinterpret_cast<TNeg*>(this); }
447
448 const TNeg& operator-() const {return negate();}
449 TNeg& operator-() {return updNegate();}
450
451 VectorBase& resize(int m) {Base::resize(m,1); return *this;}
452 VectorBase& resizeKeep(int m) {Base::resizeKeep(m,1); return *this;}
453
454 //TODO: this is not re-locking the number of columns at 1.
456
457 ELT sum() const {ELT s; Base::getHelper().sum(reinterpret_cast<Scalar*>(&s)); return s; } // add all the elements
459 return VectorIterator<ELT, VectorBase<ELT> >(*this, 0);
460 }
462 return VectorIterator<ELT, VectorBase<ELT> >(*this, size());
463 }
464
465protected:
466 // Create a VectorBase handle using a given helper rep.
467 explicit VectorBase(MatrixHelperRep<Scalar>* hrep) : Base(hrep) {}
468
469private:
470 // NO DATA MEMBERS ALLOWED
471};
472
473} //namespace SimTK
474
475#endif // SimTK_SIMMATRIX_VECTORBASE_H_
#define SimTK_THROW1(exc, a1)
Definition: Exception.h:316
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition: CompositeNumericalTypes.h:136
K::StdNumber StdNumber
Definition: CompositeNumericalTypes.h:163
static TSqrt sqrt(const K &t)
Definition: CompositeNumericalTypes.h:239
K::TSqrt TSqrt
Definition: CompositeNumericalTypes.h:154
K::TInvert TInvert
Definition: CompositeNumericalTypes.h:157
K::Scalar Scalar
Definition: CompositeNumericalTypes.h:160
K::Number Number
Definition: CompositeNumericalTypes.h:162
Definition: Exception.h:298
This is the common base class for Simbody's Vector_ and Matrix_ classes for handling large,...
Definition: MatrixBase.h:68
const MatrixHelper< Scalar > & getHelper() const
Definition: MatrixBase.h:864
MatrixBase & elementwiseInvertInPlace()
Set M(i,j) = M(i,j)^-1.
Definition: BigMatrix.h:361
const MatrixCommitment & getCharacterCommitment() const
Definition: MatrixBase.h:118
MatrixBase< typename CNT< E >::TInvert > elementwiseInvert() const
Definition: MatrixBase.h:452
MatrixBase & resize(int m, int n)
Change the size of this matrix.
Definition: MatrixBase.h:773
MatrixView_< EHerm > updTranspose()
Definition: BigMatrix.h:230
MatrixBase & operator/=(const StdNumber &t)
Definition: MatrixBase.h:290
int nrow() const
Return the number of rows m in the logical shape of this matrix.
Definition: MatrixBase.h:136
ENumber Number
Definition: MatrixBase.h:98
MatrixBase & operator=(const MatrixBase &b)
Definition: MatrixBase.h:200
int ncol() const
Return the number of columns n in the logical shape of this matrix.
Definition: MatrixBase.h:138
MatrixBase & operator-=(const MatrixBase &r)
Definition: MatrixBase.h:292
MatrixBase & operator+=(const MatrixBase &r)
Definition: MatrixBase.h:291
void rowScale(const VectorBase< EE > &r, typename EltResult< EE >::Mul &out) const
Return type is a new matrix which will have the same dimensions as 'this' but will have element types...
MatrixBase & setTo(const ELT &t)
Fill every element in current allocation with given element (or NaN or 0).
Definition: MatrixBase.h:582
MatrixHelper< Scalar > & updHelper()
Definition: MatrixBase.h:865
void clear()
This restores the MatrixBase to the state it would be in had it been constructed specifying only its ...
Definition: MatrixBase.h:287
EScalarNormSq ScalarNormSq
Definition: MatrixBase.h:101
VectorView_< ELT > operator()(int j) const
Definition: MatrixBase.h:594
ptrdiff_t nelt() const
Return the number of elements in the logical shape of this matrix.
Definition: MatrixBase.h:147
MatrixBase & operator*=(const StdNumber &t)
Definition: MatrixBase.h:289
TAbs abs() const
abs() with the result as a function return.
Definition: MatrixBase.h:698
EScalar Scalar
Definition: MatrixBase.h:97
EStdNumber StdNumber
Definition: MatrixBase.h:99
MatrixBase & resizeKeep(int m, int n)
Change the size of this matrix, retaining as much of the old data as will fit.
Definition: MatrixBase.h:779
MatrixView_< EHerm > transpose() const
Definition: BigMatrix.h:222
CNT< E >::TAbs EAbs
Definition: MatrixBase.h:84
A MatrixCharacter is a set containing a value for each of the matrix characteristics except element t...
Definition: MatrixCharacteristics.h:597
A MatrixCommitment provides a set of acceptable matrix characteristics.
Definition: MatrixCharacteristics.h:832
const S * getElt(int i, int j) const
S * updElt(int i, int j)
void sum(S *eltp) const
(Advanced) This class is identical to Matrix_ except that it has shallow (reference) copy and assignm...
Definition: MatrixView_.h:43
This is the matrix class intended to appear in user code for large, variable size matrices.
Definition: Matrix_.h:51
(Advanced) This class is identical to RowVector_ except that it has shallow (reference) copy and assi...
Definition: RowVectorView_.h:42
This is a dataless rehash of the MatrixBase class to specialize it for Vectors.
Definition: VectorBase.h:42
VectorIterator< ELT, VectorBase< ELT > > begin()
Definition: VectorBase.h:458
VectorView_< ELT > operator()(const Array_< int > &indices) const
Definition: VectorBase.h:431
VectorBase & operator/=(const StdNumber &t)
Definition: VectorBase.h:146
void elementwiseDivide(const VectorBase< EE > &v, typename EltResult< EE >::Dvd &out) const
Definition: VectorBase.h:360
int size() const
Definition: VectorBase.h:396
void clear()
Definition: VectorBase.h:455
EltResult< EE >::Dvd elementwiseDivide(const VectorBase< EE > &v) const
Definition: VectorBase.h:362
ELT sum() const
Definition: VectorBase.h:457
TNeg & updNegate()
Definition: VectorBase.h:446
const VectorBase & operator+() const
Definition: VectorBase.h:441
VectorBase & operator-=(const VectorBase &r)
Definition: VectorBase.h:148
void elementwiseMultiplyFromLeft(const VectorBase< EE > &v, typename VectorBase< EE >::template EltResult< ELT >::Mul &out) const
Definition: VectorBase.h:343
VectorView_< ELT > operator()(const Array_< int > &indices)
Definition: VectorBase.h:432
VectorBase & operator+=(const VectorBase &r)
Definition: VectorBase.h:147
CNT< ScalarNormSq >::TSqrt weightedNormRMS(const VectorBase< EE > &w, int *worstOne=0) const
Return the weighted root-mean-square (WRMS) norm of a Vector of scalars, with optional return of the ...
Definition: VectorBase.h:216
void elementwiseMultiply(const VectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
Definition: VectorBase.h:334
THerm operator~() const
Definition: VectorBase.h:438
EltResult< EE >::Mul elementwiseMultiply(const VectorBase< EE > &v) const
Definition: VectorBase.h:336
VectorBase & elementwiseDivideFromLeftInPlace(const VectorBase< EE > &r)
Definition: VectorBase.h:366
void elementwiseDivideFromLeft(const VectorBase< EE > &v, typename VectorBase< EE >::template EltResult< ELT >::Dvd &out) const
Definition: VectorBase.h:369
ELT & operator[](int i)
Definition: VectorBase.h:410
VectorBase(const MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::DeepCopy &d)
Construct a new owner vector initialized with the data from the source.
Definition: VectorBase.h:123
VectorBase & elementwiseMultiplyFromLeftInPlace(const VectorBase< EE > &r)
Definition: VectorBase.h:340
const ELT & operator[](int i) const
Definition: VectorBase.h:409
TAbs abs() const
Definition: VectorBase.h:406
THerm updTranspose()
Definition: VectorBase.h:436
void rowScale(const VectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
Definition: VectorBase.h:170
void elementwiseInvert(VectorBase< typename CNT< ELT >::TInvert > &out) const
Set supplied out[i] = this[i]^-1.
Definition: VectorBase.h:320
VectorBase< EE >::template EltResult< ELT >::Dvd elementwiseDivideFromLeft(const VectorBase< EE > &v) const
Definition: VectorBase.h:376
VectorBase & rowScaleInPlace(const VectorBase< EE > &v)
There's only one column here so it's a bit weird to use rowScale rather than elementwiseMultiply,...
Definition: VectorBase.h:168
VectorBase(MatrixHelperRep< Scalar > *hrep)
Definition: VectorBase.h:467
VectorBase< typename CNT< ELT >::TInvert > elementwiseInvert() const
Return out[i]=this[i]^-1 as function return.
Definition: VectorBase.h:325
VectorIterator< ELT, VectorBase< ELT > > end()
Definition: VectorBase.h:461
VectorBase< EE >::template EltResult< ELT >::Mul elementwiseMultiplyFromLeft(const VectorBase< EE > &v) const
Definition: VectorBase.h:350
EAbs normInf(int *worstOne=0) const
Return the infinity norm (max absolute value) of a Vector of scalars, with optional return of the ind...
Definition: VectorBase.h:251
ELT & operator()(int i)
Definition: VectorBase.h:412
ptrdiff_t nelt() const
Definition: VectorBase.h:403
const TNeg & negate() const
Definition: VectorBase.h:445
CNT< ScalarNormSq >::TSqrt normRMS(int *worstOne=0) const
Return the root-mean-square (RMS) norm of a Vector of scalars, with optional return of the index of t...
Definition: VectorBase.h:180
VectorBase & resizeKeep(int m)
Definition: VectorBase.h:452
VectorBase(int m, const ELT *cppInitialValues)
Construct an owner vector of length m, with the elements initialized sequentially from a C++ array of...
Definition: VectorBase.h:86
int ncol() const
Definition: VectorBase.h:402
VectorBase(const VectorBase &source)
Copy constructor is a deep copy (not appropriate for views!).
Definition: VectorBase.h:72
THerm operator~()
Definition: VectorBase.h:439
VectorBase & elementwiseDivideInPlace(const VectorBase< EE > &r)
Definition: VectorBase.h:358
const ELT & operator()(int i) const
Definition: VectorBase.h:411
EltResult< EE >::Mul rowScale(const VectorBase< EE > &v) const
Definition: VectorBase.h:172
VectorBase & elementwiseMultiplyInPlace(const VectorBase< EE > &r)
Definition: VectorBase.h:332
VectorBase(int m=0)
Default constructor makes a 0x1 matrix locked at 1 column; you can provide an initial allocation if y...
Definition: VectorBase.h:67
THerm transpose() const
Definition: VectorBase.h:435
VectorView_< ELT > index(const Array_< int > &indices) const
Definition: VectorBase.h:420
const TNeg & operator-() const
Definition: VectorBase.h:448
EAbs weightedNormInf(const VectorBase< EE > &w, int *worstOne=0) const
Return the weighted infinity norm (max absolute value) WInf of a Vector of scalars,...
Definition: VectorBase.h:284
VectorBase(int m, const ELT &initialValue)
Construct an owner vector of length m, with each element initialized to the given value.
Definition: VectorBase.h:79
VectorView_< ELT > updIndex(const Array_< int > &indices)
Definition: VectorBase.h:425
VectorBase(const MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
Construct a read-only view of the source data.
Definition: VectorBase.h:120
VectorBase & operator=(const VectorBase< EE > &b)
Definition: VectorBase.h:151
VectorView_< ELT > operator()(int i, int m) const
Definition: VectorBase.h:415
VectorBase(int m, int stride, const Scalar *s)
Construct a read-only view of existing data.
Definition: VectorBase.h:101
TNeg & operator-()
Definition: VectorBase.h:449
VectorBase & resize(int m)
Definition: VectorBase.h:451
VectorBase & operator=(const VectorBase &b)
Copy assignment is deep copy but behavior depends on type of lhs: if view, rhs must match.
Definition: VectorBase.h:138
VectorBase(int m, int stride, Scalar *s)
Construct a writable view into existing data.
Definition: VectorBase.h:104
VectorBase & operator+=(const VectorBase< EE > &b)
Definition: VectorBase.h:153
int nrow() const
Definition: VectorBase.h:401
VectorBase(MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
Construct a writable view into the source data.
Definition: VectorBase.h:117
VectorBase & operator=(const ELT &t)
Fill current allocation with copies of element.
Definition: VectorBase.h:162
VectorBase & operator*=(const StdNumber &t)
Definition: VectorBase.h:145
VectorBase(const TNeg &source)
Implicit conversion from compatible vector with negated elements.
Definition: VectorBase.h:75
VectorBase & operator-=(const VectorBase< EE > &b)
Definition: VectorBase.h:155
VectorBase & elementwiseInvertInPlace()
Set this[i] = this[i]^-1.
Definition: VectorBase.h:314
VectorView_< ELT > operator()(int i, int m)
Definition: VectorBase.h:416
This is an iterator for iterating over the elements of a Vector_ or Vec object.
Definition: VectorIterator.h:52
(Advanced) This class is identical to Vector_ except that it has shallow (reference) copy and assignm...
Definition: VectorView_.h:42
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
RowVectorBase< typename CNT< ELEM >::TAbs > abs(const RowVectorBase< ELEM > &v)
Definition: VectorMath.h:120
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
unsigned char square(unsigned char u)
Definition: Scalar.h:349
Definition: VectorBase.h:129
VectorBase< typename CNT< ELT >::template Result< P >::Mul > Mul
Definition: VectorBase.h:130
VectorBase< typename CNT< ELT >::template Result< P >::Add > Add
Definition: VectorBase.h:132
VectorBase< typename CNT< ELT >::template Result< P >::Dvd > Dvd
Definition: VectorBase.h:131
VectorBase< typename CNT< ELT >::template Result< P >::Sub > Sub
Definition: VectorBase.h:133