Simbody  3.7
RowVectorView_.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMMATRIX_ROWVECTORVIEW_H_
2 #define SimTK_SIMMATRIX_ROWVECTORVIEW_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 namespace SimTK {
32 
33 //==============================================================================
34 // ROW VECTOR VIEW
35 //==============================================================================
42 template <class ELT> class RowVectorView_ : public RowVectorBase<ELT> {
43  typedef RowVectorBase<ELT> Base;
44  typedef typename CNT<ELT>::Scalar S;
45  typedef typename CNT<ELT>::Number Number;
46  typedef typename CNT<ELT>::StdNumber StdNumber;
47  typedef RowVectorView_<ELT> T;
48  typedef RowVectorView_< typename CNT<ELT>::TNeg > TNeg;
49  typedef VectorView_< typename CNT<ELT>::THerm > THerm;
50 public:
51  // Default construction is suppressed.
52  // Uses default destructor.
53 
54  // Create a RowVectorView_ handle using a given helper rep.
55  explicit RowVectorView_(MatrixHelperRep<S>* hrep) : Base(hrep) {}
56 
57  // Copy constructor is shallow. CAUTION: despite const argument, this preserves writability
58  // if it was present in the source. This is necessary to allow temporary views to be
59  // created and used as lvalues.
61  : Base(const_cast<MatrixHelper<S>&>(r.getHelper()), typename MatrixHelper<S>::ShallowCopy()) { }
62 
63  // Copy assignment is deep but not reallocating.
65  Base::operator=(r); return *this;
66  }
67 
68  // Ask for shallow copy
69  explicit RowVectorView_(const MatrixHelper<S>& h) : Base(h, typename MatrixHelper<S>::ShallowCopy()) { }
70  explicit RowVectorView_(MatrixHelper<S>& h) : Base(h, typename MatrixHelper<S>::ShallowCopy()) { }
71 
72  RowVectorView_& operator=(const Base& b) { Base::operator=(b); return *this; }
73 
74  RowVectorView_& operator=(const ELT& v) { Base::operator=(v); return *this; }
75 
76  template <class EE> RowVectorView_& operator=(const RowVectorBase<EE>& m)
77  { Base::operator=(m); return*this; }
78  template <class EE> RowVectorView_& operator+=(const RowVectorBase<EE>& m)
79  { Base::operator+=(m); return*this; }
80  template <class EE> RowVectorView_& operator-=(const RowVectorBase<EE>& m)
81  { Base::operator-=(m); return*this; }
82 
83  RowVectorView_& operator*=(const StdNumber& t) { Base::operator*=(t); return *this; }
84  RowVectorView_& operator/=(const StdNumber& t) { Base::operator/=(t); return *this; }
85  RowVectorView_& operator+=(const ELT& b) { this->elementwiseAddScalarInPlace(b); return *this; }
86  RowVectorView_& operator-=(const ELT& b) { this->elementwiseSubtractScalarInPlace(b); return *this; }
87 
88 private:
89  // NO DATA MEMBERS ALLOWED
90  RowVectorView_(); // default construction suppressed (what is it a view of?)
91 };
92 
93 } //namespace SimTK
94 
95 #endif // SimTK_SIMMATRIX_ROWVECTORVIEW_H_
Here we define class MatrixHelper<S>, the scalar-type templatized helper class for the more general...
Definition: MatrixHelper.h:79
RowVectorView_ & operator+=(const RowVectorBase< EE > &m)
Definition: RowVectorView_.h:78
Definition: MatrixHelper.h:48
This is a dataless rehash of the MatrixBase class to specialize it for RowVectors.
Definition: BigMatrix.h:165
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
MatrixBase & elementwiseSubtractScalarInPlace(const S &s)
Set M(i,j)-=s for every element of M and some value s.
RowVectorView_ & operator-=(const RowVectorBase< EE > &m)
Definition: RowVectorView_.h:80
K::Scalar Scalar
Definition: CompositeNumericalTypes.h:160
RowVectorView_ & operator=(const Base &b)
Definition: RowVectorView_.h:72
RowVectorView_ & operator-=(const ELT &b)
Definition: RowVectorView_.h:86
RowVectorView_(const RowVectorView_ &r)
Definition: RowVectorView_.h:60
RowVectorBase & operator-=(const RowVectorBase &r)
Definition: RowVectorBase.h:145
RowVectorView_(MatrixHelperRep< S > *hrep)
Definition: RowVectorView_.h:55
RowVectorView_(MatrixHelper< S > &h)
Definition: RowVectorView_.h:70
RowVectorBase & operator+=(const RowVectorBase &r)
Definition: RowVectorBase.h:144
(Advanced) This class is identical to RowVector_ except that it has shallow (reference) copy and assi...
Definition: BigMatrix.h:173
RowVectorView_(const MatrixHelper< S > &h)
Definition: RowVectorView_.h:69
RowVectorView_ & operator=(const RowVectorBase< EE > &m)
Definition: RowVectorView_.h:76
RowVectorView_ & operator*=(const StdNumber &t)
Definition: RowVectorView_.h:83
RowVectorBase & operator/=(const StdNumber &t)
Definition: RowVectorBase.h:143
EStdNumber StdNumber
Definition: MatrixBase.h:99
RowVectorBase & operator=(const RowVectorBase &b)
Copy assignment is deep copy but behavior depends on type of lhs: if view, rhs must match...
Definition: RowVectorBase.h:136
MatrixBase & elementwiseAddScalarInPlace(const S &s)
Set M(i,j)+=s for every element of M and some value s.
K::StdNumber StdNumber
Definition: CompositeNumericalTypes.h:163
const MatrixHelper< Scalar > & getHelper() const
Definition: MatrixBase.h:864
RowVectorView_ & operator/=(const StdNumber &t)
Definition: RowVectorView_.h:84
RowVectorView_ & operator=(const ELT &v)
Definition: RowVectorView_.h:74
This is the common base class for Simbody&#39;s Vector_ and Matrix_ classes for handling large...
Definition: BigMatrix.h:163
K::Number Number
Definition: CompositeNumericalTypes.h:162
RowVectorView_ & operator+=(const ELT &b)
Definition: RowVectorView_.h:85
RowVectorBase & operator*=(const StdNumber &t)
Definition: RowVectorBase.h:142
RowVectorView_ & operator=(const RowVectorView_ &r)
Definition: RowVectorView_.h:64