Simbody  3.5
RowVector_.h
Go to the documentation of this file.
00001 #ifndef SimTK_SIMMATRIX_ROWVECTOR_H_
00002 #define SimTK_SIMMATRIX_ROWVECTOR_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
00035 //==============================================================================
00052 template <class ELT> class RowVector_ : public RowVectorBase<ELT> {
00053     typedef typename CNT<ELT>::Scalar       S;
00054     typedef typename CNT<ELT>::Number       Number;
00055     typedef typename CNT<ELT>::StdNumber    StdNumber;
00056     typedef typename CNT<ELT>::TNeg         ENeg;
00057 
00058     typedef RowVectorBase<ELT>              Base;
00059     typedef RowVectorBase<ENeg>             BaseNeg;
00060 public:
00061     RowVector_() : Base() {}   // 1x0 reallocatable
00062     // Uses default destructor.
00063 
00064     // Copy constructor is deep.
00065     RowVector_(const RowVector_& src) : Base(src) {}
00066 
00067     // Implicit conversions.
00068     RowVector_(const Base& src) : Base(src) {}    // e.g., RowVectorView
00069     RowVector_(const BaseNeg& src) : Base(src) {}  
00070 
00071     // Copy assignment is deep and can be reallocating if this RowVector
00072     // has no View.
00073     RowVector_& operator=(const RowVector_& src) {
00074         Base::operator=(src); return*this;
00075     }
00076 
00077 
00078     explicit RowVector_(int n) : Base(n) { }
00079     RowVector_(int n, const ELT* cppInitialValues) : Base(n, cppInitialValues) {}
00080     RowVector_(int n, const ELT& initialValue)     : Base(n, initialValue) {}
00081 
00086     RowVector_(int n, const S* cppData, bool): Base(n, Base::CppNScalarsPerElement, cppData) {}
00087     RowVector_(int n,       S* cppData, bool): Base(n, Base::CppNScalarsPerElement, cppData) {}
00088 
00092     RowVector_(int n, int stride, const S* data, bool) : Base(n, stride, data) {}
00093     RowVector_(int n, int stride,       S* data, bool) : Base(n, stride, data) {}
00094     
00096     template <int M>
00097     explicit RowVector_(const Row<M,ELT>& v) : Base(M) {
00098         for (int i = 0; i < M; ++i)
00099             this->updElt(0, i) = v(i);
00100     }
00101 
00102     RowVector_& operator=(const ELT& v) { Base::operator=(v); return *this; } 
00103 
00104     template <class EE> RowVector_& operator=(const RowVectorBase<EE>& b)
00105       { Base::operator=(b); return*this; }
00106     template <class EE> RowVector_& operator+=(const RowVectorBase<EE>& b)
00107       { Base::operator+=(b); return*this; }
00108     template <class EE> RowVector_& operator-=(const RowVectorBase<EE>& b)
00109       { Base::operator-=(b); return*this; }
00110 
00111     RowVector_& operator*=(const StdNumber& t) { Base::operator*=(t); return *this; }
00112     RowVector_& operator/=(const StdNumber& t) { Base::operator/=(t); return *this; }
00113     RowVector_& operator+=(const ELT& b) { this->elementwiseAddScalarInPlace(b); return *this; }
00114     RowVector_& operator-=(const ELT& b) { this->elementwiseSubtractScalarInPlace(b); return *this; }
00115 
00116 private:
00117     // NO DATA MEMBERS ALLOWED
00118 };
00119 
00120 } //namespace SimTK
00121 
00122 #endif // SimTK_SIMMATRIX_ROWVECTOR_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines