CoinUtils 2.10.15

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members
CoinDenseVector< T > Class Template Reference

Dense Vector. More...

`#include <CoinDenseVector.hpp>`

Collaboration diagram for CoinDenseVector< T >:
[legend]

## Public Member Functions
Get methods.
int | getNumElements () const
| Get the size. More...
int | size () const
const T * | getElements () const
| Get element values. More...
T * | getElements ()
| Get element values. More...
Set methods
void | clear ()
| Reset the vector (i.e. set all elemenets to zero) More...
CoinDenseVector & | operator= (const CoinDenseVector &)
| Assignment operator. More...
T & | operator[] (int index) const
| Member of array operator. More...
void | setVector (int size, const T *elems)
| Set vector size, and elements. More...
void | setConstant (int size, T elems)
| Elements set to have the same scalar value. More...
void | setElement (int index, T element)
| Set an existing element in the dense vector The first argument is the "index" into the elements() array. More...
void | resize (int newSize, T fill=T())
| Resize the dense vector to be the first newSize elements. More...
void | append (const CoinDenseVector &)
| Append a dense vector to this dense vector. More...
norms, sum and scale
T | oneNorm () const
| 1-norm of vector More...
double | twoNorm () const
| 2-norm of vector More...
T | infNorm () const
| infinity-norm of vector More...
T | sum () const
| sum of vector elements More...
void | scale (T factor)
| scale vector elements More...
Arithmetic operators.
void | operator+= (T value)
| add `value` to every entry More...
void | operator-= (T value)
| subtract `value` from every entry More...
void | operator*= (T value)
| multiply every entry by `value` More...
void | operator/= (T value)
| divide every entry by `value` More...
Constructors and destructors
| CoinDenseVector ()
| Default constructor. More...
| CoinDenseVector (int size, const T *elems)
| Alternate Constructors - set elements to vector of Ts. More...
| CoinDenseVector (int size, T element=T())
| Alternate Constructors - set elements to same scalar value. More...
| CoinDenseVector (const CoinDenseVector &)
| Copy constructors. More...
| ~CoinDenseVector ()
| Destructor. More...

## Private Member Functions
Private methods
void | gutsOfSetVector (int size, const T *elems)
| Copy internal data. More...
void | gutsOfSetConstant (int size, T value)
| Set all elements to a given value. More...

## Private Attributes
Private member data
int | nElements_
| Size of element vector. More...
T * | elements_
| Vector elements. More...

## Detailed Description

### template<typename T>
class CoinDenseVector< T >

Dense Vector.

Stores a dense (or expanded) vector of floating point values. Type of vector elements is controlled by templating. (Some working quantities such as accumulated sums are explicitly declared of type double). This allows the components of the vector integer, single or double precision.

Here is a sample usage:

        const int ne = 4;
        double el[ne] = { 10., 40., 1., 50. }

        // Create vector and set its value
        CoinDenseVector<double> r(ne,el);

        // access each element
        assert( r.getElements()[0]==10. );
        assert( r.getElements()[1]==40. );
        assert( r.getElements()[2]== 1. );
        assert( r.getElements()[3]==50. );

        // Test for equality
        CoinDenseVector<double> r1;
        r1=r;

        // Add dense vectors.
        // Similarly for subtraction, multiplication,
        // and division.
        CoinDenseVector<double> add = r + r1;
        assert( add[0] == 10.+10. );
        assert( add[1] == 40.+40. );
        assert( add[2] ==  1.+ 1. );
        assert( add[3] == 50.+50. );

        assert( r.sum() == 10.+40.+1.+50. );

Definition at line 67 of file CoinDenseVector.hpp.

## Constructor & Destructor Documentation

template<typename T>

CoinDenseVector< T >::CoinDenseVector | ( |  | ) |

Default constructor.

template<typename T>

CoinDenseVector< T >::CoinDenseVector | ( | int | size,
|  | const T * | elems
| ) |  |

Alternate Constructors - set elements to vector of Ts.

template<typename T>

CoinDenseVector< T >::CoinDenseVector | ( | int | size,
|  | T | element = `T()`
| ) |  |

Alternate Constructors - set elements to same scalar value.

template<typename T>

CoinDenseVector< T >::CoinDenseVector | ( | const CoinDenseVector< T > & |  | ) |

Copy constructors.

template<typename T>

CoinDenseVector< T >::~CoinDenseVector | ( |  | ) |

Destructor.

## Member Function Documentation

template<typename T>

int CoinDenseVector< T >::getNumElements | ( |  | ) | const
| inline

Get the size.

Definition at line 81 of file CoinDenseVector.hpp.

template<typename T>

int CoinDenseVector< T >::size | ( |  | ) | const
| inline

Definition at line 82 of file CoinDenseVector.hpp.

template<typename T>

const T* CoinDenseVector< T >::getElements | ( |  | ) | const
| inline

Get element values.

Definition at line 84 of file CoinDenseVector.hpp.

template<typename T>

T* CoinDenseVector< T >::getElements | ( |  | ) |
| inline

Get element values.

Definition at line 86 of file CoinDenseVector.hpp.

template<typename T>

void CoinDenseVector< T >::clear | ( |  | ) |

Reset the vector (i.e. set all elemenets to zero)

template<typename T>

CoinDenseVector& CoinDenseVector< T >::operator= | ( | const CoinDenseVector< T > & |  | ) |

Assignment operator.

template<typename T>

T& CoinDenseVector< T >::operator[] | ( | int | index | ) | const

Member of array operator.

template<typename T>

void CoinDenseVector< T >::setVector | ( | int | size,
|  | const T * | elems
| ) |  |

Set vector size, and elements.

Size is the length of the elements vector. The element vector is copied into this class instance's member data.

template<typename T>

void CoinDenseVector< T >::setConstant | ( | int | size,
|  | T | elems
| ) |  |

Elements set to have the same scalar value.

template<typename T>

void CoinDenseVector< T >::setElement | ( | int | index,
|  | T | element
| ) |  |

Set an existing element in the dense vector The first argument is the "index" into the elements() array.

template<typename T>

void CoinDenseVector< T >::resize | ( | int | newSize,
|  | T | fill = `T()`
| ) |  |

Resize the dense vector to be the first newSize elements.

If length is decreased, vector is truncated. If increased new entries, set to new default element

template<typename T>

void CoinDenseVector< T >::append | ( | const CoinDenseVector< T > & |  | ) |

Append a dense vector to this dense vector.

template<typename T>

T CoinDenseVector< T >::oneNorm | ( |  | ) | const
| inline

1-norm of vector

Definition at line 128 of file CoinDenseVector.hpp.

template<typename T>

double CoinDenseVector< T >::twoNorm | ( |  | ) | const
| inline

2-norm of vector

Definition at line 135 of file CoinDenseVector.hpp.

template<typename T>

T CoinDenseVector< T >::infNorm | ( |  | ) | const
| inline

infinity-norm of vector

Definition at line 144 of file CoinDenseVector.hpp.

template<typename T>

T CoinDenseVector< T >::sum | ( |  | ) | const
| inline

sum of vector elements

Definition at line 151 of file CoinDenseVector.hpp.

template<typename T>

void CoinDenseVector< T >::scale | ( | T | factor | ) |
| inline

scale vector elements

Definition at line 158 of file CoinDenseVector.hpp.

template<typename T>

void CoinDenseVector< T >::operator+= | ( | T | value | ) |

add `value` to every entry

template<typename T>

void CoinDenseVector< T >::operator-= | ( | T | value | ) |

subtract `value` from every entry

template<typename T>

void CoinDenseVector< T >::operator*= | ( | T | value | ) |

multiply every entry by `value`

template<typename T>

void CoinDenseVector< T >::operator/= | ( | T | value | ) |

divide every entry by `value`

template<typename T>

void CoinDenseVector< T >::gutsOfSetVector | ( | int | size,
|  | const T * | elems
| ) |  |
| private

Copy internal data.

template<typename T>

void CoinDenseVector< T >::gutsOfSetConstant | ( | int | size,
|  | T | value
| ) |  |
| private

Set all elements to a given value.

## Member Data Documentation

template<typename T>

int CoinDenseVector< T >::nElements_
| private

Size of element vector.

Definition at line 72 of file CoinDenseVector.hpp.

template<typename T>

T* CoinDenseVector< T >::elements_
| private

Vector elements.

Definition at line 74 of file CoinDenseVector.hpp.

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

- /tmp/CoinUtils-2.10.15/CoinUtils/src/CoinDenseVector.hpp