📄 tvector.h
字号:
/* -*- c++ -*- ****************************** * Scientific Library (GNU Public Licence) * * Author: Laurent Deniau, Laurent.Deniau@cern.ch * * $Id: tvector.h,v 1.1 1998/11/05 12:48:42 paubert Exp $ * * Suggestions: sl@mathinsa.insa-lyon.fr * Bugs: sl-bugs@mathinsa.insa-lyon.fr * * For more information, please see the sl++ Home Page: * http://wwwinfo.cern.ch/~ldeniau/sl.html * ****************************** */#ifndef SL_MATRIX_STRUCTURES_TVECTOR_TVECTOR_H#define SL_MATRIX_STRUCTURES_TVECTOR_TVECTOR_H#ifndef SL_MATRIX_STRUCTURES_TVECTOR_H#error <sl/matrix/structures/tvector/tvector.h> must be included via <sl/matrix/structures/tvector.h>#endif#ifdef HAVE_NAMESPACEnamespace sl {#endif /** @memo Structure TVector */ class TVector : public MatrixStructure { public: typedef TVectorIterator iterator_t; /**@name public members*/ //@{ /// return size $n$ size_t size () const { return my_n; } /// return number of rows $n$ Index rows () const { return my_n; } /// return number of cols $p$ Index cols () const { return 1; } /// return index of the first element in row $i$ Index firstInRow (Index const i) const { return MinIndex; } /// return index of the first element in col $j$ Index firstInCol (Index const j) const { return MinIndex; } /// return index of the last element in row $i$ Index lastInRow (Index const i) const { return MinIndex; } /// return index of the last element in row $j$ Index lastInCol (Index const j) const { return my_n; } /// return true if structure is row major orientated static Bool isRowMajor () { return true; } //@} protected: /**@name protected constructors*/ //@{ /// default constructor explicit TVector () : my_n (0) { } /// constructor size equal $n$ explicit TVector (Index const n) : my_n (n) { } /// rectangular constructor (should raise an exception) TVector (Index const n, Index const p) : my_n (n) { assert ( p == cols() ); } // WARNING: Do NOT declare the copy constructor ! //@} /**@name protected members*/ //@{ /// map(MinIndex,MinIndex) ptrdiff_t offset () const { return MinIndex; } /// resize to size $n$ and $p$ (should raise an exception) void resize (Index const n, Index const p=MinIndex) { my_n = n; assert ( p == cols() ); } /// set value at $(i,j)$ template <typename T_value> T_value& get (T_value* const data, Index const i, Index const j) { return data[i]; } /// get value at $(i,j)$ template <typename T_value> T_value get (T_value const* const data, Index const i, Index const j) const { return data[i]; } /// Range initialization template <typename T_value> void initialize (T_value* const data, Range const& r) { for (Index i=MinIndex; i<=rows(); ++i) data[i] = r[i]; } /// Ranged Range initialization template <typename T_value> void initialize (T_value* const data, Range const& r1 , Range const& r2) { Index i_end = r1.size(); for (Index i=MinIndex; i<=i_end; ++i) data[r1[i]] = r2[i]; } //@} private: /// number of rows Index my_n; };#ifdef HAVE_NAMESPACE}#endif #endif// SL_MATRIX_STRUCTURES_TVECTOR_TVECTOR_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -