concepts::Array< F > Class Template Reference

An array of objects. More...

#include <bilinearForm.hh>

Inheritance diagram for concepts::Array< F >:
concepts::ArrayDeterminant< F, dim > concepts::ArrayReciprocal< F >

Public Member Functions

template<class H >
Array< F > & apply (const Array< H > &a, F fnc(const H &))
 Application operator to each component. More...
 
template<class H >
Array< F > & apply (const Array< H > &a, F fnc(const H &, const F &))
 Application operator to each component. More...
 
Array< F > & apply (F &fnc(F &))
 Application operator to each component, e.g. More...
 
 Array (const Array< F > &a)
 Copy constructor. More...
 
template<class H >
 Array (const Array< H > &a)
 Type conversion constructor. More...
 
template<class H >
 Array (const Array< H > &a, F fnc(const H &))
 Constructor by applying a function to another array. More...
 
 Array (const F *dft, const uint sz)
 Constructor. More...
 
 Array (const uint sz, const F &dft)
 Constructor. More...
 
 Array (const uint sz, const F &first, const F &diff)
 Constructor for equidistant values. More...
 
 Array (const uint sz=0)
 Constructor. More...
 
uint cursize () const
 Returns the size of the allocated memory. More...
 
std::ostream & info (std::ostream &os) const
 
int memory () const
 Returns the memory usage in bytes. More...
 
 operator const F * () const
 Returns a pointer to the array. More...
 
 operator F* ()
 Returns a pointer to the array. More...
 
template<class H >
Array< F > & operator*= (const Array< H > &a)
 Multiplication operator. More...
 
template<class G >
Array< F > & operator*= (const G n)
 Scaling operator. More...
 
template<class H >
Array< F > & operator+= (const Array< H > &a)
 Addition operator. More...
 
Array< F > & operator+= (const F n)
 Addition operator. More...
 
Array< F > operator- () const
 Negation operator. More...
 
template<class H >
Array< F > & operator-= (const Array< H > &a)
 Subtraction operator. More...
 
Array< F > & operator-= (const F n)
 Subtraction operator. More...
 
Array< F > & operator= (const Array< F > &a)
 Assignement operator. More...
 
template<class H >
Array< F > & operator= (const Array< H > &a)
 Assignement operator. More...
 
Array< F > & operator= (const F n)
 Assignement operator. More...
 
F & operator[] (const int i)
 Index operator. More...
 
const F & operator[] (const int i) const
 Index operator. More...
 
void resize (const uint sz)
 Resizes the array. More...
 
void resizePreserve (const uint sz)
 Resizes the array. More...
 
Array< F > & reverse ()
 Reverse the order of the entries. More...
 
uint size () const
 Returns the requested size of the array. More...
 
void zeros ()
 Fills the memory with zeros. More...
 
 ~Array ()
 

Protected Attributes

F * data_
 Data. More...
 
uint n_
 Requested size of the array. More...
 
uint size_
 Current real size of the array. More...
 

Detailed Description

template<class F>
class concepts::Array< F >

An array of objects.

It does enlarge on request, zero out and more. In a sense a very minimalistic implementation of STLs vector. It's mainly intended to be an exception safe way to have an array of something. Especially suitable for vectors and matrices.

Author
Philipp Frauenfelder, 2001
Examples
arpackppTutorial.cc, and hpFEM3d-EV.cc.

Definition at line 23 of file bilinearForm.hh.

Constructor & Destructor Documentation

◆ Array() [1/7]

template<class F >
concepts::Array< F >::Array ( const uint  sz = 0)
inline

Constructor.

Definition at line 49 of file array.hh.

◆ Array() [2/7]

template<class F >
concepts::Array< F >::Array ( const uint  sz,
const F &  dft 
)
inline

Constructor.

Parameters
szSize of the array
dftDefault value. This is used in the first allocation and not in subsequent allocations.

Definition at line 59 of file array.hh.

◆ Array() [3/7]

template<class F >
concepts::Array< F >::Array ( const F *  dft,
const uint  sz 
)
inline

Constructor.

Parameters
szSize of the array
dataC array of size sz.

Take care for the length of the C array.

Definition at line 70 of file array.hh.

◆ Array() [4/7]

template<class F >
concepts::Array< F >::Array ( const uint  sz,
const F &  first,
const F &  diff 
)
inline

Constructor for equidistant values.

Only for types, which have a substraction- and a division-operator.

Parameters
szsize
firstfirst value
diffdifferences between values

Definition at line 84 of file array.hh.

◆ Array() [5/7]

template<class F >
template<class H >
concepts::Array< F >::Array ( const Array< H > &  a,
F   fncconst H & 
)
inline

Constructor by applying a function to another array.

Parameters
aArray with elements of type H
fncFunction which maps from H to F

Definition at line 98 of file array.hh.

◆ Array() [6/7]

template<class F >
concepts::Array< F >::Array ( const Array< F > &  a)
inline

Copy constructor.

Definition at line 103 of file array.hh.

◆ Array() [7/7]

template<class F >
template<class H >
concepts::Array< F >::Array ( const Array< H > &  a)
inline

Type conversion constructor.

Definition at line 109 of file array.hh.

◆ ~Array()

template<class F >
concepts::Array< F >::~Array ( )
inline

Definition at line 111 of file array.hh.

Member Function Documentation

◆ apply() [1/3]

template<class F >
template<class H >
Array<F>& concepts::Array< F >::apply ( const Array< H > &  a,
F   fncconst H & 
)
inline

Application operator to each component.

Each array value is the function applied to the appropiate array value in a.

  @param a   Array with elements of type H
  @param fnc Function which maps from H to F

Definition at line 233 of file array.hh.

◆ apply() [2/3]

template<class F >
template<class H >
Array<F>& concepts::Array< F >::apply ( const Array< H > &  a,
F   fncconst H &, const F & 
)
inline

Application operator to each component.

Each array value is the function applied to the appropiate array value in a and to the old array value.

  @param a   Array with elements of type H
  @param fnc Function which maps from (H,F) to F

Definition at line 249 of file array.hh.

◆ apply() [3/3]

template<class F >
Array<F>& concepts::Array< F >::apply ( F &  fncF &)
inline

Application operator to each component, e.g.

std::sin or std::conj

Definition at line 219 of file array.hh.

◆ cursize()

template<class F >
uint concepts::Array< F >::cursize ( ) const
inline

Returns the size of the allocated memory.

Definition at line 262 of file array.hh.

◆ info()

template<class F >
std::ostream & concepts::Array< F >::info ( std::ostream &  os) const

Definition at line 302 of file array.hh.

◆ memory()

template<class F >
int concepts::Array< F >::memory ( ) const
inline

Returns the memory usage in bytes.

Definition at line 265 of file array.hh.

◆ operator const F *()

template<class F >
concepts::Array< F >::operator const F * ( ) const
inline

Returns a pointer to the array.

Definition at line 133 of file array.hh.

◆ operator F*()

template<class F >
concepts::Array< F >::operator F* ( )
inline

Returns a pointer to the array.

Definition at line 131 of file array.hh.

◆ operator*=() [1/2]

template<class F >
template<class H >
Array<F>& concepts::Array< F >::operator*= ( const Array< H > &  a)
inline

Multiplication operator.

Definition at line 158 of file array.hh.

◆ operator*=() [2/2]

template<class F >
template<class G >
Array<F>& concepts::Array< F >::operator*= ( const G  n)
inline

Scaling operator.

Definition at line 150 of file array.hh.

◆ operator+=() [1/2]

template<class F >
template<class H >
Array<F>& concepts::Array< F >::operator+= ( const Array< H > &  a)
inline

Addition operator.

Definition at line 191 of file array.hh.

◆ operator+=() [2/2]

template<class F >
Array<F>& concepts::Array< F >::operator+= ( const F  n)
inline

Addition operator.

Definition at line 185 of file array.hh.

◆ operator-()

template<class F >
Array<F> concepts::Array< F >::operator- ( ) const
inline

Negation operator.

Definition at line 211 of file array.hh.

◆ operator-=() [1/2]

template<class F >
template<class H >
Array<F>& concepts::Array< F >::operator-= ( const Array< H > &  a)
inline

Subtraction operator.

Definition at line 204 of file array.hh.

◆ operator-=() [2/2]

template<class F >
Array<F>& concepts::Array< F >::operator-= ( const F  n)
inline

Subtraction operator.

Definition at line 198 of file array.hh.

◆ operator=() [1/3]

template<class F >
Array<F>& concepts::Array< F >::operator= ( const Array< F > &  a)
inline

Assignement operator.

Definition at line 171 of file array.hh.

◆ operator=() [2/3]

template<class F >
template<class H >
Array<F>& concepts::Array< F >::operator= ( const Array< H > &  a)
inline

Assignement operator.

Definition at line 178 of file array.hh.

◆ operator=() [3/3]

template<class F >
Array<F>& concepts::Array< F >::operator= ( const F  n)
inline

Assignement operator.

Definition at line 166 of file array.hh.

◆ operator[]() [1/2]

template<class F >
F& concepts::Array< F >::operator[] ( const int  i)
inline

Index operator.

Definition at line 142 of file array.hh.

◆ operator[]() [2/2]

template<class F >
const F& concepts::Array< F >::operator[] ( const int  i) const
inline

Index operator.

Definition at line 136 of file array.hh.

◆ resize()

template<class F >
void concepts::Array< F >::resize ( const uint  sz)

Resizes the array.

A reallocation occurs only if the requested space is not available, ie. making the array smaller does not result in a reallocation. If a reallocation occurs, the data is not preserved.

Definition at line 281 of file array.hh.

◆ resizePreserve()

template<class F >
void concepts::Array< F >::resizePreserve ( const uint  sz)

Resizes the array.

Basically, it does the same as resize. But, if a reallocation occurs, the data is preserved.

Definition at line 290 of file array.hh.

◆ reverse()

template<class F >
Array< F > & concepts::Array< F >::reverse

Reverse the order of the entries.

Definition at line 311 of file array.hh.

◆ size()

template<class F >
uint concepts::Array< F >::size ( ) const
inline

Returns the requested size of the array.

Definition at line 259 of file array.hh.

◆ zeros()

template<class F >
void concepts::Array< F >::zeros ( )
inline

Fills the memory with zeros.

Definition at line 128 of file array.hh.

Member Data Documentation

◆ data_

template<class F >
F* concepts::Array< F >::data_
protected

Data.

Definition at line 273 of file array.hh.

◆ n_

template<class F >
uint concepts::Array< F >::n_
protected

Requested size of the array.

Definition at line 277 of file array.hh.

◆ size_

template<class F >
uint concepts::Array< F >::size_
protected

Current real size of the array.

Definition at line 275 of file array.hh.


The documentation for this class was generated from the following files:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich