1 /* 2 * 3 * Template Numerical Toolkit (TNT): Linear Algebra Module 4 * 5 * Mathematical and Computational Sciences Division 6 * National Institute of Technology, 7 * Gaithersburg, MD USA 8 * 9 * 10 * This software was developed at the National Institute of Standards and 11 * Technology (NIST) by employees of the Federal Government in the course 12 * of their official duties. Pursuant to title 17 Section 105 of the 13 * United States Code, this software is not subject to copyright protection 14 * and is in the public domain. The Template Numerical Toolkit (TNT) is 15 * an experimental system. NIST assumes no responsibility whatsoever for 16 * its use by other parties, and makes no guarantees, expressed or implied, 17 * about its quality, reliability, or any other characteristic. 18 * 19 * BETA VERSION INCOMPLETE AND SUBJECT TO CHANGE 20 * see http://math.nist.gov/tnt for latest updates. 21 * 22 */ 23 24 25 26 // Vector/Matrix/Array Index Module 27 28 #ifndef INDEX_H 29 #define INDEX_H 30 31 #include "tnt/subscript.h" 32 33 namespace TNT 34 { 35 36 class Index1D 37 { 38 Subscript lbound_; 39 Subscript ubound_; 40 41 public: 42 lbound()43 Subscript lbound() const { return lbound_; } ubound()44 Subscript ubound() const { return ubound_; } 45 Index1D(const Index1D & D)46 Index1D(const Index1D &D) : lbound_(D.lbound_), ubound_(D.ubound_) {} Index1D(Subscript i1,Subscript i2)47 Index1D(Subscript i1, Subscript i2) : lbound_(i1), ubound_(i2) {} 48 49 Index1D & operator=(const Index1D &D) 50 { 51 lbound_ = D.lbound_; 52 ubound_ = D.ubound_; 53 return *this; 54 } 55 56 }; 57 58 inline Index1D operator+(const Index1D &D, Subscript i) 59 { 60 return Index1D(i+D.lbound(), i+D.ubound()); 61 } 62 63 inline Index1D operator+(Subscript i, const Index1D &D) 64 { 65 return Index1D(i+D.lbound(), i+D.ubound()); 66 } 67 68 69 70 inline Index1D operator-(Index1D &D, Subscript i) 71 { 72 return Index1D(D.lbound()-i, D.ubound()-i); 73 } 74 75 inline Index1D operator-(Subscript i, Index1D &D) 76 { 77 return Index1D(i-D.lbound(), i-D.ubound()); 78 } 79 80 } // namespace TNT 81 82 #endif 83 84