⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rowmajor.h

📁 高效的c++科学算法库
💻 H
字号:
/*                                           -*- c++ -*- ****************************** * Scientific Library (GNU Public Licence) * * Author: Laurent Deniau, Laurent.Deniau@cern.ch * * $Id: rowmajor.h,v 1.1 1998/11/05 12:48:38 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_ROWMAJOR_ROWMAJOR_H#define SL_MATRIX_STRUCTURES_ROWMAJOR_ROWMAJOR_H#ifndef SL_MATRIX_STRUCTURES_ROWMAJOR_H#error <sl/matrix/structures/rowmajor/rowmajor.h> must be included via <sl/matrix/structures/rowmajor.h>#endif#ifdef HAVE_NAMESPACEnamespace sl {#endif      // forward declaration    class RowmajorIterator;// Row major matrix structure//// [1 2 3]// [4 5 6]// [7 8 9]//      /** @memo Structure Row Major (C-like)       */    class RowMajor : public MatrixStructure    {    public:        typedef RowMajorIterator iterator_t;          /**@name public members*/          //@{          /// return size $n\times p$        size_t size() const { return my_n*my_p; }          /// return number of rows $n$        Index  rows() const { return my_n; }          /// return number of cols $p$        Index  cols() const { return my_p; }          /// 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 my_p; }          /// 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        RowMajor() : my_n(0), my_p(0) {}          /// square constructor        explicit        RowMajor(Index const n) : my_n(n), my_p(n) {}          /// rectangular constructor        RowMajor(Index const n, Index const p) : my_n(n), my_p(p) {}          // WARNING: Do NOT declare the copy constructor !          //@}              /**@name protected members*/          //@{          /// map(MinIndex,MinIndex)        ptrdiff_t offset() const { return (my_p+1)*MinIndex; }          /// resize to size $n$ and $p$        void        resize(Index const n, Index const p) {            my_n = n;            my_p = p;        }          /// set value at $(i,j)$        template <typename T_value>        T_value&        get(T_value* const data, Index const i, Index const j) {            return data[my_p*i+j];        }          /// 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[my_p*i+j];        }          //@}    private:          /// number of rows        Index my_n;          /// number of cols        Index my_p;    };#ifdef HAVE_NAMESPACE}#endif #endif// SL_MATRIX_STRUCTURES_ROWMAJOR_ROWMAJOR_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -