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

📄 symmetric.h

📁 高效的c++科学算法库
💻 H
字号:
#ifndef SL_MATRIX_STRUCTURES_SYMMETRIC_SYMMETRIC_H#define SL_MATRIX_STRUCTURES_SYMMETRIC_SYMMETRIC_H/* ****************************** * Scientific Library (GNU Public Licence) * * Author: Laurent Deniau, Laurent.Deniau@cern.ch * * $Id: symmetric.h,v 1.1 1998/11/05 12:48:39 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_SYMMETRIC_H#error <sl/matrix/structures/symmetric/symmetric.h> must be included via <sl/matrix/structures/symmetric.h>#endif#ifdef HAVE_NAMESPACEnamespace sl {#endif/*  WARNING:  These classes MUST use the default copy constructor*/  // Symmetric matrix structure//// [1 2 4]// [2 3 5]// [4 5 6]//    class Symmetric : public MatrixStructure {      public:        typedef SymmetricIterator iterator_t;        size_t size () const { return my_n*(my_n+1)/2; }        Index  rows () const { return my_n; }        Index  cols () const { return my_n; }        Index firstInRow (Index const i) const { return MinIndex; }        Index firstInCol (Index const j) const { return j; }        Index lastInRow  (Index const i) const { return i; }        Index lastInCol  (Index const j) const { return my_n; }        static Bool isRowMajor () { return true; }          // map(MinIndex,MinIndex)        ptrdiff_t offset () const { return MinIndex; }        Symmetric () : my_n (0) { }        Symmetric (Index const n) : my_n (n) { }        Symmetric (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 data[map(i,j)];        }        template <typename T_value>            T_value            get (T_value const* const data, Index const i, Index const j) const {            return data[map(i,j)];        }      private:        Index            map (Index const i, Index const j) const {            return j<=i ? (i-MinIndex)*(i-MinIndex+1)/2+j :                 (j-MinIndex)*(j-MinIndex+1)/2+i;        }        Index my_n;    };#ifdef HAVE_NAMESPACE}#endif #endif // SL_MATRIX_STRUCTURES_SYMMETRIC_SYMMETRIC_H

⌨️ 快捷键说明

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