Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F19251383
PointND.icc
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
PointND.icc
View Options
#include <cassert>
#include <limits>
#include "geners/ClassId.hh"
namespace npstat {
template <typename Numeric, unsigned Dim>
inline PointND<Numeric,Dim>::PointND()
{
assert(Dim);
coords_[0] = Numeric();
for (unsigned i=1; i<Dim; ++i)
coords_[i] = coords_[0];
}
template <typename Numeric, unsigned Dim>
template <typename Num2>
inline PointND<Numeric,Dim>::PointND(const Num2* data,
const unsigned dataLen)
{
assert(Dim);
assert(data);
assert(dataLen <= Dim);
unsigned i=0;
for (; i<dataLen; ++i)
coords_[i] = data[i];
if (i < Dim)
{
coords_[i++] = Numeric();
for (; i<Dim; ++i)
coords_[i] = coords_[dataLen];
}
}
template <typename Numeric, unsigned Dim>
PointND<Numeric,Dim> PointND<Numeric,Dim>::operator-() const
{
PointND p;
for (unsigned i=0; i<Dim; ++i)
p.coords_[i] = -coords_[i];
return p;
}
template <typename Numeric, unsigned Dim>
template <unsigned Dim2>
PointND<Numeric,Dim2> PointND<Numeric,Dim>::subPoint(
const unsigned* whichCoords) const
{
PointND<Numeric,Dim2> p;
for (unsigned i=0; i<Dim2; ++i)
{
assert(whichCoords[i] < Dim);
p.coords_[i] = coords_[whichCoords[i]];
}
}
template <typename Numeric, unsigned Dim>
PointND<Numeric,Dim> PointND<Numeric,Dim>::maximumPoint()
{
PointND<Numeric,Dim> p;
for (unsigned i=0; i<Dim; ++i)
p.coords_[i] = std::numeric_limits<Numeric>::max();
return p;
}
template <typename Numeric, unsigned Dim>
inline PointND<Numeric,Dim> PointND<Numeric,Dim>::minimumPoint()
{
return -maximumPoint();
}
template <typename Numeric, unsigned Dim>
inline PointND<Numeric,Dim>::PointND(const Numeric& c0)
{
assert(Dim == 1U);
coords_[0] = c0;
}
template <typename Numeric, unsigned Dim>
inline PointND<Numeric,Dim>::PointND(const Numeric& c0,
const Numeric& c1)
{
assert(Dim == 2U);
coords_[0] = c0;
coords_[1] = c1;
}
template <typename Numeric, unsigned Dim>
inline PointND<Numeric,Dim>::PointND(const Numeric& c0,
const Numeric& c1,
const Numeric& c2)
{
assert(Dim == 3U);
coords_[0] = c0;
coords_[1] = c1;
coords_[2] = c2;
}
template <typename Numeric, unsigned Dim>
inline PointND<Numeric,Dim>::PointND(const Numeric& c0,
const Numeric& c1,
const Numeric& c2,
const Numeric& c3)
{
assert(Dim == 4U);
coords_[0] = c0;
coords_[1] = c1;
coords_[2] = c2;
coords_[3] = c3;
}
template <typename Numeric, unsigned Dim>
inline PointND<Numeric,Dim>::PointND(const Numeric& c0,
const Numeric& c1,
const Numeric& c2,
const Numeric& c3,
const Numeric& c4)
{
assert(Dim == 5U);
coords_[0] = c0;
coords_[1] = c1;
coords_[2] = c2;
coords_[3] = c3;
coords_[4] = c4;
}
template <typename Numeric, unsigned Dim>
inline PointND<Numeric,Dim>::PointND(const Numeric& c0,
const Numeric& c1,
const Numeric& c2,
const Numeric& c3,
const Numeric& c4,
const Numeric& c5)
{
assert(Dim == 6U);
coords_[0] = c0;
coords_[1] = c1;
coords_[2] = c2;
coords_[3] = c3;
coords_[4] = c4;
coords_[5] = c5;
}
template <typename Numeric, unsigned Dim>
const char* PointND<Numeric,Dim>::classname()
{
static std::string name;
if (name.size() == 0)
{
name = "npstat::PointND<";
const gs::ClassId& id(gs::ClassId::makeId<Numeric>());
name += id.id();
name += ',';
std::ostringstream os;
os << Dim << "(0)";
name += os.str();
name += '>';
}
return name.c_str();
}
template <typename Numeric, unsigned Dim>
bool operator==(const PointND<Numeric,Dim>& l,
const PointND<Numeric,Dim>& r)
{
for (unsigned i=0; i<Dim; ++i)
if (!(l.coords_[i] == r.coords_[i]))
return false;
return true;
}
template <typename Numeric, unsigned Dim>
inline bool operator!=(const PointND<Numeric,Dim>& l,
const PointND<Numeric,Dim>& r)
{
return !(l == r);
}
template <typename Numeric, unsigned Dim>
bool operator<(const PointND<Numeric,Dim>& l,
const PointND<Numeric,Dim>& r)
{
for (unsigned i=0; i<Dim; ++i)
if (!(l.coords_[i] < r.coords_[i]))
return false;
return true;
}
template <typename Numeric, unsigned Dim>
bool operator<=(const PointND<Numeric,Dim>& l,
const PointND<Numeric,Dim>& r)
{
for (unsigned i=0; i<Dim; ++i)
if (!(l.coords_[i] <= r.coords_[i]))
return false;
return true;
}
template <typename Numeric, unsigned Dim>
bool operator>(const PointND<Numeric,Dim>& l,
const PointND<Numeric,Dim>& r)
{
for (unsigned i=0; i<Dim; ++i)
if (!(l.coords_[i] > r.coords_[i]))
return false;
return true;
}
template <typename Numeric, unsigned Dim>
bool operator>=(const PointND<Numeric,Dim>& l,
const PointND<Numeric,Dim>& r)
{
for (unsigned i=0; i<Dim; ++i)
if (!(l.coords_[i] >= r.coords_[i]))
return false;
return true;
}
template <typename Numeric, unsigned Dim>
std::ostream& operator<<(std::ostream& os,
const PointND<Numeric,Dim>& p)
{
os << '[';
for (unsigned i=0; i<Dim; ++i)
{
os << p.coords_[i];
if (i+1 != Dim)
os << ", ";
}
os << ']';
return os;
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Tue, Sep 30, 5:50 AM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6540407
Default Alt Text
PointND.icc (6 KB)
Attached To
Mode
rNPSTATSVN npstatsvn
Attached
Detach File
Event Timeline
Log In to Comment