vector.h
/*
Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer. Redistributions in binary form must reproduce
the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.
Neither the name of the Johns Hopkins University nor the names of its contributors
may be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*/
#ifndef __VECTOR_HPP
#define __VECTOR_HPP
#define Assert assert
#include <assert.h>
namespace pcl
{
namespace poisson
{
template<class T>
class Vector
{
public:
Vector();
Vector( const Vector<T>& V );
Vector( std::size_t N );
Vector( std::size_t N, T* pV );
~Vector();
const T& operator () (std::size_t i) const;
T& operator () (std::size_t i);
const T& operator [] (std::size_t i) const;
T& operator [] (std::size_t i);
void SetZero();
std::size_t Dimensions() const;
void Resize( std::size_t N );
Vector operator * (const T& A) const;
Vector operator / (const T& A) const;
Vector operator - (const Vector& V) const;
Vector operator + (const Vector& V) const;
Vector& operator *= (const T& A);
Vector& operator /= (const T& A);
Vector& operator += (const Vector& V);
Vector& operator -= (const Vector& V);
Vector& AddScaled(const Vector& V,const T& scale);
Vector& SubtractScaled(const Vector& V,const T& scale);
static void Add(const Vector& V1,const T& scale1,const Vector& V2,const T& scale2,Vector& Out);
static void Add(const Vector& V1,const T& scale1,const Vector& V2,Vector& Out);
Vector operator - () const;
Vector& operator = (const Vector& V);
T Dot( const Vector& V ) const;
T Length() const;
T Norm( std::size_t Ln ) const;
void Normalize();
bool write( FILE* fp ) const;
bool write( const char* fileName ) const;
bool read( FILE* fp );
bool read( const char* fileName );
T* m_pV;
protected:
std::size_t m_N;
};
template<class T,int Dim>
class NVector
{
public:
NVector();
NVector( const NVector& V );
NVector( std::size_t N );
NVector( std::size_t N, T* pV );
~NVector();
const T* operator () (std::size_t i) const;
T* operator () (std::size_t i);
const T* operator [] (std::size_t i) const;
T* operator [] (std::size_t i);
void SetZero();
std::size_t Dimensions() const;
void Resize( std::size_t N );
NVector operator * (const T& A) const;
NVector operator / (const T& A) const;
NVector operator - (const NVector& V) const;
NVector operator + (const NVector& V) const;
NVector& operator *= (const T& A);
NVector& operator /= (const T& A);
NVector& operator += (const NVector& V);
NVector& operator -= (const NVector& V);
NVector& AddScaled(const NVector& V,const T& scale);
NVector& SubtractScaled(const NVector& V,const T& scale);
static void Add(const NVector& V1,const T& scale1,const NVector& V2,const T& scale2,NVector& Out);
static void Add(const NVector& V1,const T& scale1,const NVector& V2, NVector& Out);
NVector operator - () const;
NVector& operator = (const NVector& V);
T Dot( const NVector& V ) const;
T Length() const;
T Norm( std::size_t Ln ) const;
void Normalize();
T* m_pV;
protected:
std::size_t m_N;
};
}
}
#include "vector.hpp"
#endif
pcl::poisson::NVector
Definition: vector.h:99
pcl::poisson::NVector::operator*
NVector operator*(const T &A) const
Definition: vector.hpp:360
pcl::poisson::NVector::Add
static void Add(const NVector &V1, const T &scale1, const NVector &V2, const T &scale2, NVector &Out)
Definition: vector.hpp:415
pcl::poisson::NVector::operator-=
NVector & operator-=(const NVector &V)
Definition: vector.hpp:452
pcl::poisson::NVector::operator[]
const T * operator[](std::size_t i) const
Definition: vector.hpp:350
pcl::poisson::NVector::AddScaled
NVector & AddScaled(const NVector &V, const T &scale)
Definition: vector.hpp:399
pcl::poisson::NVector::operator/=
NVector & operator/=(const T &A)
Definition: vector.hpp:383
pcl::poisson::NVector::operator-
NVector operator-() const
Definition: vector.hpp:442
pcl::poisson::NVector::Resize
void Resize(std::size_t N)
Definition: vector.hpp:309
pcl::poisson::NVector::Normalize
void Normalize()
Definition: vector.hpp:468
pcl::poisson::NVector::Dot
T Dot(const NVector &V) const
Definition: vector.hpp:483
pcl::poisson::NVector::m_N
std::size_t m_N
Definition: vector.h:145
pcl::poisson::NVector::operator()
const T * operator()(std::size_t i) const
Definition: vector.hpp:339
pcl::poisson::NVector::Dimensions
std::size_t Dimensions() const
Definition: vector.hpp:335
pcl::poisson::NVector::operator+
NVector operator+(const NVector &V) const
Definition: vector.hpp:390
pcl::poisson::NVector::Norm
T Norm(std::size_t Ln) const
Definition: vector.hpp:460
pcl::poisson::NVector::~NVector
~NVector()
Definition: vector.hpp:326
pcl::poisson::NVector::SubtractScaled
NVector & SubtractScaled(const NVector &V, const T &scale)
Definition: vector.hpp:407
pcl::poisson::NVector::m_pV
T * m_pV
Definition: vector.h:143
pcl::poisson::NVector::operator+=
NVector & operator+=(const NVector &V)
Definition: vector.hpp:425
pcl::poisson::NVector::SetZero
void SetZero()
Definition: vector.hpp:337
pcl::poisson::NVector::Length
T Length() const
Definition: vector.hpp:475
pcl::poisson::NVector::NVector
NVector()
Definition: vector.hpp:288
pcl::poisson::NVector::operator/
NVector operator/(const T &A) const
Definition: vector.hpp:375
pcl::poisson::NVector::operator=
NVector & operator=(const NVector &V)
Definition: vector.hpp:328
pcl::poisson::NVector::operator*=
NVector & operator*=(const T &A)
Definition: vector.hpp:368
pcl::poisson::Vector
Definition: vector.h:42
pcl::poisson::Vector::operator()
const T & operator()(std::size_t i) const
Definition: vector.hpp:95
pcl::poisson::Vector::operator+
Vector operator+(const Vector &V) const
Definition: vector.hpp:146
pcl::poisson::Vector::SubtractScaled
Vector & SubtractScaled(const Vector &V, const T &scale)
Definition: vector.hpp:163
pcl::poisson::Vector::AddScaled
Vector & AddScaled(const Vector &V, const T &scale)
Definition: vector.hpp:155
pcl::poisson::Vector::Norm
T Norm(std::size_t Ln) const
Definition: vector.hpp:216
pcl::poisson::Vector::operator/=
Vector & operator/=(const T &A)
Definition: vector.hpp:139
pcl::poisson::Vector::read
bool read(FILE *fp)
Definition: vector.hpp:267
pcl::poisson::Vector::Normalize
void Normalize()
Definition: vector.hpp:224
pcl::poisson::Vector::operator+=
Vector & operator+=(const Vector &V)
Definition: vector.hpp:181
pcl::poisson::Vector::operator*
Vector operator*(const T &A) const
Definition: vector.hpp:116
pcl::poisson::Vector::Add
static void Add(const Vector &V1, const T &scale1, const Vector &V2, const T &scale2, Vector &Out)
Definition: vector.hpp:171
pcl::poisson::Vector::m_N
std::size_t m_N
Definition: vector.h:93
pcl::poisson::Vector::m_pV
T * m_pV
Definition: vector.h:91
pcl::poisson::Vector::Dimensions
std::size_t Dimensions() const
Definition: vector.hpp:91
pcl::poisson::Vector::Resize
void Resize(std::size_t N)
Definition: vector.hpp:63
pcl::poisson::Vector::operator[]
const T & operator[](std::size_t i) const
Definition: vector.hpp:106
pcl::poisson::Vector::SetZero
void SetZero()
Definition: vector.hpp:93
pcl::poisson::Vector::operator=
Vector & operator=(const Vector &V)
Definition: vector.hpp:84
pcl::poisson::Vector::~Vector
~Vector()
Definition: vector.hpp:82
pcl::poisson::Vector::Length
T Length() const
Definition: vector.hpp:231
pcl::poisson::Vector::write
bool write(FILE *fp) const
Definition: vector.hpp:276
pcl::poisson::Vector::operator-=
Vector & operator-=(const Vector &V)
Definition: vector.hpp:208
pcl::poisson::Vector::operator/
Vector operator/(const T &A) const
Definition: vector.hpp:131
pcl::poisson::Vector::operator-
Vector operator-() const
Definition: vector.hpp:198
pcl::poisson::Vector::operator*=
Vector & operator*=(const T &A)
Definition: vector.hpp:124
pcl::poisson::Vector::Vector
Vector()
Definition: vector.hpp:42
pcl::poisson::Vector::Dot
T Dot(const Vector &V) const
Definition: vector.hpp:239
pcl
Definition: convolution.h:46