# concepts::Vector< F > Class Template ReferenceBilinear and Linear Forms &ndash; Matrices and Vectors

A vector. More...

#include <vectorTest.hh>

## Public Member Functions

virtual Function< F > & add (const Function< F > &fnc, F sc)

template<class H >
Vector< F > & add (const Vector< H > &fnc)
Adds a vector of possible different length and type. More...

template<class H >
Vector< F > & add (const Vector< H > &fnc, F sc, uint offset=0)
Adds a vector of possible different length and type with an offset. More...

Vector< F > & apply (F fnc(const F &))
Application operator to each component, e.g. More...

template<class G >
Vector< F > & assemble (const Space< G > &spc, const LinearForm< F, G > &lf)
Assembles the vector w.r.t. linear form lf and space spc. More...

F * data () const

Real l1 () const
l1 norm More...

Real l2 () const
l2 norm More...

Real l2_2 () const
l2 norm squared More...

Real max () const
Maximum of the absolute values in the vector, ie. norm. More...

uint n () const
Elements in the vector. More...

operator F* () const
Conversion operator. More...

virtual F & operator() (uint i)

virtual F operator() (uint i) const

operator* (const Vector< F > &fnc) const
Inner product (v = this, w = \fnc) More...

Vector< F > operator* (F c) const

virtual Function< F > & operator*= (F sc)
Scaling operator. More...

Vector< F > operator+ (const Function< F > &fnc) const

Vector< F > operator+ (F c) const

virtual Function< F > & operator+= (const Function< F > &fnc)

virtual Function< F > & operator+= (F c)

Vector< F > operator- (const Function< F > &fnc) const

Vector< F > operator- (F c) const

virtual Function< F > & operator-= (const Function< F > &fnc)
Subtraction operator. More...

virtual Function< F > & operator-= (F c)

Vector< F > operator/ (F c) const

virtual Function< F > & operator/= (F sc)

virtual Vector< F > & operator= (const Function< F > &fnc)

template<class H >
Vector< F > & operator= (const Function< H > &fnc)

Vector< F > & operator= (const Vector< F > &fnc)
Assignement operator. More...

Vector< F > & operator= (F c)
Assignement operator. More...

virtual void resize (uint n)
Sets a new size, previous data might be lost
More...

void reverse ()

uint size () const

void storeMatlab (const char *filename, const char *name=0, bool append=false) const
Stores the vector in a Matlab sparse matrix. More...

template<class G >
Vector (const Space< G > &spc)
Constructor. More...

template<class G >
Vector (const Space< G > &spc, const LinearForm< F, G > &lf)
Constructor. More...

template<class G >
Vector (const Space< G > &spc, const std::string &fname)

template<class G >
Vector (const Space< G > &spc, F *data)
Constructor. More...

Vector (const uint dim=0)
Constructor. More...

Vector (const Vector< F > &f)
Copy constructor. More...

template<class H >
Vector (const Vector< H > &f)
Copy constructor. More...

template<class H >
Vector (const Vector< H > &fnc, const Set< IndexRange > &indices)
Constructor. More...

template<class H >
Vector (const Vector< H > &fncX, const F &fnc(const H &))

template<class H >
Vector (const Vector< H > &fncX, F fnc(const H &))
Constructor. More...

Vector (const Vector< typename Realtype< F >::type > &V_R, const Vector< typename Realtype< F >::type > &V_I)
Constructor. More...

Vector (uint dim, F *data)

const Vector< F > & write (const std::string &fname) const
Writes the vector to a file. More...

virtual ~Vector ()

## Protected Member Functions

template<class G >
void fillEntries_ (const Space< G > &spc, const LinearForm< F, G > &lf)

virtual std::ostream & info (std::ostream &os) const

## Protected Attributes

Array< F > data_
Vector data. More...

## Private Attributes

F * v_
Pointer to the vector data. More...

## Static Private Attributes

static uint storeMatlabCounter_
Counts number of Matlab outputs (used to uniquely name the vectors) More...

## Detailed Description

### template<class F> class concepts::Vector< F >

A vector.

The values of the function represented by this vector are stored elementwise in an array.

It is possible to write fast interfaces to other libraries since the array of values is under complete control of this class. An example is the interface to PETSc, where the vector data is not copied, but the data of PETSc is used.

Test:
test::VectorTest
Examples
arpackppTutorial.cc, and hpFEM3d-EV.cc.

Definition at line 15 of file vectorTest.hh.

## ◆ Vector() [1/12]

template<class F >
 concepts::Vector< F >::Vector ( const Vector< F > & f )

Copy constructor.

## ◆ Vector() [2/12]

template<class F >
template<class H >
 concepts::Vector< F >::Vector ( const Vector< H > & f )

Copy constructor.

Definition at line 253 of file vector.hh.

## ◆ Vector() [3/12]

template<class F >
template<class G >
 concepts::Vector< F >::Vector ( const Space< G > & spc )
inline

Constructor.

Creates a vector with all entries set to 0.

Parameters
 spc A space

Definition at line 51 of file vector.hh.

## ◆ Vector() [4/12]

template<class F >
 concepts::Vector< F >::Vector ( const uint dim = 0 )
inline

Constructor.

Creates a vector with all entries set to 0.

Parameters
 dim number of entries

Definition at line 57 of file vector.hh.

## ◆ Vector() [5/12]

template<class F >
template<class G >
 concepts::Vector< F >::Vector ( const Space< G > & spc, const LinearForm< F, G > & lf )

Constructor.

The entries are filled according to lf.

Parameters
 spc A space lf A linear form

Definition at line 270 of file vector.hh.

## ◆ Vector() [6/12]

template<class F >
template<class G >
 concepts::Vector< F >::Vector ( const Space< G > & spc, const std::string & fname )

The vector is read from a file. This should be endian proof.

Parameters
 spc A space fname Filename

## ◆ Vector() [7/12]

template<class F >
template<class G >
 concepts::Vector< F >::Vector ( const Space< G > & spc, F * data )
inline

Constructor.

Use this constructor to create a vector from an array of data. The memory in data is not freed by this class.

Parameters
 spc Space on which the vector is defined data Data of the vector

Definition at line 84 of file vector.hh.

## ◆ Vector() [8/12]

template<class F >
 concepts::Vector< F >::Vector ( uint dim, F * data )
inline

Definition at line 88 of file vector.hh.

## ◆ Vector() [9/12]

template<class F >
template<class H >
 concepts::Vector< F >::Vector ( const Vector< H > & fncX, F fncconst H & )

Constructor.

Use this constructor to create a vector of type F out of a vector with entries of type H. The F type vector consists of elementwise evaluations of the function fnc.

Definition at line 260 of file vector.hh.

## ◆ Vector() [10/12]

template<class F >
template<class H >
 concepts::Vector< F >::Vector ( const Vector< H > & fncX, const F & fncconst H & )

Definition at line 277 of file vector.hh.

## ◆ Vector() [11/12]

template<class F >
 concepts::Vector< F >::Vector ( const Vector< typename Realtype< F >::type > & V_R, const Vector< typename Realtype< F >::type > & V_I )

Constructor.

Use this constructor to build a vector of type F out of two vectors with entries of type Realtype<F>; works only for F = Cmplx, G = Real

## ◆ Vector() [12/12]

template<class F >
template<class H >
 concepts::Vector< F >::Vector ( const Vector< H > & fnc, const Set< IndexRange > & indices )

Constructor.

Takes (copies) the entries at the indices indices of vector fnc.

Definition at line 287 of file vector.hh.

## ◆ ~Vector()

template<class F >
 virtual concepts::Vector< F >::~Vector ( )
virtual

## Member Function Documentation

template<class F >
 virtual Function& concepts::Vector< F >::add ( const Function< F > & fnc, F sc )
virtual

template<class F >
template<class H >
 Vector& concepts::Vector< F >::add ( const Vector< H > & fnc )
inline

Adds a vector of possible different length and type.

Definition at line 209 of file vector.hh.

template<class F >
template<class H >
 Vector< F > & concepts::Vector< F >::add ( const Vector< H > & fnc, F sc, uint offset = 0 )

Adds a vector of possible different length and type with an offset.

Definition at line 307 of file vector.hh.

## ◆ apply()

template<class F >
 Vector& concepts::Vector< F >::apply ( F fncconst F & )

Application operator to each component, e.g.

std::sin or std::conj

## ◆ assemble()

template<class F >
template<class G >
 Vector& concepts::Vector< F >::assemble ( const Space< G > & spc, const LinearForm< F, G > & lf )

Assembles the vector w.r.t. linear form lf and space spc.

## ◆ data()

template<class F >
 F* concepts::Vector< F >::data ( ) const
inline

Definition at line 192 of file vector.hh.

## ◆ fillEntries_()

template<class F >
template<class G >
 void concepts::Vector< F >::fillEntries_ ( const Space< G > & spc, const LinearForm< F, G > & lf )
protected

## ◆ info()

template<class F >
 virtual std::ostream& concepts::Vector< F >::info ( std::ostream & os ) const
protectedvirtual

## ◆ l1()

template<class F >
 Real concepts::Vector< F >::l1 ( ) const

l1 norm

## ◆ l2()

template<class F >
 Real concepts::Vector< F >::l2 ( ) const
inline

l2 norm

Definition at line 215 of file vector.hh.

## ◆ l2_2()

template<class F >
 Real concepts::Vector< F >::l2_2 ( ) const

l2 norm squared

## ◆ max()

template<class F >
 Real concepts::Vector< F >::max ( ) const

Maximum of the absolute values in the vector, ie. norm.

## ◆ n()

template<class F >
 uint concepts::Vector< F >::n ( ) const
inline

Elements in the vector.

Definition at line 224 of file vector.hh.

## ◆ operator F*()

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

Conversion operator.

Returns the array of values.

Definition at line 190 of file vector.hh.

## ◆ operator()() [1/2]

template<class F >
 virtual F& concepts::Vector< F >::operator() ( uint i )
inlinevirtual

Definition at line 140 of file vector.hh.

## ◆ operator()() [2/2]

template<class F >
 virtual F concepts::Vector< F >::operator() ( uint i ) const
inlinevirtual

Definition at line 143 of file vector.hh.

## ◆ operator*() [1/2]

template<class F >
 F concepts::Vector< F >::operator* ( const Vector< F > & fnc ) const

Inner product (v = this, w = \fnc)

or

for complex vectors respectivly.

## ◆ operator*() [2/2]

template<class F >
 Vector concepts::Vector< F >::operator* ( F c ) const

## ◆ operator*=()

template<class F >
 virtual Function& concepts::Vector< F >::operator*= ( F sc )
virtual

Scaling operator.

## ◆ operator+() [1/2]

template<class F >
 Vector concepts::Vector< F >::operator+ ( const Function< F > & fnc ) const

## ◆ operator+() [2/2]

template<class F >
 Vector concepts::Vector< F >::operator+ ( F c ) const

## ◆ operator+=() [1/2]

template<class F >
 virtual Function& concepts::Vector< F >::operator+= ( const Function< F > & fnc )
virtual

## ◆ operator+=() [2/2]

template<class F >
 virtual Function& concepts::Vector< F >::operator+= ( F c )
virtual

## ◆ operator-() [1/2]

template<class F >
 Vector concepts::Vector< F >::operator- ( const Function< F > & fnc ) const

## ◆ operator-() [2/2]

template<class F >
 Vector concepts::Vector< F >::operator- ( F c ) const

## ◆ operator-=() [1/2]

template<class F >
 virtual Function& concepts::Vector< F >::operator-= ( const Function< F > & fnc )
virtual

Subtraction operator.

## ◆ operator-=() [2/2]

template<class F >
 virtual Function& concepts::Vector< F >::operator-= ( F c )
virtual

## ◆ operator/()

template<class F >
 Vector concepts::Vector< F >::operator/ ( F c ) const

## ◆ operator/=()

template<class F >
 virtual Function& concepts::Vector< F >::operator/= ( F sc )
virtual

## ◆ operator=() [1/4]

template<class F >
 virtual Vector& concepts::Vector< F >::operator= ( const Function< F > & fnc )
virtual

## ◆ operator=() [2/4]

template<class F >
template<class H >
 Vector< F > & concepts::Vector< F >::operator= ( const Function< H > & fnc )

Definition at line 298 of file vector.hh.

## ◆ operator=() [3/4]

template<class F >
 Vector& concepts::Vector< F >::operator= ( const Vector< F > & fnc )

Assignement operator.

## ◆ operator=() [4/4]

template<class F >
 Vector& concepts::Vector< F >::operator= ( F c )

Assignement operator.

## ◆ resize()

template<class F >
 virtual void concepts::Vector< F >::resize ( uint n )
inlinevirtual

Sets a new size, previous data might be lost

Definition at line 195 of file vector.hh.

## ◆ reverse()

template<class F >
 void concepts::Vector< F >::reverse

Definition at line 316 of file vector.hh.

## ◆ size()

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

Definition at line 147 of file vector.hh.

## ◆ storeMatlab()

template<class F >
 void concepts::Vector< F >::storeMatlab ( const char * filename, const char * name = 0, bool append = false ) const

Stores the vector in a Matlab sparse matrix.

## ◆ write()

template<class F >
 const Vector& concepts::Vector< F >::write ( const std::string & fname ) const

Writes the vector to a file.

This should be endian proof.

Parameters
 fname Filename

## ◆ data_

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

Vector data.

Definition at line 243 of file vector.hh.

## ◆ storeMatlabCounter_

template<class F >
 uint concepts::Vector< F >::storeMatlabCounter_
staticprivate

Counts number of Matlab outputs (used to uniquely name the vectors)

Definition at line 248 of file vector.hh.

## ◆ v_

template<class F >
 F* concepts::Vector< F >::v_
private

Pointer to the vector data.

Definition at line 246 of file vector.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