Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

matvec::Vector< T > Class Template Reference

#include <vector.h>

List of all members.


Detailed Description

template<class T>
class matvec::Vector< T >

A class template for one-dimensional array. Vector is also a container. For example:

matvec::Vector<int> a(5);

See also:
Matrix

Definition at line 47 of file vector.h.

Public Types

typedef int size_type
typedef T value_type
typedef T element_type
typedef T * pointer
typedef T * iterator
typedef T & reference
typedef const T * const_iterator
typedef const T * const_pointer
typedef const T & const_reference
typedef std::reverse_iterator<
iterator
reverse_iterator
typedef std::reverse_iterator<
const_iterator
const_reverse_iterator

Public Methods

 Vector (void)
 Constructs an empty vector of type T.

 Vector (const size_type n)
 Constructs a vector of size n with each element being T().

 Vector (const size_type n, const T *a)
 Constructs a vector of size n initialized by *a.

 Vector (const Vector &a)
 Copy constructor.

iterator begin (void)
 returns a random access iterator for the first element.

iterator end ()
 returns a random access iterator for the position after the last element.

iterator begin (void) const
iterator end (void) const
reverse_iterator rbegin (void)
 returns a reverse iterator for the first element of a reverse iteration.

reverse_iterator rend (void)
 returns a reverse iterator for the position after the last element of a reverse iteration.

const reverse_iterator rbegin (void) const
const reverse_iterator rend (void) const
virtual ~Vector (void)
 Destructs a vector.

void copy (const Vector &a)
Vector & assign (const Vector &a)
Vector & assign (const T &x)
Vector & resize (const size_type n, const T &val=T())
Vector & resize (const size_type n, const T *a)
Vector & resize (const Vector &a)
Vector & reserve (const size_type n)
Vector & operator= (const Vector &a)
Vector & operator= (const T &x)
Vector operator+ (const Vector &a) const
Vector operator- (const Vector &a) const
Vector operator * (const Vector &a) const
Vector operator/ (const Vector &a) const
Vector operator+ (const T &x) const
Vector operator- (const T &x) const
Vector operator * (const T &x) const
Vector operator/ (const T &x) const
Vector & operator+= (const Vector &a)
Vector & operator-= (const Vector &a)
Vector & operator *= (const Vector &a)
Vector & operator/= (const Vector &a)
Vector & operator+= (const T &x)
Vector & operator-= (const T &x)
Vector & operator *= (const T &x)
Vector & operator/= (const T &x)
T & operator[] (const size_type i)
const T & operator[] (const size_type i) const
T & operator() (const size_type i)
Vector operator- (void) const
Vector & operator+ (void)
Vector< bool > operator! (void) const
Vector< bool > operator== (const Vector &a) const
Vector< bool > operator< (const Vector &a) const
Vector< bool > operator> (const Vector &a) const
Vector< bool > operator!= (const Vector &a) const
Vector< bool > operator<= (const Vector &a) const
Vector< bool > operator>= (const Vector &a) const
Vector< bool > operator== (const T &x) const
Vector< bool > operator< (const T &x) const
Vector< bool > operator> (const T &x) const
Vector< bool > operator!= (const T &x) const
Vector< bool > operator<= (const T &x) const
Vector< bool > operator>= (const T &x) const
bool all (void) const
bool any (void) const
bool empty (void) const
Vector apply (T(*f)(const T &)) const
Vector apply (T(*f)(const T &, const T &), const Vector &b) const
Vector apply (T(*f)(const T &, const T &), const T &b) const
Vector apply (T(*f)(T)) const
Vector apply (T(*f)(T, T), const Vector &b) const
Vector apply (T(*f)(T, T), const T &b) const
Vector & append (const T &x)
Vector & append (const Vector &a)
Vector & sort (void)
sum (T init=T()) const
inner_product (const T *b, T init=T()) const
inner_product (const Vector &b, T init=T()) const
inner_product (T init=T()) const
sumsq (T init=T()) const
variance (T init=T()) const
Vector subvec (const size_type idx=0, const unsigned len=0) const
Vector subvec (const Vector< bool > &v) const
Vector find (const Vector< bool > &v) const
int find (const T &x) const
max (void) const
min (void) const
std::ostream & print (std::ostream &os=std::cout) const
T & at (const size_type i)
T & front (void)
const T & front (void) const
T & back ()
const T & back () const
int size (void) const
void clear (void)
void input (const std::string &fname, const size_type n)
bool save (const std::string &fname, const int io_mode=std::ios::out) const
void initialize (size_type n, const T *a)

Protected Attributes

T * ve
 it store the pointer to the memory allocated for ne element.

int ne
 it stores the number of elements.


Related Functions

(Note that these are not member functions.)

Vector< T > sin (const Vector< T > &a)
Vector< T > asin (const Vector< T > &a)
Vector< T > cos (const Vector< T > &a)
Vector< T > acos (const Vector< T > &a)
Vector< T > tan (const Vector< T > &a)
Vector< T > atan (const Vector< T > &a)
Vector< T > ceil (const Vector< T > &a)
Vector< T > floor (const Vector< T > &a)
Vector< T > log (const Vector< T > &a)
Vector< T > log10 (const Vector< T > &a)
Vector< T > exp (const Vector< T > &a)
Vector< T > sqrt (const Vector< T > &a)
Vector< T > abs (const Vector< T > &a)
Vector< T > erf (const Vector< T > &a)
Vector< T > erfc (const Vector< T > &a)
bool all (const Vector< T > &a)
bool any (const Vector< T > &a)
Vector< T > operator+ (const T &a, const Vector< T > &b)
Vector< T > operator- (const T &a, const Vector< T > &b)
Vector< T > operator * (const T &a, const Vector< T > &b)
Vector< T > operator/ (const T &a, const Vector< T > &b)
std::ostream & operator<< (std::ostream &os, const Vector< T > &a)


Member Typedef Documentation

template<class T>
typedef const T* matvec::Vector< T >::const_iterator
 

Definition at line 56 of file vector.h.

template<class T>
typedef const T* matvec::Vector< T >::const_pointer
 

Definition at line 57 of file vector.h.

template<class T>
typedef const T& matvec::Vector< T >::const_reference
 

Definition at line 58 of file vector.h.

template<class T>
typedef std::reverse_iterator<const_iterator> matvec::Vector< T >::const_reverse_iterator
 

Definition at line 60 of file vector.h.

Referenced by matvec::Vector< Vector< Sym2x2 > >::rbegin(), and matvec::Vector< Vector< Sym2x2 > >::rend().

template<class T>
typedef T matvec::Vector< T >::element_type
 

Definition at line 52 of file vector.h.

template<class T>
typedef T* matvec::Vector< T >::iterator
 

Definition at line 54 of file vector.h.

Referenced by matvec::Vector< T >::all(), matvec::Vector< T >::any(), matvec::Vector< T >::apply(), matvec::Vector< Vector< Sym2x2 > >::begin(), matvec::Vector< Vector< Sym2x2 > >::end(), matvec::Vector< T >::inner_product(), matvec::Vector< T >::operator *(), matvec::Vector< T >::operator *=(), matvec::Vector< T >::operator+(), matvec::Vector< T >::operator+=(), matvec::Vector< T >::operator-(), matvec::Vector< T >::operator-=(), matvec::Vector< T >::operator/(), matvec::Vector< T >::operator/=(), matvec::Vector< T >::operator<(), matvec::Vector< T >::operator==(), matvec::Vector< T >::operator>(), and matvec::Vector< T >::resize().

template<class T>
typedef T* matvec::Vector< T >::pointer
 

Definition at line 53 of file vector.h.

template<class T>
typedef T& matvec::Vector< T >::reference
 

Definition at line 55 of file vector.h.

template<class T>
typedef std::reverse_iterator<iterator> matvec::Vector< T >::reverse_iterator
 

Definition at line 59 of file vector.h.

Referenced by matvec::Vector< Vector< Sym2x2 > >::rbegin(), and matvec::Vector< Vector< Sym2x2 > >::rend().

template<class T>
typedef int matvec::Vector< T >::size_type
 

Definition at line 50 of file vector.h.

Referenced by matvec::Vector< Vector< Sym2x2 > >::operator[](), and matvec::Vector< Vector< Sym2x2 > >::Vector().

template<class T>
typedef T matvec::Vector< T >::value_type
 

Definition at line 51 of file vector.h.


Constructor & Destructor Documentation

template<class T>
matvec::Vector< T >::Vector void    [inline]
 

Constructs an empty vector of type T.

Definition at line 62 of file vector.h.

template<class T>
matvec::Vector< T >::Vector const size_type    n [inline, explicit]
 

Constructs a vector of size n with each element being T().

Definition at line 63 of file vector.h.

template<class T>
matvec::Vector< T >::Vector const size_type    n,
const T *    a
[inline]
 

Constructs a vector of size n initialized by *a.

Definition at line 64 of file vector.h.

template<class T>
matvec::Vector< T >::Vector const Vector< T > &    a [inline]
 

Copy constructor.

Definition at line 65 of file vector.h.

template<class T>
virtual matvec::Vector< T >::~Vector void    [inline, virtual]
 

Destructs a vector.

Definition at line 76 of file vector.h.


Member Function Documentation

template<class T>
bool matvec::Vector< T >::all void    const [inline]
 

Definition at line 644 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ve.

Referenced by matvec::Vector< T >::all().

00645 {
00646    if (!ve) return false;
00647    iterator it = begin(), endit = end();
00648    while (it != endit) if (*it++ == false) return false;
00649    return true;
00650 }

template<class T>
bool matvec::Vector< T >::any void    const [inline]
 

Definition at line 652 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ve.

Referenced by matvec::Vector< T >::any().

00653 {
00654    if (!ve) return false;
00655    iterator it = begin(), endit = end();
00656    while (it != endit) if (*it++ == true) return true;
00657    return false;
00658 }

template<class T>
Vector< T > & matvec::Vector< T >::append const Vector< T > &    a [inline]
 

Definition at line 634 of file vector.h.

References matvec::Vector< T >::ne, matvec::Vector< T >::reserve(), and matvec::Vector< T >::ve.

00635 {
00636    Vector<T> temp(ne,ve);
00637    int i,n = ne;
00638    reserve(n + a.ne);
00639    for (i=0; i<n; ++i) ve[i] = temp[i];
00640    for (i=n; i<ne; ++i) ve[i] = a[i];
00641    return *this;
00642 }

template<class T>
Vector< T > & matvec::Vector< T >::append const T &    x [inline]
 

Definition at line 625 of file vector.h.

References matvec::Vector< T >::ne, matvec::Vector< T >::reserve(), and matvec::Vector< T >::ve.

00626 {
00627    Vector<T> temp(ne,ve);
00628    reserve(ne+1);
00629    for (int i=0; i<ne; ++i) ve[i] = temp[i];
00630    temp[ne] = x;
00631    return *this;
00632 }

template<class T>
Vector< T > matvec::Vector< T >::apply T(*    f)(T, T),
const T &    b
const [inline]
 

Definition at line 617 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00618 {
00619    Vector<T> temp(ne);
00620    iterator it = begin(), endit = end(),t_it = temp.begin();
00621    while (it != endit) *t_it++ = (*f)(*it++,a);
00622    return temp;
00623 }

template<class T>
Vector< T > matvec::Vector< T >::apply T(*    f)(T, T),
const Vector< T > &    b
const [inline]
 

Definition at line 608 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, matvec::Vector< T >::ne, and matvec::Vector< T >::size().

00609 {
00610    assert(ne == a.size());
00611    Vector<T> temp(ne);
00612    iterator it = begin(), endit = end(),t_it = temp.begin(),a_it = a.begin();
00613    while (it != endit) *t_it++ = (*f)(*it++,*a_it++);
00614    return temp;
00615 }

template<class T>
Vector< T > matvec::Vector< T >::apply T(*    f)(T) const [inline]
 

Definition at line 600 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00601 {
00602    Vector<T> temp(ne);
00603    iterator it = begin(), endit = end(),t_it = temp.begin();
00604    while (it != endit) *t_it++ = (*f)(*it++);
00605    return temp;
00606 }

template<class T>
Vector< T > matvec::Vector< T >::apply T(*    f)(const T &, const T &),
const T &    b
const [inline]
 

Definition at line 592 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00593 {
00594    Vector<T> temp(ne);
00595    iterator it = begin(), endit = end(),t_it = temp.begin(),a_it = a.begin();
00596    while (it != endit) *t_it++ = (*f)(*it++,a);
00597    return temp;
00598 }

template<class T>
Vector< T > matvec::Vector< T >::apply T(*    f)(const T &, const T &),
const Vector< T > &    b
const [inline]
 

Definition at line 583 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, matvec::Vector< T >::ne, and matvec::Vector< T >::size().

00584 {
00585    assert(ne == a.size());
00586    Vector<T> temp(ne);
00587    iterator it = begin(), endit = end(),t_it = temp.begin(),a_it = a.begin();
00588    while (it != endit) *t_it++ = (*f)(*it++,*a_it++);
00589    return temp;
00590 }

template<class T>
Vector< T > matvec::Vector< T >::apply T(*    f)(const T &) const [inline]
 

Definition at line 575 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

Referenced by matvec::Vector< T >::abs(), matvec::Vector< T >::acos(), matvec::Vector< T >::asin(), matvec::Vector< T >::atan(), matvec::Vector< T >::ceil(), matvec::Vector< T >::cos(), matvec::Vector< T >::erf(), matvec::Vector< T >::erfc(), matvec::Vector< T >::exp(), matvec::Vector< T >::floor(), matvec::Vector< T >::log(), matvec::Vector< T >::log10(), matvec::Vector< T >::sin(), matvec::Vector< T >::sqrt(), and matvec::Vector< T >::tan().

00576 {
00577    Vector<T> temp(ne);
00578    iterator it = begin(), endit = end(),t_it = temp.begin();
00579    while (it != endit) *t_it++ = (*f)(*it++);
00580    return temp;
00581 }

template<class T>
Vector< T > & matvec::Vector< T >::assign const T &    x [inline]
 

Definition at line 284 of file vector.h.

References matvec::Vector< T >::ne, and matvec::Vector< T >::resize().

00285 {
00286    if (ve) {
00287       resize(ne,a);
00288    }
00289    else {
00290       resize(1,a);
00291    }
00292    return *this;
00293 }

template<class T>
Vector< T > & matvec::Vector< T >::assign const Vector< T > &    a [inline]
 

Definition at line 278 of file vector.h.

References matvec::Vector< T >::copy().

Referenced by matvec::Model::genotypic_value_gibbs(), matvec::Model::get_lms_kp(), matvec::doubleMatrix::inv(), matvec::BGMatrix::inv(), matvec::Vector< Vector< Sym2x2 > >::operator=(), matvec::Model::sampleW(), matvec::Model::setup_ww_single_trait(), matvec::GLMM::SSQCP(), and matvec::Model::vce_gibbs().

00279 {
00280    copy(a);
00281    return *this;
00282 }

template<class T>
T & matvec::Vector< T >::at const size_type    i [inline]
 

It returns a reference to element i with range-cheching. Note that element index starting from 0.

Definition at line 202 of file vector.h.

References matvec::Vector< T >::ne, and matvec::Vector< T >::ve.

00203 {
00204    if (i < 0 || i >= ne) throw exception("Vector<T>::at(i): out of range");
00205    return ve[i];
00206 }

template<class T>
const T& matvec::Vector< T >::back   const [inline]
 

Definition at line 160 of file vector.h.

00160 { return *(end() - 1); }

template<class T>
T& matvec::Vector< T >::back   [inline]
 

Definition at line 159 of file vector.h.

00159 { return *(end() - 1); }

template<class T>
iterator matvec::Vector< T >::begin void    const [inline]
 

Definition at line 69 of file vector.h.

00069 { return ve; }

template<class T>
iterator matvec::Vector< T >::begin void    [inline]
 

returns a random access iterator for the first element.

Definition at line 67 of file vector.h.

Referenced by matvec::Model::add_Ag(), matvec::Model::add_Ig(), matvec::GLMM::AI_REML(), matvec::Vector< T >::all(), matvec::Vector< T >::any(), matvec::Vector< T >::apply(), matvec::Model::blup_pccg(), matvec::GLMM::build_hInv(), matvec::doubleMatrix::cond(), matvec::Population::cond_genotype_config(), matvec::Model::contrast(), matvec::GLMM::contrast(), matvec::Model::CovMat(), matvec::NuFamily::cutting(), matvec::doubleMatrix::det(), matvec::BGMatrix::det(), matvec::Population::display(), matvec::doubleMatrix::eigen(), matvec::Model::estimate(), matvec::SparseMatrix::factor(), matvec::SparseBGMatrix::factor(), matvec::Vector< T >::find(), matvec::Vector< Vector< Sym2x2 > >::front(), matvec::Population::genotype_config(), matvec::Model::genotype_dist_gibbs(), matvec::Population::genotype_dist_peeling(), matvec::Model::genotypic_value_cat(), matvec::Model::genotypic_value_gibbs(), matvec::Model::get_lms_kp(), matvec::Population::gibbs_iterate(), matvec::doubleMatrix::ginv0(), matvec::GLMM::glim(), matvec::Vector< T >::inner_product(), matvec::Vector< Vector< Sym2x2 > >::inner_product(), matvec::Pedigree::input(), matvec::doubleMatrix::inv(), matvec::BGMatrix::inv(), matvec::Population::llhood_phenotype(), matvec::doubleMatrix::lu_solve(), matvec::BGMatrix::lu_solve(), matvec::Vector< Vector< Sym2x2 > >::max(), matvec::Population::maxant_maxpost(), matvec::Population::maxant_maxpost_old(), matvec::Vector< Vector< Sym2x2 > >::min(), matvec::Model::mme_times(), matvec::SparseMatrix::mv(), matvec::SparseBGMatrix::mv(), matvec::doubleMatrix::norm(), matvec::nr_powell(), matvec::Vector< T >::operator *(), matvec::operator *(), matvec::Vector< T >::operator *=(), matvec::Vector< T >::operator+(), matvec::Vector< T >::operator+=(), matvec::Vector< T >::operator-(), matvec::Vector< T >::operator-=(), matvec::Vector< T >::operator/(), matvec::Vector< T >::operator/=(), matvec::Vector< T >::operator<(), matvec::Vector< T >::operator==(), matvec::Vector< T >::operator>(), matvec::Model::out_lsmeans_to_stream(), matvec::Minimizer::praxis(), matvec::NuFamily::pretend_missing(), matvec::SparseMatrix::q(), matvec::SparseBGMatrix::q(), matvec::SparseMatrix::qTLW(), matvec::SparseBGMatrix::qTLW(), matvec::doubleMatrix::rank(), matvec::Vector< Vector< Sym2x2 > >::rend(), matvec::Vector< T >::resize(), matvec::SparseMatrix::row(), matvec::SparseBGMatrix::row(), matvec::GeometricDist::sample(), matvec::PoissonDist::sample(), matvec::UniformDist::sample(), matvec::Pedigree::sample(), matvec::Model::sampleW(), matvec::Model::setup_ww(), matvec::GLMM::setup_ww(), matvec::SparseMatrix::solv(), matvec::SparseBGMatrix::solv(), matvec::SparseMatrix::solve(), matvec::SparseBGMatrix::solve(), matvec::SparseMatrix::solvrow(), matvec::SparseBGMatrix::solvrow(), matvec::Vector< Vector< Sym2x2 > >::sort(), matvec::GLMM::SSQCP(), matvec::Vector< T >::subvec(), matvec::Vector< Vector< Sym2x2 > >::sum(), matvec::doubleMatrix::svd(), matvec::Model::uAu_trCA(), and matvec::Model::vce_gibbs_sampler().

template<class T>
void matvec::Vector< T >::clear void    [inline]
 

Definition at line 163 of file vector.h.

Referenced by matvec::Model::blup_pccg(), matvec::Model::prepare_data(), matvec::Vector< T >::reserve(), matvec::Vector< T >::resize(), and matvec::Vector< Vector< Sym2x2 > >::~Vector().

00163                                 { ///< Releases memory.
00164                       if (ne > 0) {
00165                         delete [] ve; 
00166                         ne = 0; 
00167                         ve = 0;
00168                       } 
00169                     } 

template<class T>
void matvec::Vector< T >::copy const Vector< T > &    a [inline]
 

Definition at line 266 of file vector.h.

References matvec::Vector< T >::ne, matvec::Vector< T >::reserve(), and matvec::Vector< T >::ve.

Referenced by matvec::Vector< T >::assign().

00267 {
00268    if (this == &a) return;
00269    reserve(a.ne);
00270    // memcpy did not work correctly for the BG class (RLF)
00271    //memcpy(ve,a.ve,sizeof(T)*ne);
00272    for (unsigned i=0;i<ne;i++){
00273      ve[i] = a.ve[i];
00274    }
00275    return;
00276 }

template<class T>
bool matvec::Vector< T >::empty void    const [inline]
 

Definition at line 133 of file vector.h.

Referenced by matvec::Model::vce_emreml_multi_trait().

00133 { return ne == 0;}

template<class T>
iterator matvec::Vector< T >::end void    const [inline]
 

Definition at line 70 of file vector.h.

00070 { if (ve) return ve + ne; else return 0; }

template<class T>
iterator matvec::Vector< T >::end   [inline]
 

returns a random access iterator for the position after the last element.

Definition at line 68 of file vector.h.

Referenced by matvec::Vector< T >::all(), matvec::Vector< T >::any(), matvec::Vector< T >::apply(), matvec::Vector< Vector< Sym2x2 > >::back(), matvec::Vector< T >::find(), matvec::Vector< T >::inner_product(), matvec::Vector< Vector< Sym2x2 > >::max(), matvec::Vector< Vector< Sym2x2 > >::min(), matvec::Vector< T >::operator *(), matvec::Vector< T >::operator *=(), matvec::Vector< T >::operator+(), matvec::Vector< T >::operator+=(), matvec::Vector< T >::operator-(), matvec::Vector< T >::operator-=(), matvec::Vector< T >::operator/(), matvec::Vector< T >::operator/=(), matvec::Vector< T >::operator<(), matvec::Vector< T >::operator==(), matvec::Vector< T >::operator>(), matvec::Vector< Vector< Sym2x2 > >::rbegin(), matvec::Vector< T >::resize(), matvec::GeometricDist::sample(), matvec::PoissonDist::sample(), matvec::UniformDist::sample(), matvec::Vector< Vector< Sym2x2 > >::sort(), and matvec::Vector< Vector< Sym2x2 > >::sum().

template<class T>
int matvec::Vector< T >::find const T &    x const [inline]
 

Definition at line 701 of file vector.h.

References matvec::Vector< T >::ne, and matvec::Vector< T >::ve.

00702 {
00703    int i = -1;
00704    for (i=0; i<ne; ++i) {
00705       if (ve[i] == x) break;
00706    }
00707    if (i == ne) i = -1;
00708    return i;
00709 }

template<class T>
Vector< T > matvec::Vector< T >::find const Vector< bool > &    v const [inline]
 

Definition at line 711 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::ne, matvec::Vector< T >::size(), and matvec::Vector< T >::ve.

Referenced by matvec::Data::input().

00712 {
00713    assert (ne == a.size() );
00714    int n = 0;
00715    bool *bot = a.begin(), *top = a.end();
00716    while (bot < top) if (*bot++) n++;
00717    Vector<T> temp(n);
00718    n = 0;
00719    bot = a.begin();
00720    T *pt = ve;
00721    while (bot < top) {
00722       if (*bot++) temp[n++] = *pt;
00723       pt++;
00724    }
00725    return temp;
00726 }

template<class T>
const T& matvec::Vector< T >::front void    const [inline]
 

Definition at line 158 of file vector.h.

00158 { return *begin(); }

template<class T>
T& matvec::Vector< T >::front void    [inline]
 

Definition at line 157 of file vector.h.

00157 { return *begin(); }

template<class T>
void matvec::Vector< T >::initialize size_type    n,
const T *    a
[inline]
 

A private member used by constructors.

Definition at line 181 of file vector.h.

References matvec::check_ptr(), matvec::Vector< T >::ne, and matvec::Vector< T >::ve.

Referenced by matvec::Model::hashxact(), and matvec::Vector< Vector< Sym2x2 > >::Vector().

00182 {
00183    if (n == 0) {
00184       ne = 0; ve = 0;
00185    } else {
00186       ne = n;
00187       ve = new T [ne];
00188       check_ptr(ve);
00189       T *bot = ve, *top = ve + ne;
00190       if (a) {
00191          while (bot < top) *bot++ = *a++;
00192       } else {
00193          while (bot < top) *bot++ = T();
00194       }
00195    }
00196 }

template<class T>
T matvec::Vector< T >::inner_product   init = T() const [inline]
 

Definition at line 146 of file vector.h.

00146 { return inner_product(this->begin(),init); }

template<class T>
T matvec::Vector< T >::inner_product const Vector< T > &    b,
  init = T()
const [inline]
 

Definition at line 145 of file vector.h.

00145 {return inner_product(b.begin(),init);}

template<class T>
T matvec::Vector< T >::inner_product const T *    b,
  init = T()
const [inline]
 

Definition at line 660 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), and matvec::Vector< T >::iterator.

Referenced by matvec::Model::blup_pccg(), matvec::Vector< Vector< Sym2x2 > >::inner_product(), matvec::Vector< Vector< Sym2x2 > >::sumsq(), matvec::Vector< T >::variance(), matvec::Model::vce_emreml_multi_trait(), and matvec::Model::vce_gibbs_sampler().

00661 {
00662    iterator it = begin(), endit = end();
00663    while (it != endit) init = init + (*it++ * *b++);
00664    return init;
00665 }

template<class T>
void matvec::Vector< T >::input const std::string &    fname,
const size_type    n
[inline]
 

Input data from an external text file.

Parameters:
fname  Filename
n  number of elements you want to read
See also:
save()

Definition at line 224 of file vector.h.

References matvec::Vector< T >::reserve(), and matvec::Vector< T >::ve.

00225 {
00226    reserve(n);
00227    std::ifstream infile(fname.c_str(),std::ios::in);//SDK | std::ios::nocreate);
00228    if (!infile) throw exception("Vector<T>::input(): cannot open file");
00229    int i = 0;
00230    while (!infile.eof()) {
00231       if (i >= n) break;
00232       infile >> ve[i++];
00233    }
00234    infile.close();
00235    return;
00236 }

template<class T>
T matvec::Vector< T >::max void    const [inline]
 

Definition at line 153 of file vector.h.

Referenced by matvec::GLMM::AI_REML(), matvec::GLMM::Build_SinMat(), matvec::doubleMatrix::cond(), matvec::doubleMatrix::ginv0(), matvec::doubleMatrix::mat_exp(), matvec::doubleMatrix::mat_exp_der(), matvec::doubleMatrix::mat_log(), matvec::Data::max(), matvec::Population::maxant_maxpost(), matvec::Population::maxant_maxpost_old(), matvec::doubleMatrix::norm(), and matvec::Pedigree::renum().

00153 { return *(std::max_element(begin(),end())); }

template<class T>
T matvec::Vector< T >::min void    const [inline]
 

Definition at line 154 of file vector.h.

Referenced by matvec::doubleMatrix::cond(), matvec::doubleMatrix::mat_exp(), matvec::doubleMatrix::mat_exp_der(), matvec::doubleMatrix::mat_log(), and matvec::Data::min().

00154 { return *(std::min_element(begin(),end())); }

template<class T>
Vector< T > matvec::Vector< T >::operator * const T &    x const [inline]
 

Definition at line 542 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00543 {
00544    Vector<T> temp(ne);
00545    iterator it = begin(), endit = end(),t_it = temp.begin();
00546    while (it != endit) *t_it++ = *it++ * a;
00547    return temp;
00548 }

template<class T>
Vector< T > matvec::Vector< T >::operator * const Vector< T > &    a const [inline]
 

Definition at line 508 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00509 {
00510    assert ( ne == a.ne );
00511    Vector<T> temp(ne);
00512    iterator it = begin(), endit = end(), a_it = a.begin(),t_it = temp.begin();
00513    while (it != endit) *t_it++ = *it++ * *a_it++;
00514    return temp;
00515 }

template<class T>
Vector< T > & matvec::Vector< T >::operator *= const T &    x [inline]
 

Definition at line 399 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), and matvec::Vector< T >::iterator.

00400 {
00401    iterator it = begin(), endit = end();
00402    while (it != endit) *it++ *= s;
00403    return *this;
00404 }

template<class T>
Vector< T > & matvec::Vector< T >::operator *= const Vector< T > &    a [inline]
 

Definition at line 369 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00370 {
00371    assert( ne == a.ne );
00372    iterator it = begin(), endit = end(), a_it = a.begin();
00373    while (it != endit) *it++ *= *a_it++;
00374    return *this;
00375 }

template<class T>
Vector< bool > matvec::Vector< T >::operator! void    const [inline]
 

Definition at line 567 of file vector.h.

00568 {
00569    Vector<bool> temp(ne);
00570    if (ne == 0) return temp;
00571    for (int i=0; i<ne; ++i) temp[i] = !ve[i];
00572    return temp;
00573 }

template<class T>
Vector< bool > matvec::Vector< T >::operator!= const T &    x const [inline]
 

Definition at line 473 of file vector.h.

00474 { return !(*this == x); }

template<class T>
Vector< bool > matvec::Vector< T >::operator!= const Vector< T > &    a const [inline]
 

Definition at line 470 of file vector.h.

00471 { return !(*this == a); }

template<class T>
T & matvec::Vector< T >::operator() const size_type    i [inline]
 

It returns a reference to element i with range-cheching. Note that element index starting from 1.

Definition at line 212 of file vector.h.

References matvec::Vector< T >::ne, and matvec::Vector< T >::ve.

00213 {
00214    if (i <= 0 || i > ne) throw exception("Vector<T>::operator(): out of range");
00215    return ve[i-1];
00216 }

template<class T>
Vector& matvec::Vector< T >::operator+ void    [inline]
 

Definition at line 113 of file vector.h.

00113 {return *this;}

template<class T>
Vector< T > matvec::Vector< T >::operator+ const T &    x const [inline]
 

Definition at line 526 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00527 {
00528    Vector<T> temp(ne);
00529    iterator it = begin(), endit = end(),t_it = temp.begin();
00530    while (it != endit) *t_it++ = *it++ + a;
00531    return temp;
00532 }

template<class T>
Vector< T > matvec::Vector< T >::operator+ const Vector< T > &    a const [inline]
 

Definition at line 489 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00490 {
00491    assert ( ne == a.ne );
00492    Vector<T> temp(ne);
00493    iterator it = begin(), endit = end(), a_it = a.begin(),t_it = temp.begin();
00494    while (it != endit) *t_it++ = *it++ + *a_it++;
00495    return temp;
00496 }

template<class T>
Vector< T > & matvec::Vector< T >::operator+= const T &    x [inline]
 

Definition at line 385 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), and matvec::Vector< T >::iterator.

00386 {
00387    iterator it = begin(), endit = end();
00388    while (it != endit) *it++ += s;
00389    return *this;
00390 }

template<class T>
Vector< T > & matvec::Vector< T >::operator+= const Vector< T > &    a [inline]
 

Definition at line 353 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00354 {
00355    assert( ne == a.ne );
00356    iterator it = begin(), endit = end(), a_it = a.begin();
00357    while (it != endit) *it++ += *a_it++;
00358    return *this;
00359 }

template<class T>
Vector< T > matvec::Vector< T >::operator- void    const [inline]
 

Definition at line 558 of file vector.h.

References matvec::Vector< T >::begin().

00559 {
00560    if (ne == 0) return *this;
00561    Vector<T> temp(ne);
00562    iterator it = begin(), endit = end(),t_it = temp.begin();
00563    while (it != endit) *t_it++ = - *it++;
00564    return temp;
00565 }

template<class T>
Vector< T > matvec::Vector< T >::operator- const T &    x const [inline]
 

Definition at line 534 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00535 {
00536    Vector<T> temp(ne);
00537    iterator it = begin(), endit = end(),t_it = temp.begin();
00538    while (it != endit) *t_it++ = *it++ - a;
00539    return temp;
00540 }

template<class T>
Vector< T > matvec::Vector< T >::operator- const Vector< T > &    a const [inline]
 

Definition at line 498 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00499 {
00500    assert ( ne == a.ne );
00501    Vector<T> temp(ne);
00502    iterator it = begin(), endit = end(), a_it = a.begin(),t_it = temp.begin();
00503    while (it != endit) *t_it++ = *it++ - *a_it++;
00504    return temp;
00505 }

template<class T>
Vector< T > & matvec::Vector< T >::operator-= const T &    x [inline]
 

Definition at line 392 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), and matvec::Vector< T >::iterator.

00393 {
00394    iterator it = begin(), endit = end();
00395    while (it != endit) *it++ -= s;
00396    return *this;
00397 }

template<class T>
Vector< T > & matvec::Vector< T >::operator-= const Vector< T > &    a [inline]
 

Definition at line 361 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00362 {
00363    assert( ne == a.ne );
00364    iterator it = begin(), endit = end(), a_it = a.begin();
00365    while (it != endit) *it++ -= *a_it++;
00366    return *this;
00367 }

template<class T>
Vector< T > matvec::Vector< T >::operator/ const T &    x const [inline]
 

Definition at line 550 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00551 {
00552    Vector<T> temp(ne);
00553    iterator it = begin(), endit = end(),t_it = temp.begin();
00554    while (it != endit) *t_it++ = *it++ / a;
00555    return temp;
00556 }

template<class T>
Vector< T > matvec::Vector< T >::operator/ const Vector< T > &    a const [inline]
 

Definition at line 517 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00518 {
00519    assert ( ne == a.ne );
00520    Vector<T> temp(ne);
00521    iterator it = begin(), endit = end(), a_it = a.begin(),t_it = temp.begin();
00522    while (it != endit) *t_it++ = *it++ / *a_it++;
00523    return temp;
00524 }

template<class T>
Vector< T > & matvec::Vector< T >::operator/= const T &    x [inline]
 

Definition at line 406 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), and matvec::Vector< T >::iterator.

00407 {
00408    iterator it = begin(), endit = end();
00409    while (it != endit) *it++ /= s;
00410    return *this;
00411 }

template<class T>
Vector< T > & matvec::Vector< T >::operator/= const Vector< T > &    a [inline]
 

Definition at line 377 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00378 {
00379    assert( ne == a.ne );
00380    iterator it = begin(), endit = end(), a_it = a.begin();
00381    while (it != endit) *it++ /= *a_it++;
00382    return *this;
00383 }

template<class T>
Vector< bool > matvec::Vector< T >::operator< const T &    x const [inline]
 

Definition at line 442 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00443 {
00444    Vector<bool> temp(ne);
00445    iterator it = begin(), endit = end();
00446    bool *t_it = temp.begin();
00447    while (it != endit) *t_it++ = *it++ < x;
00448    return temp;
00449 }

template<class T>
Vector< bool > matvec::Vector< T >::operator< const Vector< T > &    a const [inline]
 

Definition at line 432 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00433 {
00434    assert (ne == a.ne );
00435    Vector<bool> temp(ne);
00436    iterator it = begin(), endit = end(), a_it = a.begin();
00437    bool *t_it = temp.begin();
00438    while (it != endit) *t_it++ = *it++ < *a_it++;
00439    return temp;
00440 }

template<class T>
Vector< bool > matvec::Vector< T >::operator<= const T &    x const [inline]
 

Definition at line 479 of file vector.h.

00480 { return !(*this > x); }

template<class T>
Vector< bool > matvec::Vector< T >::operator<= const Vector< T > &    a const [inline]
 

Definition at line 476 of file vector.h.

00477 { return !(*this > a); }

template<class T>
Vector& matvec::Vector< T >::operator= const T &    x [inline]
 

Definition at line 88 of file vector.h.

00088 { return assign(x); }

template<class T>
Vector& matvec::Vector< T >::operator= const Vector< T > &    a [inline]
 

Definition at line 87 of file vector.h.

00087 { return assign(a); }

template<class T>
Vector< bool > matvec::Vector< T >::operator== const T &    x const [inline]
 

Definition at line 423 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00424 {
00425    Vector<bool> temp(ne);
00426    iterator it = begin(), endit = end();
00427    bool *t_it = temp.begin();
00428    while (it != endit) *t_it++ = *it++ == x;
00429    return temp;
00430 }

template<class T>
Vector< bool > matvec::Vector< T >::operator== const Vector< T > &    a const [inline]
 

Definition at line 413 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, matvec::Vector< T >::ne, and matvec::Vector< T >::size().

00414 {
00415    assert(ne == a.size());
00416    Vector<bool> temp(ne);
00417    iterator it = begin(), endit = end(), a_it = a.begin();
00418    bool *t_it = temp.begin();
00419    while (it != endit) *t_it++ = *it++ == *a_it++;
00420    return temp;
00421 }

template<class T>
Vector< bool > matvec::Vector< T >::operator> const T &    x const [inline]
 

Definition at line 461 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00462 {
00463    Vector<bool> temp(ne);
00464    iterator it = begin(), endit = end();
00465    bool *t_it = temp.begin();
00466    while (it != endit) *t_it++ = *it++ > x;
00467    return temp;
00468 }

template<class T>
Vector< bool > matvec::Vector< T >::operator> const Vector< T > &    a const [inline]
 

Definition at line 451 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, and matvec::Vector< T >::ne.

00452 {
00453    assert (ne != a.ne );
00454    Vector<bool> temp(ne);
00455    iterator it = begin(), endit = end(), a_it = a.begin();
00456    bool *t_it = temp.begin();
00457    while (it != endit) *t_it++ = *it++ > *a_it++;
00458    return temp;
00459 }

template<class T>
Vector< bool > matvec::Vector< T >::operator>= const T &    x const [inline]
 

Definition at line 486 of file vector.h.

00487 { return !(*this < x); }

template<class T>
Vector< bool > matvec::Vector< T >::operator>= const Vector< T > &    a const [inline]
 

Definition at line 483 of file vector.h.

00484 { return !(*this < a); }

template<class T>
const T& matvec::Vector< T >::operator[] const size_type    i const [inline]
 

Definition at line 110 of file vector.h.

00110 {return ve[i];}

template<class T>
T& matvec::Vector< T >::operator[] const size_type    i [inline]
 

Definition at line 109 of file vector.h.

00109 {return ve[i];}

template<class T>
std::ostream & matvec::Vector< T >::print std::ostream &    os = std::cout const [inline]
 

Definition at line 728 of file vector.h.

References matvec::Vector< T >::ne, matvec::Session::output_precision, matvec::SESSION, and matvec::Vector< T >::ve.

Referenced by matvec::Vector< T >::operator<<(), matvec::Minimizer::praxis(), matvec::print(), and matvec::Vector< T >::save().

00729 {
00730   for (int i=0; i<ne; ++i) {
00731     os.width(8);
00732     os.precision(SESSION.output_precision); 
00733     os <<ve[i] << "\n";
00734   }
00735    return os;
00736 }

template<class T>
const reverse_iterator matvec::Vector< T >::rbegin void    const [inline]
 

Definition at line 73 of file vector.h.

00073 { return const_reverse_iterator(end()); }

template<class T>
reverse_iterator matvec::Vector< T >::rbegin void    [inline]
 

returns a reverse iterator for the first element of a reverse iteration.

Definition at line 71 of file vector.h.

template<class T>
const reverse_iterator matvec::Vector< T >::rend void    const [inline]
 

Definition at line 74 of file vector.h.

00074 { return const_reverse_iterator(begin());}

template<class T>
reverse_iterator matvec::Vector< T >::rend void    [inline]
 

returns a reverse iterator for the position after the last element of a reverse iteration.

Definition at line 72 of file vector.h.

template<class T>
Vector< T > & matvec::Vector< T >::reserve const size_type    n [inline]
 

It resizes vector without initialization.

See also:
resize

Definition at line 299 of file vector.h.

References matvec::check_ptr(), matvec::Vector< T >::clear(), matvec::Vector< T >::ne, and matvec::Vector< T >::ve.

Referenced by matvec::Vector< T >::append(), matvec::Model::blup_pccg(), matvec::Vector< T >::copy(), matvec::Model::covariance(), matvec::SparseMatrix::factor(), matvec::SparseBGMatrix::factor(), matvec::Data::field_index_vec(), matvec::Model::genotype_dist_gibbs(), matvec::Model::genotypic_value_cat(), matvec::Model::genotypic_value_gibbs(), matvec::doubleMatrix::ginv0(), matvec::Population::inbcoef_meuwissen(), matvec::Population::inbcoef_quaas(), matvec::Vector< T >::input(), matvec::doubleMatrix::inv(), matvec::BGMatrix::inv(), matvec::doubleMatrix::lu_solve(), matvec::BGMatrix::lu_solve(), matvec::Matrix< T >::max(), matvec::Matrix< T >::min(), matvec::SparseMatrix::mv(), matvec::SparseBGMatrix::mv(), matvec::doubleMatrix::norm(), matvec::operator *(), matvec::Pedigree::renum(), matvec::Population::setup_m_ww(), matvec::SparseMatrix::solv(), matvec::SparseBGMatrix::solv(), matvec::SparseMatrix::solve(), matvec::SparseBGMatrix::solve(), matvec::Matrix< T >::sum(), matvec::Matrix< T >::sumsq(), matvec::Model::vce_emreml_multi_trait(), matvec::Model::vce_emreml_single_trait(), matvec::Model::vce_gibbs(), and matvec::Matrix< T >::vec().

00300 {
00301    if (ne != n) {
00302       clear();
00303       ne = n;
00304       if(ne>0){
00305         ve = new T [ne];
00306       }
00307       else {
00308         ve = 0;
00309       }
00310       check_ptr(ve);
00311    }
00312    return *this;
00313 }

template<class T>
Vector& matvec::Vector< T >::resize const Vector< T > &    a [inline]
 

Definition at line 84 of file vector.h.

00084 {resize(a.ne); return *this;}

template<class T>
Vector< T > & matvec::Vector< T >::resize const size_type    n,
const T *    a
[inline]
 

Definition at line 336 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::clear(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, matvec::Vector< T >::ne, and matvec::Vector< T >::ve.

00337 {
00338    if (n == 0) {
00339       clear();
00340    } else {
00341       if (ne != n) {
00342          clear();
00343          ne = n;
00344          ve = new T [ne];
00345          assert( ve != 0 );
00346       }
00347       iterator it = begin(), endit = end();
00348       while (it != endit) *it++ = *a++;
00349    }
00350    return *this;
00351 }

template<class T>
Vector< T > & matvec::Vector< T >::resize const size_type    n,
const T &    val = T()
[inline]
 

It resizes vector with each element being val.

See also:
resize

Definition at line 319 of file vector.h.

References matvec::Vector< T >::begin(), matvec::check_ptr(), matvec::Vector< T >::clear(), matvec::Vector< T >::end(), matvec::Vector< T >::iterator, matvec::Vector< T >::ne, and matvec::Vector< T >::ve.

Referenced by matvec::GLMM::add_Ag_old(), matvec::GLMM::AI_REML(), matvec::Anterior_c::Anterior_c(), matvec::Vector< T >::assign(), matvec::bound_pd(), matvec::GLMM::build_hInv(), matvec::Model::covariance(), matvec::Model::estimate(), matvec::SparseBGMatrix::factor(), matvec::Model::get_solutions(), matvec::GLMM::glim(), matvec::doubleMatrix::gs_solve(), matvec::BGMatrix::gs_solve(), matvec::Population::input_descentGraph(), matvec::Population::input_markerData(), matvec::GLMM::link(), matvec::doubleMatrix::mat_exp_der(), matvec::SparseMatrix::minfilsymelm_node_list(), matvec::SparseBGMatrix::minfilsymelm_node_list(), matvec::normal_loginClasses(), matvec::Posterior_c::Posterior_c(), matvec::Vector< Vector< Sym2x2 > >::resize(), matvec::Population::resizeSegregationIndicators(), matvec::Population::setup_m_ww(), matvec::Model::setup_mme(), matvec::GLMM::setup_mme(), matvec::Model::setup_ww(), matvec::SparseBGMatrix::solve(), matvec::GLMM::SSQCP(), matvec::Population::sum_genotype_freq1(), matvec::Population::sum_genotype_freq2(), matvec::Population::sum_genotype_freq3(), matvec::doubleMatrix::svd(), matvec::doubleMatrix::variance(), matvec::BGMatrix::variance(), matvec::Model::vce_emreml_multi_trait(), and matvec::Model::vce_emreml_single_trait().

00320 {
00321    if (n == 0) {
00322       clear();
00323    } else {
00324       if (ne != n) {
00325          clear();
00326          ne = n;
00327          ve = new T [ne];
00328          check_ptr(ve);
00329       }
00330       iterator it=begin(), endit = end();
00331       while  (it != endit) *it++ = val;
00332    }
00333    return *this;
00334 }

template<class T>
bool matvec::Vector< T >::save const std::string &    fname,
const int    io_mode = std::ios::out
const [inline]
 

Save the content into an text file.

Parameters:
fname  Filename
io_mode  determines how the file is opened. It must be one (or more by ORing) of these values:
  • ios::in Opens for reading;
  • ios::out Opens for writing;
  • ios::ate Seeks to EOS after file is create;
  • ios::app All writes added to end of file;
  • ios::truct If file already exists, truncates;
  • ios::nocreate Won't open if file does not exit;
  • ios::noreplace Won't open if file does exit;
  • ios::binary Opens file in binary mode (default text)
For instance ios::app|ios::nocreate append all writes to an existing file, it won't open if file does not exit.
See also:
input()

Definition at line 256 of file vector.h.

References matvec::Vector< T >::print().

00257 {
00258    std::ofstream ofs;
00259    ofs.open(fname.c_str(),(OpenModeType)io_mode);
00260    if (!ofs) throw exception("Vector<T>::save(): cannot open file");
00261    print(ofs);
00262    ofs.close();
00263    return true;
00264 }

template<class T>
int matvec::Vector< T >::size void    const [inline]
 

Definition at line 162 of file vector.h.

Referenced by matvec::Vector< T >::apply(), matvec::Model::contrast(), matvec::GLMM::contrast(), matvec::diag(), matvec::Model::estimate(), matvec::Vector< T >::find(), matvec::Individual::get_penetrance(), matvec::doubleMatrix::gs_solve(), matvec::BGMatrix::gs_solve(), matvec::hadjoin(), matvec::Population::llhood_phenotype(), matvec::doubleMatrix::lu_solve(), matvec::BGMatrix::lu_solve(), matvec::Data::max(), matvec::Data::mean(), matvec::Data::min(), matvec::SparseMatrix::mv(), matvec::SparseBGMatrix::mv(), matvec::Matrix< T >::operator *(), matvec::operator *(), matvec::Vector< T >::operator/(), matvec::Vector< T >::operator==(), matvec::NuFamily::pretend_missing(), matvec::Data::print(), matvec::Data::product(), matvec::SparseMatrix::q(), matvec::SparseBGMatrix::q(), matvec::SparseMatrix::qTLW(), matvec::SparseBGMatrix::qTLW(), matvec::doubleMatrix::quadratic(), matvec::BGMatrix::quadratic(), matvec::SparseMatrix::solve(), matvec::SparseBGMatrix::solve(), matvec::Vector< T >::subvec(), matvec::Data::sum(), matvec::Data::sumsq(), matvec::doubleMatrix::svd(), matvec::vadjoin(), and matvec::Data::variance().

00162 {return ne;}

template<class T>
Vector& matvec::Vector< T >::sort void    [inline]
 

Definition at line 142 of file vector.h.

00142 {std::sort(begin(),end()); return *this;}

template<class T>
Vector< T > matvec::Vector< T >::subvec const Vector< bool > &    v const [inline]
 

Definition at line 686 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::size(), and matvec::Vector< T >::ve.

00687 {
00688    int n = 0;
00689    int m = v.size();
00690    bool *ve_pt = v.ve;
00691    int i;
00692    for (i=0; i<m; i++) if (*ve_pt++) n++;
00693 
00694    Vector<T> temp(n);
00695    T *t_pt = temp.begin();
00696    ve_pt = v.ve;
00697    for (i=0; i<m; i++) if (*ve_pt++) *t_pt++ = ve[i];
00698    return temp;
00699 }

template<class T>
Vector< T > matvec::Vector< T >::subvec const size_type    idx = 0,
const unsigned    len = 0
const [inline]
 

Definition at line 675 of file vector.h.

References matvec::Vector< T >::begin(), matvec::Vector< T >::ne, and matvec::Vector< T >::ve.

00676 {
00677    assert (idx >= 0 && idx < ne && len <= (ne - idx));
00678    int newne = len;
00679    if (newne == 0) {newne = ne - idx;}
00680    Vector<T> temp(newne);
00681    T *bot = &ve[idx], *top = bot + newne, *t_pt = temp.begin();
00682    while (bot < top) *t_pt++ = *bot++;
00683    return temp;
00684 }

template<class T>
T matvec::Vector< T >::sum   init = T() const [inline]
 

Definition at line 143 of file vector.h.

Referenced by matvec::Individual::get_penetrance(), matvec::Population::llhood_phenotype(), matvec::Data::sum(), and matvec::Vector< T >::variance().

00143 {return std::accumulate(begin(),end(),init);}

template<class T>
T matvec::Vector< T >::sumsq   init = T() const [inline]
 

Definition at line 147 of file vector.h.

Referenced by matvec::Data::sumsq().

00147 { return inner_product(this->begin(),init); }

template<class T>
T matvec::Vector< T >::variance   init = T() const [inline]
 

Definition at line 667 of file vector.h.

References matvec::Vector< T >::inner_product(), matvec::Vector< T >::ne, and matvec::Vector< T >::sum().

Referenced by matvec::Field::covariance().

00668 {
00669    assert( ne > 1);
00670    T x(sum(init));
00671    init = (inner_product(init) - x*x/ne)/(ne - 1);
00672    return init;
00673 }


Friends And Related Function Documentation

template<class T>
Vector< T > abs const Vector< T > &    a [related]
 

returns a vector of abs(a[i]).

Definition at line 817 of file vector.h.

References matvec::Vector< T >::apply().

00817 {return a.apply(std::abs);}

template<class T>
Vector< T > acos const Vector< T > &    a [related]
 

returns a vector of acos(a[i]).

Definition at line 763 of file vector.h.

References matvec::Vector< T >::apply().

00763 {return a.apply(std::acos);}

template<class T>
bool all const Vector< T > &    a [related]
 

If each element is true return true, otherwise return false.

Definition at line 836 of file vector.h.

References matvec::Vector< T >::all().

00836 {return a.all();}

template<class T>
bool any const Vector< T > &    a [related]
 

If each element is false return false, otherwise return true.

Definition at line 843 of file vector.h.

References matvec::Vector< T >::any().

00843 {return a.any();}

template<class T>
Vector< T > asin const Vector< T > &    a [related]
 

returns a vector of asin(a[i]).

Definition at line 750 of file vector.h.

References matvec::Vector< T >::apply().

00750 {return a.apply(std::asin);}

template<class T>
Vector< T > atan const Vector< T > &    a [related]
 

returns a vector of atan(a[i]).

Definition at line 775 of file vector.h.

References matvec::Vector< T >::apply().

00775 {return a.apply(std::atan);}

template<class T>
Vector< T > ceil const Vector< T > &    a [related]
 

returns a vector of ceil(a[i]).

Definition at line 781 of file vector.h.

References matvec::Vector< T >::apply().

00781 {return a.apply(std::ceil);}

template<class T>
Vector< T > cos const Vector< T > &    a [related]
 

returns a vector of cos(a[i]).

Definition at line 757 of file vector.h.

References matvec::Vector< T >::apply().

00757 {return a.apply(std::cos);}

template<class T>
Vector< T > erf const Vector< T > &    a [related]
 

returns a vector of erf(a[i]).

Definition at line 823 of file vector.h.

References matvec::Vector< T >::apply().

00823 {return a.apply(erf);}

template<class T>
Vector< T > erfc const Vector< T > &    a [related]
 

returns a vector of erfc(a[i]).

Definition at line 829 of file vector.h.

References matvec::Vector< T >::apply().

00829 {return a.apply(erfc);}

template<class T>
Vector< T > exp const Vector< T > &    a [related]
 

returns a vector of exp(a[i]).

Definition at line 805 of file vector.h.

References matvec::Vector< T >::apply().

00805 {return a.apply(std::exp);}

template<class T>
Vector< T > floor const Vector< T > &    a [related]
 

returns a vector of floor(a[i]).

Definition at line 787 of file vector.h.

References matvec::Vector< T >::apply().

00787 {return a.apply(std::floor);}

template<class T>
Vector< T > log const Vector< T > &    a [related]
 

returns a vector of log(a[i]).

Definition at line 793 of file vector.h.

References matvec::Vector< T >::apply().

00793 {return a.apply(std::log);}

template<class T>
Vector< T > log10 const Vector< T > &    a [related]
 

returns a vector of log10(a[i]).

Definition at line 799 of file vector.h.

References matvec::Vector< T >::apply().

00799 {return a.apply(std::log10);}

template<class T>
Vector< T > operator * const T &    a,
const Vector< T > &    b
[related]
 

returns a * b..

Definition at line 864 of file vector.h.

00864 {return b*a;}

template<class T>
Vector< T > operator+ const T &    a,
const Vector< T > &    b
[related]
 

returns a + b.

Definition at line 850 of file vector.h.

00850 {return b+a;}

template<class T>
Vector< T > operator- const T &    a,
const Vector< T > &    b
[related]
 

returns a - b.

Definition at line 857 of file vector.h.

00857 {return -b+a;}

template<class T>
Vector< T > operator/ const T &    a,
const Vector< T > &    b
[related]
 

returns a / b

Definition at line 871 of file vector.h.

References matvec::Vector< T >::size().

00872 {
00873    Vector<T> temp(b.size());
00874    for (int i=0; i<b.size(); ++i) temp[i] = a / b[i];
00875    return temp;
00876 }

template<class T>
std::ostream & operator<< std::ostream &    os,
const Vector< T > &    a
[related]
 

It print Vector a to an output stream.

Definition at line 882 of file vector.h.

References matvec::Vector< T >::print().

00882 {return a.print(os);}

template<class T>
Vector< T > sin const Vector< T > &    a [related]
 

returns a vector of sin(a[i]).

Definition at line 744 of file vector.h.

References matvec::Vector< T >::apply().

00744 {return a.apply(std::sin);}

template<class T>
Vector< T > sqrt const Vector< T > &    a [related]
 

returns a vector of sqrt(a[i]).

Definition at line 811 of file vector.h.

References matvec::Vector< T >::apply().

00811 {return a.apply(std::sqrt);}

template<class T>
Vector< T > tan const Vector< T > &    a [related]
 

returns a vector of tan(a[i]).

Definition at line 769 of file vector.h.

References matvec::Vector< T >::apply().

00769 {return a.apply(std::tan);}


Member Data Documentation

template<class T>
int matvec::Vector< T >::ne [protected]
 

it stores the number of elements.

Definition at line 175 of file vector.h.

Referenced by matvec::Vector< T >::append(), matvec::Vector< T >::apply(), matvec::Vector< T >::assign(), matvec::Vector< T >::at(), matvec::Vector< Vector< Sym2x2 > >::clear(), matvec::Vector< T >::copy(), matvec::Vector< Vector< Sym2x2 > >::empty(), matvec::Vector< Vector< Sym2x2 > >::end(), matvec::Vector< T >::find(), matvec::Vector< T >::initialize(), matvec::Vector< T >::operator *(), matvec::Vector< T >::operator *=(), matvec::Vector< T >::operator()(), matvec::Vector< T >::operator+(), matvec::Vector< T >::operator+=(), matvec::Vector< T >::operator-(), matvec::Vector< T >::operator-=(), matvec::Vector< T >::operator/(), matvec::Vector< T >::operator/=(), matvec::Vector< T >::operator<(), matvec::Vector< T >::operator==(), matvec::Vector< T >::operator>(), matvec::Vector< T >::print(), matvec::Vector< T >::reserve(), matvec::Vector< T >::resize(), matvec::Vector< Vector< Sym2x2 > >::resize(), matvec::Vector< Vector< Sym2x2 > >::size(), matvec::Vector< T >::subvec(), matvec::Vector< T >::variance(), and matvec::Vector< Vector< Sym2x2 > >::Vector().

template<class T>
T* matvec::Vector< T >::ve [protected]
 

it store the pointer to the memory allocated for ne element.

Definition at line 174 of file vector.h.

Referenced by matvec::Vector< T >::all(), matvec::Vector< T >::any(), matvec::Vector< T >::append(), matvec::Vector< T >::at(), matvec::Vector< Vector< Sym2x2 > >::begin(), matvec::Vector< Vector< Sym2x2 > >::clear(), matvec::Vector< T >::copy(), matvec::Vector< Vector< Sym2x2 > >::end(), matvec::Vector< T >::find(), matvec::Vector< T >::initialize(), matvec::Vector< T >::input(), matvec::Vector< T >::operator()(), matvec::Vector< Vector< Sym2x2 > >::operator[](), matvec::Vector< T >::print(), matvec::Vector< T >::reserve(), matvec::Vector< T >::resize(), matvec::Vector< T >::subvec(), and matvec::Vector< Vector< Sym2x2 > >::Vector().


The documentation for this class was generated from the following file:
Generated on Thu Jun 16 17:14:53 2005 for Matvec by doxygen1.2.16