Blender V2.61 - r43446

index.h

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