Simbody  3.5
RowVectorView_.h
Go to the documentation of this file.
00001 #ifndef SimTK_SIMMATRIX_ROWVECTORVIEW_H_
00002 #define SimTK_SIMMATRIX_ROWVECTORVIEW_H_
00003 
00004 /* -------------------------------------------------------------------------- *
00005  *                       Simbody(tm): SimTKcommon                             *
00006  * -------------------------------------------------------------------------- *
00007  * This is part of the SimTK biosimulation toolkit originating from           *
00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00010  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody.  *
00011  *                                                                            *
00012  * Portions copyright (c) 2005-13 Stanford University and the Authors.        *
00013  * Authors: Michael Sherman                                                   *
00014  * Contributors:                                                              *
00015  *                                                                            *
00016  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
00017  * not use this file except in compliance with the License. You may obtain a  *
00018  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
00019  *                                                                            *
00020  * Unless required by applicable law or agreed to in writing, software        *
00021  * distributed under the License is distributed on an "AS IS" BASIS,          *
00022  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
00023  * See the License for the specific language governing permissions and        *
00024  * limitations under the License.                                             *
00025  * -------------------------------------------------------------------------- */
00026 
00031 namespace SimTK {
00032 
00033 //==============================================================================
00034 //                              ROW VECTOR VIEW
00035 //==============================================================================
00042 template <class ELT> class RowVectorView_ : public RowVectorBase<ELT> {
00043     typedef RowVectorBase<ELT>                              Base;
00044     typedef typename CNT<ELT>::Scalar                       S;
00045     typedef typename CNT<ELT>::Number                       Number;
00046     typedef typename CNT<ELT>::StdNumber                    StdNumber;
00047     typedef RowVectorView_<ELT>                             T;
00048     typedef RowVectorView_< typename CNT<ELT>::TNeg >       TNeg;
00049     typedef VectorView_< typename CNT<ELT>::THerm >         THerm;
00050 public:
00051     // Default construction is suppressed.
00052     // Uses default destructor.
00053 
00054     // Create a RowVectorView_ handle using a given helper rep. 
00055     explicit RowVectorView_(MatrixHelperRep<S>* hrep) : Base(hrep) {}
00056 
00057     // Copy constructor is shallow. CAUTION: despite const argument, this preserves writability
00058     // if it was present in the source. This is necessary to allow temporary views to be
00059     // created and used as lvalues.
00060     RowVectorView_(const RowVectorView_& r) 
00061       : Base(const_cast<MatrixHelper<S>&>(r.getHelper()), typename MatrixHelper<S>::ShallowCopy()) { }
00062 
00063     // Copy assignment is deep but not reallocating.
00064     RowVectorView_& operator=(const RowVectorView_& r) {
00065         Base::operator=(r); return *this;
00066     }
00067 
00068     // Ask for shallow copy    
00069     explicit RowVectorView_(const MatrixHelper<S>& h) : Base(h, typename MatrixHelper<S>::ShallowCopy()) { }
00070     explicit RowVectorView_(MatrixHelper<S>&       h) : Base(h, typename MatrixHelper<S>::ShallowCopy()) { }
00071     
00072     RowVectorView_& operator=(const Base& b) { Base::operator=(b); return *this; }
00073 
00074     RowVectorView_& operator=(const ELT& v) { Base::operator=(v); return *this; } 
00075 
00076     template <class EE> RowVectorView_& operator=(const RowVectorBase<EE>& m)
00077       { Base::operator=(m); return*this; }
00078     template <class EE> RowVectorView_& operator+=(const RowVectorBase<EE>& m)
00079       { Base::operator+=(m); return*this; }
00080     template <class EE> RowVectorView_& operator-=(const RowVectorBase<EE>& m)
00081       { Base::operator-=(m); return*this; }
00082 
00083     RowVectorView_& operator*=(const StdNumber& t) { Base::operator*=(t); return *this; }
00084     RowVectorView_& operator/=(const StdNumber& t) { Base::operator/=(t); return *this; }
00085     RowVectorView_& operator+=(const ELT& b) { this->elementwiseAddScalarInPlace(b); return *this; }
00086     RowVectorView_& operator-=(const ELT& b) { this->elementwiseSubtractScalarInPlace(b); return *this; }
00087 
00088 private:
00089     // NO DATA MEMBERS ALLOWED
00090     RowVectorView_(); // default construction suppressed (what is it a view of?)
00091 };
00092 
00093 } //namespace SimTK
00094 
00095 #endif // SimTK_SIMMATRIX_ROWVECTORVIEW_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines