Blender  V2.59
index.h
Go to the documentation of this file.
00001 
00005 /*
00006 
00007 *
00008 * Template Numerical Toolkit (TNT): Linear Algebra Module
00009 *
00010 * Mathematical and Computational Sciences Division
00011 * National Institute of Technology,
00012 * Gaithersburg, MD USA
00013 *
00014 *
00015 * This software was developed at the National Institute of Standards and
00016 * Technology (NIST) by employees of the Federal Government in the course
00017 * of their official duties. Pursuant to title 17 Section 105 of the
00018 * United States Code, this software is not subject to copyright protection
00019 * and is in the public domain.  The Template Numerical Toolkit (TNT) is
00020 * an experimental system.  NIST assumes no responsibility whatsoever for
00021 * its use by other parties, and makes no guarantees, expressed or implied,
00022 * about its quality, reliability, or any other characteristic.
00023 *
00024 * BETA VERSION INCOMPLETE AND SUBJECT TO CHANGE
00025 * see http://math.nist.gov/tnt for latest updates.
00026 *
00027 */
00028 
00029 
00030 
00031 // Vector/Matrix/Array Index Module  
00032 
00033 #ifndef INDEX_H
00034 #define INDEX_H
00035 
00036 #include "subscript.h"
00037 
00038 namespace TNT
00039 {
00040 
00041 class Index1D
00042 {
00043     Subscript lbound_;
00044     Subscript ubound_;
00045 
00046     public:
00047 
00048     Subscript lbound() const { return lbound_; }
00049     Subscript ubound() const { return ubound_; }
00050 
00051     Index1D(const Index1D &D) : lbound_(D.lbound_), ubound_(D.ubound_) {}
00052     Index1D(Subscript i1, Subscript i2) : lbound_(i1), ubound_(i2) {}
00053 
00054     Index1D & operator=(const Index1D &D)
00055     {
00056         lbound_ = D.lbound_;
00057         ubound_ = D.ubound_;
00058         return *this;
00059     }
00060 
00061 };
00062 
00063 inline Index1D operator+(const Index1D &D, Subscript i)
00064 {
00065     return Index1D(i+D.lbound(), i+D.ubound());
00066 }
00067 
00068 inline Index1D operator+(Subscript i, const Index1D &D)
00069 {
00070     return Index1D(i+D.lbound(), i+D.ubound());
00071 }
00072 
00073 
00074 
00075 inline Index1D operator-(Index1D &D, Subscript i)
00076 {
00077     return Index1D(D.lbound()-i, D.ubound()-i);
00078 }
00079 
00080 inline Index1D operator-(Subscript i, Index1D &D)
00081 {
00082     return Index1D(i-D.lbound(), i-D.ubound());
00083 }
00084 
00085 } // namespace TNT
00086 
00087 #endif
00088