Simbody 3.9
Loading...
Searching...
No Matches
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
31#include <initializer_list>
32
33namespace SimTK {
34
35//==============================================================================
36// VECTOR BASE
37//==============================================================================
44template <class ELT> class VectorBase : public MatrixBase<ELT> {
45 typedef MatrixBase<ELT> Base;
46 typedef typename Base::ScalarNormSq ScalarNormSq;
47 typedef typename Base::EAbs EAbs;
48 typedef typename CNT<ELT>::Scalar Scalar;
49 typedef typename CNT<ELT>::Number Number;
50 typedef typename CNT<ELT>::StdNumber StdNumber;
51 typedef VectorBase<ELT> T;
55public:
56 // ------------------------------------------------------------------------
66
69 explicit VectorBase(int m=0) : Base(MatrixCommitment::Vector(), m, 1) {}
70
74 VectorBase(const VectorBase& source) : Base(source) {}
75
77 VectorBase(const TNeg& source) : Base(source) {}
78
81 VectorBase(int m, const ELT& initialValue)
82 : Base(MatrixCommitment::Vector(),m,1,initialValue) {}
83
88 VectorBase(int m, const ELT* cppInitialValues)
89 : Base(MatrixCommitment::Vector(),m,1,cppInitialValues) {}
90
91 VectorBase(std::initializer_list<ELT> init)
92 : VectorBase(static_cast<int>(init.size()), init.begin()) {}
94
95 // ------------------------------------------------------------------------
104
106 VectorBase(int m, int stride, const Scalar* s)
107 : Base(MatrixCommitment::Vector(m), MatrixCharacter::Vector(m),stride,s) { }
109 VectorBase(int m, int stride, Scalar* s)
110 : Base(MatrixCommitment::Vector(m), MatrixCharacter::Vector(m),stride,s) { }
112
113 // ------------------------------------------------------------------------
120
131
132 // This gives the resulting vector type when (v[i] op P) is applied to each element.
133 // It will have element types which are the regular composite result of ELT op P.
134 template <class P> struct EltResult {
139 };
140
144 Base::operator=(b); return *this;
145 }
146
147 // default destructor
148
149
150 VectorBase& operator*=(const StdNumber& t) { Base::operator*=(t); return *this; }
151 VectorBase& operator/=(const StdNumber& t) { Base::operator/=(t); return *this; }
152 VectorBase& operator+=(const VectorBase& r) { Base::operator+=(r); return *this; }
153 VectorBase& operator-=(const VectorBase& r) { Base::operator-=(r); return *this; }
154
155
156 template <class EE> VectorBase& operator=(const VectorBase<EE>& b)
157 { Base::operator=(b); return *this; }
158 template <class EE> VectorBase& operator+=(const VectorBase<EE>& b)
159 { Base::operator+=(b); return *this; }
160 template <class EE> VectorBase& operator-=(const VectorBase<EE>& b)
161 { Base::operator-=(b); return *this; }
162
163
167 VectorBase& operator=(const ELT& t) { Base::setTo(t); return *this; }
168
173 template <class EE> VectorBase& rowScaleInPlace(const VectorBase<EE>& v)
174 { Base::template rowScaleInPlace<EE>(v); return *this; }
175 template <class EE> inline void rowScale(const VectorBase<EE>& v, typename EltResult<EE>::Mul& out) const
176 { Base::rowScale(v,out); }
177 template <class EE> SimTK_NODISCARD inline typename EltResult<EE>::Mul rowScale(const VectorBase<EE>& v) const
178 { typename EltResult<EE>::Mul out(nrow()); Base::rowScale(v,out); return out; }
179
185 normRMS(int* worstOne=0) const {
188 "Vector::normRMS() only defined for scalar elements.");
189 const int n = nrow();
190 if (n == 0) {
191 if (worstOne) *worstOne = -1;
192 return typename CNT<ScalarNormSq>::TSqrt(0);
193 }
194
195 ScalarNormSq sumsq = 0;
196 if (worstOne) {
197 *worstOne = 0;
198 ScalarNormSq maxsq = 0;
199 for (int i=0; i<n; ++i) {
200 const ScalarNormSq v2 = square((*this)[i]);
201 if (v2 > maxsq) maxsq=v2, *worstOne=i;
202 sumsq += v2;
203 }
204 } else { // don't track the worst element
205 for (int i=0; i<n; ++i) {
206 const ScalarNormSq v2 = square((*this)[i]);
207 sumsq += v2;
208 }
209 }
210
211 return CNT<ScalarNormSq>::sqrt(sumsq/n);
212 }
213
219 template <class EE>
221 weightedNormRMS(const VectorBase<EE>& w, int* worstOne=0) const {
224 "Vector::weightedNormRMS() only defined for scalar elements"
225 " and weights.");
226 const int n = nrow();
227 assert(w.nrow()==n);
228 if (n == 0) {
229 if (worstOne) *worstOne = -1;
230 return typename CNT<ScalarNormSq>::TSqrt(0);
231 }
232
233 ScalarNormSq sumsq = 0;
234 if (worstOne) {
235 *worstOne = 0;
236 ScalarNormSq maxsq = 0;
237 for (int i=0; i<n; ++i) {
238 const ScalarNormSq wv2 = square(w[i]*(*this)[i]);
239 if (wv2 > maxsq) maxsq=wv2, *worstOne=i;
240 sumsq += wv2;
241 }
242 } else { // don't track the worst element
243 for (int i=0; i<n; ++i) {
244 const ScalarNormSq wv2 = square(w[i]*(*this)[i]);
245 sumsq += wv2;
246 }
247 }
248
249 return CNT<ScalarNormSq>::sqrt(sumsq/n);
250 }
251
256 EAbs normInf(int* worstOne=0) const {
259 "Vector::normInf() only defined for scalar elements.");
260 const int n = nrow();
261 if (n == 0) {
262 if (worstOne) *worstOne = -1;
263 return EAbs(0);
264 }
265
266 EAbs maxabs = 0;
267 if (worstOne) {
268 *worstOne = 0;
269 for (int i=0; i<n; ++i) {
270 const EAbs a = std::abs((*this)[i]);
271 if (a > maxabs) maxabs=a, *worstOne=i;
272 }
273 } else { // don't track the worst element
274 for (int i=0; i<n; ++i) {
275 const EAbs a = std::abs((*this)[i]);
276 if (a > maxabs) maxabs=a;
277 }
278 }
279
280 return maxabs;
281 }
282
288 template <class EE>
289 EAbs weightedNormInf(const VectorBase<EE>& w, int* worstOne=0) const {
292 "Vector::weightedNormInf() only defined for scalar elements"
293 " and weights.");
294 const int n = nrow();
295 assert(w.nrow()==n);
296 if (n == 0) {
297 if (worstOne) *worstOne = -1;
298 return EAbs(0);
299 }
300
301 EAbs maxabs = 0;
302 if (worstOne) {
303 *worstOne = 0;
304 for (int i=0; i<n; ++i) {
305 const EAbs wv = std::abs(w[i]*(*this)[i]);
306 if (wv > maxabs) maxabs=wv, *worstOne=i;
307 }
308 } else { // don't track the worst element
309 for (int i=0; i<n; ++i) {
310 const EAbs wv = std::abs(w[i]*(*this)[i]);
311 if (wv > maxabs) maxabs=wv;
312 }
313 }
314
315 return maxabs;
316 }
317
323
325 void elementwiseInvert(VectorBase<typename CNT<ELT>::TInvert>& out) const {
327 }
328
335
336 // elementwise multiply
338 { Base::template elementwiseMultiplyInPlace<EE>(r); return *this; }
339 template <class EE> inline void elementwiseMultiply(const VectorBase<EE>& v, typename EltResult<EE>::Mul& out) const
340 { Base::template elementwiseMultiply<EE>(v,out); }
341 template <class EE> inline typename EltResult<EE>::Mul elementwiseMultiply(const VectorBase<EE>& v) const
342 { typename EltResult<EE>::Mul out(nrow()); Base::template elementwiseMultiply<EE>(v,out); return out; }
343
344 // elementwise multiply from left
346 { Base::template elementwiseMultiplyFromLeftInPlace<EE>(r); return *this; }
347 template <class EE> inline void
349 const VectorBase<EE>& v,
351 {
352 Base::template elementwiseMultiplyFromLeft<EE>(v,out);
353 }
354 template <class EE> inline typename VectorBase<EE>::template EltResult<ELT>::Mul
356 {
358 Base::template elementwiseMultiplyFromLeft<EE>(v,out);
359 return out;
360 }
361
362 // elementwise divide
364 { Base::template elementwiseDivideInPlace<EE>(r); return *this; }
365 template <class EE> inline void elementwiseDivide(const VectorBase<EE>& v, typename EltResult<EE>::Dvd& out) const
366 { Base::template elementwiseDivide<EE>(v,out); }
367 template <class EE> inline typename EltResult<EE>::Dvd elementwiseDivide(const VectorBase<EE>& v) const
368 { typename EltResult<EE>::Dvd out(nrow()); Base::template elementwiseDivide<EE>(v,out); return out; }
369
370 // elementwise divide from left
372 { Base::template elementwiseDivideFromLeftInPlace<EE>(r); return *this; }
373 template <class EE> inline void
375 const VectorBase<EE>& v,
377 {
378 Base::template elementwiseDivideFromLeft<EE>(v,out);
379 }
380 template <class EE> inline typename VectorBase<EE>::template EltResult<ELT>::Dvd
382 {
384 Base::template elementwiseDivideFromLeft<EE>(v,out);
385 return out;
386 }
387
388 // Implicit conversions are allowed to Vector or Matrix, but not to RowVector.
389 operator const Vector_<ELT>&() const { return *reinterpret_cast<const Vector_<ELT>*>(this); }
390 operator Vector_<ELT>&() { return *reinterpret_cast< Vector_<ELT>*>(this); }
391 operator const VectorView_<ELT>&() const { return *reinterpret_cast<const VectorView_<ELT>*>(this); }
392 operator VectorView_<ELT>&() { return *reinterpret_cast< VectorView_<ELT>*>(this); }
393
394 operator const Matrix_<ELT>&() const { return *reinterpret_cast<const Matrix_<ELT>*>(this); }
395 operator Matrix_<ELT>&() { return *reinterpret_cast< Matrix_<ELT>*>(this); }
396 operator const MatrixView_<ELT>&() const { return *reinterpret_cast<const MatrixView_<ELT>*>(this); }
397 operator MatrixView_<ELT>&() { return *reinterpret_cast< MatrixView_<ELT>*>(this); }
398
399
400 // size() for Vectors is Base::nelt() but returns int instead of ptrdiff_t.
401 int size() const {
402 assert(Base::nelt() <= (ptrdiff_t)std::numeric_limits<int>::max());
403 assert(Base::ncol()==1);
404 return (int)Base::nelt();
405 }
406 int nrow() const {assert(Base::ncol()==1); return Base::nrow();}
407 int ncol() const {assert(Base::ncol()==1); return Base::ncol();}
408 ptrdiff_t nelt() const {assert(Base::ncol()==1); return Base::nelt();}
409
410 // Override MatrixBase operators to return the right shape
411 SimTK_NODISCARD TAbs abs() const {TAbs result; Base::abs(result); return result;}
412
413 // Override MatrixBase indexing operators
414 const ELT& operator[](int i) const {return *reinterpret_cast<const ELT*>(Base::getHelper().getElt(i));}
415 ELT& operator[](int i) {return *reinterpret_cast<ELT*> (Base::updHelper().updElt(i));}
416 const ELT& operator()(int i) const {return *reinterpret_cast<const ELT*>(Base::getHelper().getElt(i));}
417 ELT& operator()(int i) {return *reinterpret_cast<ELT*> (Base::updHelper().updElt(i));}
418
419 // Block (contiguous subvector) view creation
420 VectorView_<ELT> operator()(int i, int m) const {return Base::operator()(i,0,m,1).getAsVectorView();}
421 VectorView_<ELT> operator()(int i, int m) {return Base::operator()(i,0,m,1).updAsVectorView();}
422
423 // Indexed view creation (arbitrary subvector). Indices must be
424 // monotonically increasing.
435
436 VectorView_<ELT> operator()(const Array_<int>& indices) const {return index(indices);}
437 VectorView_<ELT> operator()(const Array_<int>& indices) {return updIndex(indices);}
438
439 // Hermitian transpose.
442
443 THerm operator~() const {return transpose();}
445
446 const VectorBase& operator+() const {return *this; }
447
448 // Negation
449
450 SimTK_NODISCARD const TNeg& negate() const {return *reinterpret_cast<const TNeg*>(this); }
451 TNeg& updNegate() {return *reinterpret_cast<TNeg*>(this); }
452
453 const TNeg& operator-() const {return negate();}
454 TNeg& operator-() {return updNegate();}
455
456 VectorBase& resize(int m) {Base::resize(m,1); return *this;}
457 VectorBase& resizeKeep(int m) {Base::resizeKeep(m,1); return *this;}
458
459 //TODO: this is not re-locking the number of columns at 1.
461
462 ELT sum() const {ELT s; Base::getHelper().sum(reinterpret_cast<Scalar*>(&s)); return s; } // add all the elements
469
470protected:
471 // Create a VectorBase handle using a given helper rep.
472 explicit VectorBase(MatrixHelperRep<Scalar>* hrep) : Base(hrep) {}
473
474private:
475 // NO DATA MEMBERS ALLOWED
476};
477
478} //namespace SimTK
479
480#endif // SimTK_SIMMATRIX_VECTORBASE_H_
#define SimTK_THROW1(exc, a1)
Definition Exception.h:325
#define SimTK_NODISCARD
Warn if a caller fails to capture or use the return value of a method.
Definition SimTKcommon/include/SimTKcommon/internal/common.h:315
The Array_<T> container class is a plug-compatible replacement for the C++ standard template library ...
Definition Array.h:1520
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:307
This is the common base class for Simbody's Vector_ and Matrix_ classes for handling large,...
Definition MatrixBase.h:68
const RowVectorView_< ELT > & getAsRowVectorView() const
Definition MatrixBase.h:810
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
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
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
RowVectorView_< ELT > & updAsRowVectorView()
Definition MatrixBase.h:812
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
Definition MatrixHelper.h:49
Definition MatrixHelper.h:97
Definition MatrixHelper.h:96
Here we define class MatrixHelper<S>, the scalar-type templatized helper class for the more general,...
Definition MatrixHelper.h:80
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:44
VectorIterator< ELT, VectorBase< ELT > > begin()
Definition VectorBase.h:463
VectorView_< ELT > operator()(const Array_< int > &indices) const
Definition VectorBase.h:436
VectorBase & operator/=(const StdNumber &t)
Definition VectorBase.h:151
void elementwiseDivide(const VectorBase< EE > &v, typename EltResult< EE >::Dvd &out) const
Definition VectorBase.h:365
int size() const
Definition VectorBase.h:401
void clear()
Definition VectorBase.h:460
EltResult< EE >::Dvd elementwiseDivide(const VectorBase< EE > &v) const
Definition VectorBase.h:367
VectorBase(std::initializer_list< ELT > init)
Default constructor makes a 0x1 matrix locked at 1 column; you can provide an initial allocation if y...
Definition VectorBase.h:91
ELT sum() const
Definition VectorBase.h:462
TNeg & updNegate()
Definition VectorBase.h:451
const VectorBase & operator+() const
Definition VectorBase.h:446
VectorBase & operator-=(const VectorBase &r)
Definition VectorBase.h:153
void elementwiseMultiplyFromLeft(const VectorBase< EE > &v, typename VectorBase< EE >::template EltResult< ELT >::Mul &out) const
Definition VectorBase.h:348
VectorView_< ELT > operator()(const Array_< int > &indices)
Definition VectorBase.h:437
VectorBase & operator+=(const VectorBase &r)
Definition VectorBase.h:152
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:221
void elementwiseMultiply(const VectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
Definition VectorBase.h:339
THerm operator~() const
Definition VectorBase.h:443
EltResult< EE >::Mul elementwiseMultiply(const VectorBase< EE > &v) const
Definition VectorBase.h:341
VectorBase & elementwiseDivideFromLeftInPlace(const VectorBase< EE > &r)
Definition VectorBase.h:371
void elementwiseDivideFromLeft(const VectorBase< EE > &v, typename VectorBase< EE >::template EltResult< ELT >::Dvd &out) const
Definition VectorBase.h:374
ELT & operator[](int i)
Definition VectorBase.h:415
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:128
VectorBase & elementwiseMultiplyFromLeftInPlace(const VectorBase< EE > &r)
Definition VectorBase.h:345
const ELT & operator[](int i) const
Definition VectorBase.h:414
TAbs abs() const
Definition VectorBase.h:411
THerm updTranspose()
Definition VectorBase.h:441
void rowScale(const VectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
Definition VectorBase.h:175
void elementwiseInvert(VectorBase< typename CNT< ELT >::TInvert > &out) const
Set supplied out[i] = this[i]^-1.
Definition VectorBase.h:325
VectorBase< EE >::template EltResult< ELT >::Dvd elementwiseDivideFromLeft(const VectorBase< EE > &v) const
Definition VectorBase.h:381
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:173
VectorBase(MatrixHelperRep< Scalar > *hrep)
Definition VectorBase.h:472
VectorBase< typename CNT< ELT >::TInvert > elementwiseInvert() const
Return out[i]=this[i]^-1 as function return.
Definition VectorBase.h:330
VectorIterator< ELT, VectorBase< ELT > > end()
Definition VectorBase.h:466
VectorBase< EE >::template EltResult< ELT >::Mul elementwiseMultiplyFromLeft(const VectorBase< EE > &v) const
Definition VectorBase.h:355
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:256
ELT & operator()(int i)
Definition VectorBase.h:417
ptrdiff_t nelt() const
Definition VectorBase.h:408
const TNeg & negate() const
Definition VectorBase.h:450
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:185
VectorBase & resizeKeep(int m)
Definition VectorBase.h:457
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:88
int ncol() const
Definition VectorBase.h:407
VectorBase(const VectorBase &source)
Copy constructor is a deep copy (not appropriate for views!).
Definition VectorBase.h:74
THerm operator~()
Definition VectorBase.h:444
VectorBase & elementwiseDivideInPlace(const VectorBase< EE > &r)
Definition VectorBase.h:363
const ELT & operator()(int i) const
Definition VectorBase.h:416
EltResult< EE >::Mul rowScale(const VectorBase< EE > &v) const
Definition VectorBase.h:177
VectorBase & elementwiseMultiplyInPlace(const VectorBase< EE > &r)
Definition VectorBase.h:337
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:69
THerm transpose() const
Definition VectorBase.h:440
VectorView_< ELT > index(const Array_< int > &indices) const
Definition VectorBase.h:425
const TNeg & operator-() const
Definition VectorBase.h:453
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:289
VectorBase(int m, const ELT &initialValue)
Construct an owner vector of length m, with each element initialized to the given value.
Definition VectorBase.h:81
VectorView_< ELT > updIndex(const Array_< int > &indices)
Definition VectorBase.h:430
VectorBase(const MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
Construct a read-only view of the source data.
Definition VectorBase.h:125
VectorBase & operator=(const VectorBase< EE > &b)
Definition VectorBase.h:156
VectorView_< ELT > operator()(int i, int m) const
Definition VectorBase.h:420
VectorBase(int m, int stride, const Scalar *s)
Construct a read-only view of existing data.
Definition VectorBase.h:106
TNeg & operator-()
Definition VectorBase.h:454
VectorBase & resize(int m)
Definition VectorBase.h:456
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:143
VectorBase(int m, int stride, Scalar *s)
Construct a writable view into existing data.
Definition VectorBase.h:109
VectorBase & operator+=(const VectorBase< EE > &b)
Definition VectorBase.h:158
int nrow() const
Definition VectorBase.h:406
VectorBase(MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
Construct a writable view into the source data.
Definition VectorBase.h:122
VectorBase & operator=(const ELT &t)
Fill current allocation with copies of element.
Definition VectorBase.h:167
VectorBase & operator*=(const StdNumber &t)
Definition VectorBase.h:150
VectorBase(const TNeg &source)
Implicit conversion from compatible vector with negated elements.
Definition VectorBase.h:77
VectorBase & operator-=(const VectorBase< EE > &b)
Definition VectorBase.h:160
VectorBase & elementwiseInvertInPlace()
Set this[i] = this[i]^-1.
Definition VectorBase.h:319
VectorView_< ELT > operator()(int i, int m)
Definition VectorBase.h:421
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
unsigned char square(unsigned char u)
Definition Scalar.h:339
Definition VectorBase.h:134
VectorBase< typename CNT< ELT >::template Result< P >::Mul > Mul
Definition VectorBase.h:135
VectorBase< typename CNT< ELT >::template Result< P >::Add > Add
Definition VectorBase.h:137
VectorBase< typename CNT< ELT >::template Result< P >::Dvd > Dvd
Definition VectorBase.h:136
VectorBase< typename CNT< ELT >::template Result< P >::Sub > Sub
Definition VectorBase.h:138