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

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# CoinDenseVector< T > Class Template Reference

Dense Vector. More...

`#include <CoinDenseVector.hpp>`

Collaboration diagram for CoinDenseVector< T >:

[legend]
List of all members.

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

## 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 64 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 78 of file CoinDenseVector.hpp.

References CoinDenseVector< T >::nElements_.

template<typename T>

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

Get the size.

Definition at line 79 of file CoinDenseVector.hpp.

References CoinDenseVector< T >::nElements_.

Referenced by operator *(), operator+(), operator-(), and operator/().

template<typename T>

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

Get element values.

Definition at line 81 of file CoinDenseVector.hpp.

References CoinDenseVector< T >::elements_.

Referenced by operator *(), operator+(), operator-(), and operator/().

template<typename T>

T* CoinDenseVector< T >::getElements | ( |  | ) | `[inline]`

Get element values.

Definition at line 83 of file CoinDenseVector.hpp.

References CoinDenseVector< T >::elements_.

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 125 of file CoinDenseVector.hpp.

References CoinAbs(), CoinDenseVector< T >::elements_, and CoinDenseVector< T >::nElements_.

template<typename T>

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

2-norm of vector

Definition at line 132 of file CoinDenseVector.hpp.

References CoinDenseVector< T >::elements_, and CoinDenseVector< T >::nElements_.

template<typename T>

T CoinDenseVector< T >::infNorm | ( |  | ) | const`[inline]`

infinity-norm of vector

Definition at line 141 of file CoinDenseVector.hpp.

References CoinAbs(), CoinMax(), CoinDenseVector< T >::elements_, and CoinDenseVector< T >::nElements_.

template<typename T>

T CoinDenseVector< T >::sum | ( |  | ) | const`[inline]`

sum of vector elements

Definition at line 148 of file CoinDenseVector.hpp.

References CoinDenseVector< T >::elements_, and CoinDenseVector< T >::nElements_.

template<typename T>

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

scale vector elements

Definition at line 155 of file CoinDenseVector.hpp.

References CoinDenseVector< T >::elements_, and CoinDenseVector< T >::nElements_.

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 69 of file CoinDenseVector.hpp.

Referenced by CoinDenseVector< T >::getNumElements(), CoinDenseVector< T >::infNorm(), CoinDenseVector< T >::oneNorm(), CoinDenseVector< T >::scale(), CoinDenseVector< T >::size(), CoinDenseVector< T >::sum(), and CoinDenseVector< T >::twoNorm().

template<typename T>

T* CoinDenseVector< T >::elements_`[private]`

Vector elements.

Definition at line 71 of file CoinDenseVector.hpp.

Referenced by CoinDenseVector< T >::getElements(), CoinDenseVector< T >::infNorm(), CoinDenseVector< T >::oneNorm(), CoinDenseVector< T >::scale(), CoinDenseVector< T >::sum(), and CoinDenseVector< T >::twoNorm().

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

- /home/coin/SVN-release/Blis-0.91.0/CoinUtils/src/CoinDenseVector.hpp