Detailed Description

Vector of scalars.

This is a wrapper for a plain C array to provide a faudes style interface, incl. token IO, access to individual entries. There is also access to the internal C++ array. Note that libFAUDES does not implement any mathematical operations on vectors. For this purpose, one should employ some external library (e.g. BOOST, alglib, ...) via an appropriate set of wrapper functions.

The token format is as follows:

<Vector count="5">
1.50 -80 17 90 100
Vector(void)
Default constructor - sets dimension to 0.

Definition at line 391 of file hyb_parameter.h.

#include <hyb_parameter.h>

Public Member Functions

 Vector (void)
 Default constructor - sets dimension to 0. More...
 
 Vector (int dim)
 Constructor by dimension. More...
 
 Vector (const Vector &rSrc)
 Copy-constructor. More...
 
 Vector (const std::string &rFileName)
 Construct from file. More...
 
virtual ~Vector (void)
 Destructor. More...
 
void Clear (void)
 Clear all. More...
 
Idx Size (void) const
 Get size. More...
 
int Dimension (void) const
 Get dimension. More...
 
void Dimension (int dim)
 Set dimension. More...
 
void Zero (int dim=-1)
 Set to zero vector. More...
 
void Ones (int dim=-1)
 Set to ones. More...
 
const Scalar::TypeAt (int i) const
 Get entry. More...
 
void At (int i, const Scalar::Type &val)
 Set entry. More...
 
const Scalar::Typeoperator() (int i) const
 Cosmetic access operator. More...
 
Scalar::Typeoperator() (int i)
 Cosmetic access operator. More...
 
void CArray (int dim, const Scalar::Type *data)
 Set from std C array. More...
 
const Scalar::TypeCArray (void) const
 Access std C array. More...
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 Constructor. More...
 
 Type (const Type &rType)
 Copy constructor. More...
 
virtual ~Type (void)
 Destructor. More...
 
virtual TypeNew (void) const
 Construct on heap. More...
 
virtual TypeCopy (void) const
 Construct on heap. More...
 
virtual const TypeCast (const Type *pOther) const
 Cast other object to this type. More...
 
virtual TypeAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
virtual Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void Name (const std::string &rName)
 Set the objects's name. More...
 
virtual const std::string & Name (void) const
 Get objects's name. More...
 
virtual const std::string & TypeName (void) const
 Get objects's type name. More...
 
void Write (const Type *pContext=0) const
 Write configuration data to console. More...
 
void Write (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file. More...
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 Write configuration data to a file. More...
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to TokenWriter. More...
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to an XML file. More...
 
void XWrite (const Type *pContext=0) const
 Write configuration data in XML format to concole Note: this write function uses the virtual function DoXWrite(), to be reimplemented by derived classes. More...
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in XML format to TokenWriter. More...
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a string. More...
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a formated string. More...
 
void DWrite (const Type *pContext=0) const
 Write configuration data to console, debugging format. More...
 
void DWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file, debugging format. More...
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debug format to TokenWriter. More...
 
void SWrite (TokenWriter &rTw) const
 Write statistics comment to TokenWriter. More...
 
void SWrite (void) const
 Write statistics comment to console. More...
 
std::string ToSText (void) const
 Write statistics to a string. More...
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from file with label specified. More...
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from a string. More...
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from TokenReader with label sepcified. More...
 

Protected Member Functions

virtual VectorDoAssign (const Vector &rSrc)
 Assign from other vector. More...
 
virtual bool DoEqual (const Vector &rOther) const
 Test equality. More...
 
virtual void DoWrite (TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const
 Write to TokenWriter, see Type::Write for public wrappers. More...
 
virtual void DoSWrite (TokenWriter &tw) const
 Write statistic info to TokenWriter, see Type::SWrite for public wrapper. More...
 
virtual void DoRead (TokenReader &tr, const std::string &rLabel="", const Type *pContext=0)
 Read from TokenReader, see Type::Read for public wrappers. More...
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
bool DoEqual (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data of this object to TokenWriter in XML format. More...
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debugging format to TokenWriter. More...
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 Get objects's type definition. More...
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

int mDim
 
Scalar::TypempData
 

Constructor & Destructor Documentation

◆ Vector() [1/4]

Vector::Vector ( void  )

Default constructor - sets dimension to 0.

Definition at line 343 of file hyb_parameter.cpp.

◆ Vector() [2/4]

Vector::Vector ( int  dim)

Constructor by dimension.

Parameters
dimdimension

Definition at line 350 of file hyb_parameter.cpp.

◆ Vector() [3/4]

Vector::Vector ( const Vector rSrc)

Copy-constructor.

Definition at line 366 of file hyb_parameter.cpp.

◆ Vector() [4/4]

Vector::Vector ( const std::string &  rFileName)

Construct from file.

Definition at line 374 of file hyb_parameter.cpp.

◆ ~Vector()

Vector::~Vector ( void  )
virtual

Destructor.

Definition at line 383 of file hyb_parameter.cpp.

Member Function Documentation

◆ At() [1/2]

const Scalar::Type & Vector::At ( int  i) const

Get entry.

Parameters
iindex.
Returns
entry V(i)
Exceptions
Exception
  • index out of range (id 700);

Definition at line 455 of file hyb_parameter.cpp.

◆ At() [2/2]

void Vector::At ( int  i,
const Scalar::Type val 
)

Set entry.

Parameters
iindex
valvalue
Exceptions
Exception
  • index out of range (id 700);

Definition at line 465 of file hyb_parameter.cpp.

◆ CArray() [1/2]

void Vector::CArray ( int  dim,
const Scalar::Type data 
)

Set from std C array.

This version takes a copy of the provided data.

Parameters
dimdimension
datapointer to array of entries.

Definition at line 497 of file hyb_parameter.cpp.

◆ CArray() [2/2]

const Scalar::Type * Vector::CArray ( void  ) const

Access std C array.

Note that for zero dimension, this function returns NULL.

Returns
Const ref to internal C array

Definition at line 505 of file hyb_parameter.cpp.

◆ Clear()

void Vector::Clear ( void  )
virtual

Clear all.

Sets dimension to 0

Reimplemented from faudes::Type.

Definition at line 410 of file hyb_parameter.cpp.

◆ Dimension() [1/2]

void Vector::Dimension ( int  dim)

Set dimension.

This will invalidate the entries.

Parameters
dimNew dimension

Definition at line 424 of file hyb_parameter.cpp.

◆ Dimension() [2/2]

int Vector::Dimension ( void  ) const

Get dimension.

Returns
Number of entries

Definition at line 435 of file hyb_parameter.cpp.

◆ DoAssign()

Vector & Vector::DoAssign ( const Vector rSrc)
protectedvirtual

Assign from other vector.

Parameters
rSrcSource to copy from
Returns
Ref to this vector

Definition at line 389 of file hyb_parameter.cpp.

◆ DoEqual()

bool Vector::DoEqual ( const Vector rOther) const
protectedvirtual

Test equality.

Parameters
rOtherOther object to compare with.
Returns
True on match.

Definition at line 401 of file hyb_parameter.cpp.

◆ DoRead()

void Vector::DoRead ( TokenReader tr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
protectedvirtual

Read from TokenReader, see Type::Read for public wrappers.

The method invokes TokenReader::ReadBegin() to seek the specified section, reads subsequent symbols, and calls matching TokenReader::ReadEnd(). If no section is specified, the section is assumed to start at the current position of the token stream. If the current position is no begin token, the section "Vector" is read.

Parameters
trReference to TokenReader
rLabelLabel to read, defaults to current begin label or else "Vector"
pContextWrite context to provide contextual information
Exceptions
Exception
  • IO errors (id 1)
  • token mismatch (id 50)

Reimplemented from faudes::Type.

Definition at line 539 of file hyb_parameter.cpp.

◆ DoSWrite()

void Vector::DoSWrite ( TokenWriter tw) const
protectedvirtual

Write statistic info to TokenWriter, see Type::SWrite for public wrapper.

Parameters
twReference to TokenWriter
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 532 of file hyb_parameter.cpp.

◆ DoWrite()

void Vector::DoWrite ( TokenWriter tw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Write to TokenWriter, see Type::Write for public wrappers.

Parameters
twReference to TokenWriter
rLabelLabel of the section to write, defaults to name of set or "Vector"
pContextWrite context to provide contextual information (ignores)
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 511 of file hyb_parameter.cpp.

◆ Ones()

void Vector::Ones ( int  dim = -1)

Set to ones.

Either provide dimension, or use the default -1 to maintain the dimension.

Parameters
dimnumber of entries

Definition at line 448 of file hyb_parameter.cpp.

◆ operator()() [1/2]

Scalar::Type & Vector::operator() ( int  i)

Cosmetic access operator.

Parameters
iindex.
Exceptions
Exception
  • index out of range (id 700);

Definition at line 486 of file hyb_parameter.cpp.

◆ operator()() [2/2]

const Scalar::Type & Vector::operator() ( int  i) const

Cosmetic access operator.

Parameters
iindex.
Exceptions
Exception
  • index out of range (id 700);

Definition at line 476 of file hyb_parameter.cpp.

◆ Size()

Idx Vector::Size ( void  ) const

Get size.

Gets over all number of entries. Same as Dimension().

Returns
Dimension()

Definition at line 418 of file hyb_parameter.cpp.

◆ Zero()

void Vector::Zero ( int  dim = -1)

Set to zero vector.

Either provide dimension, or use the default -1 to maintain the dimension.

Parameters
dimnumber of entries

Definition at line 441 of file hyb_parameter.cpp.

Member Data Documentation

◆ mDim

int faudes::Vector::mDim
protected

Definition at line 566 of file hyb_parameter.h.

◆ mpData

Scalar::Type* faudes::Vector::mpData
protected

Definition at line 569 of file hyb_parameter.h.


The documentation for this class was generated from the following files:

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen