diagonal.h

来自「高效的c++科学算法库」· C头文件 代码 · 共 112 行

H
112
字号
#ifndef SL_MATRIX_STRUCTURES_DIAGONAL_DIAGONAL_H#define SL_MATRIX_STRUCTURES_DIAGONAL_DIAGONAL_H/* ****************************** * Scientific Library (GNU Public Licence) * * Author: Laurent Deniau, Laurent.Deniau@cern.ch * * $Id: diagonal.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_DIAGONAL_H#error <sl/matrix/structures/diagonal/diagonal.h> must be included via <sl/matrix/structures/diagonal.h>#endif#ifdef HAVE_NAMESPACEnamespace sl {#endif/*  WARNING:  These classes MUST use the default copy constructor*/  // Diagonal matrix structure//// [1 . .]// [. 2 .]// [. . 3]//    class Diagonal : public MatrixStructure {      public:        typedef DiagonalIterator iterator_t;        size_t size () const { return my_n; }        Index  rows () const { return my_n; }        Index  cols () const { return my_n; }        Index firstInRow (Index const i) const { return i; }        Index firstInCol (Index const j) const { return j; }        Index lastInRow  (Index const i) const { return i; }        Index lastInCol  (Index const j) const { return j; }        static Bool isRowMajor () { return true; }          // map(MinIndex,MinIndex)        ptrdiff_t offset () const { return MinIndex; }            Diagonal () : my_n (0) { }            Diagonal (Index const n) : my_n (n) { }            Diagonal (Index const n, Index const p) : my_n (n) {            assert ( p == cols() );        }          // WARNING: Do NOT declare the copy constructor !          void            resize (Index const n, Index const p) {            my_n = n;            assert ( p == cols() );        }        template <typename T_value>            T_value&            get (T_value* const data, Index const i, Index const j) {            return i==j ? data[i] : zero_ref<T_value>();        }        template <typename T_value>            T_value            get (T_value const* const data, Index const i, Index const j) const {            return i==j ? data[i] : T_value();        }      private:        Index my_n;    };#ifdef HAVE_NAMESPACE}#endif #endif// SL_MATRIX_STRUCTURES_DIAGONAL_DIAGONAL_H

⌨️ 快捷键说明

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