CUV  0.9.201304091348
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Public Attributes | List of all members
cuv::dia_matrix< __value_type, __memory_space_type, __index_type > Class Template Reference

Class for diagonal matrices. More...

#include <dia_matrix.hpp>

Inheritance diagram for cuv::dia_matrix< __value_type, __memory_space_type, __index_type >:
Inheritance graph
[legend]
Collaboration diagram for cuv::dia_matrix< __value_type, __memory_space_type, __index_type >:
Collaboration graph
[legend]

Public Types

typedef __value_type value_type
 Type of the entries of matrix.
typedef const value_type const_value_type
 Type of the entries of matrix.
typedef matrix< __value_type,
__index_type > 
base_type
 Basic matrix type.
typedef __memory_space_type memory_space_type
 Whether this is a host or device matrix.
typedef base_type::index_type index_type
 Type of indices.
typedef const tensor
< value_type,
memory_space_type
const_vec_type
 Basic vector type used.
typedef tensor< value_type,
memory_space_type
vec_type
 Basic vector type used.
typedef tensor< int,
memory_space_type
intvec_type
 Type of offsets for diagonals.
typedef dia_matrix< value_type,
memory_space_type, index_type
my_type
 Type of this matix.
typedef vec_type::pointer_type ptr_type
- Public Types inherited from cuv::matrix< __value_type, __index_type >
typedef __value_type value_type
 Type of the entries of matrix.
typedef __index_type index_type
 Type of indices.

Public Member Functions

 ~dia_matrix ()
 dia_matrix (const index_type &h, const index_type &w, const int &num_dia, const int &stride, int row_fact=1)
 Creates diagonal matrix of given size, with given number of diagonals and stride.
void dealloc ()
std::vector< index_typeshape () const
 shape of a dia-matrix.
void alloc ()
const vec_typevec () const
 Return pointer to vector storing entries.
vec_typevec ()
 Return pointer to vector storing entries.
const vec_typevec_ptr () const
 Return reference to vector storing entries.
vec_typevec_ptr ()
 Return reference to vector storing entries.
ptr_type ptr ()
 Return reference to vector storing entries.
const ptr_type ptr () const
 Return reference to vector storing entries.
int num_dia () const
 Return number of diagonals.
unsigned int stride () const
 Return stride of matrix.
int row_fact () const
 Return steepness of diagonals.
template<class T >
void set_offsets (T begin, const T &end)
 Set the offsets of the diagonals in the DIA matrix This overload works with any iterator.
template<class T >
void set_offsets (const std::vector< T > &v)
 Set the offsets of the diagonals in the DIA matrix.
void post_update_offsets ()
 Update the internal reverse-mapping of diagonals to positions in the offset-array.
void set_offset (const index_type &idx, const index_type &val)
 Set a single diagonal offset in the matrix.
const_vec_typeget_dia (const int &k) const
 Return vector (view) containing specified diagonal.
vec_typeget_dia (const int &k)
 Return a vector (view) on the specified diagonal.
const intvec_typeget_offsets () const
 Return the vector of offsets.
intvec_typeget_offsets ()
 return the vector of offsets
int get_offset (const index_type &idx) const
 < Return offset of specified diagonal
void set (const index_type &i, const index_type &j, const value_type &val)
value_type operator() (const index_type &i, const index_type &j) const
 < Return matrix entry (i,j)
bool has (const index_type &i, const index_type &j) const
 < Return whether matrix entry is managed by sparse matrix
my_typeoperator= (const my_type &o)
 Assignment operator.
- Public Member Functions inherited from cuv::matrix< __value_type, __index_type >
 matrix (const index_type &h, const index_type &w)
 Basic constructor: set width and height of matrix but do not allocate any memory.
 matrix (const matrix< value_type, index_type > &m)
 Copy Constructor.
matrix< value_type, index_type > & operator= (const matrix< value_type, index_type > &m)
 assignment operator
virtual ~matrix ()
void resize (const index_type &h, const index_type &w)
 Resizing matrix: changing width and height without changing memory layout.
index_type w () const
 Return matrix width.
index_type h () const
 Return matrix height.
index_type n () const
 Return number of entries in matrix.

Public Attributes

int m_num_dia
 number of diagonals stored
unsigned int m_stride
 how long the stored diagonals are
vec_typem_vec
 stores the actual data
intvec_type m_offsets
 stores the offsets of the diagonals
std::map< int, index_typem_dia2off
 maps a diagonal to an offset
int m_row_fact
 factor by which to multiply a row index (allows matrices with "steep" diagonals)

Additional Inherited Members

- Protected Attributes inherited from cuv::matrix< __value_type, __index_type >
index_type m_width
 Width of matrix.
index_type m_height
 Heigth of matrix.

Detailed Description

template<class __value_type, class __memory_space_type, class __index_type = unsigned int>
class cuv::dia_matrix< __value_type, __memory_space_type, __index_type >

Class for diagonal matrices.

Definition at line 58 of file dia_matrix.hpp.

Constructor & Destructor Documentation

template<class __value_type, class __memory_space_type, class __index_type = unsigned int>
cuv::dia_matrix< __value_type, __memory_space_type, __index_type >::~dia_matrix ( )
inline

< Destructor. Deallocates Matrix.

Definition at line 79 of file dia_matrix.hpp.

template<class __value_type, class __memory_space_type, class __index_type = unsigned int>
cuv::dia_matrix< __value_type, __memory_space_type, __index_type >::dia_matrix ( const index_type h,
const index_type w,
const int &  num_dia,
const int &  stride,
int  row_fact = 1 
)
inline

Creates diagonal matrix of given size, with given number of diagonals and stride.

Parameters
hHeight of matrix
wWidth of matrix
num_diaNumber of diagonals in matrix
strideStride of matrix
row_factSteepness of diagonals. Only 1 is supported at the moment.

Definition at line 98 of file dia_matrix.hpp.

Member Function Documentation

template<class __value_type, class __memory_space_type, class __index_type = unsigned int>
my_type& cuv::dia_matrix< __value_type, __memory_space_type, __index_type >::operator= ( const my_type o)
inline

Assignment operator.

Assigns vector belonging to source to destination and sets source vector to NULL

Parameters
oSource matrix
Returns
Matrix of same size and type of o that now owns vector of entries of o.

Definition at line 260 of file dia_matrix.hpp.

template<class __value_type, class __memory_space_type, class __index_type = unsigned int>
void cuv::dia_matrix< __value_type, __memory_space_type, __index_type >::post_update_offsets ( )
inline

Update the internal reverse-mapping of diagonals to positions in the offset-array.

Normally, you do not need to call this function, except when changing the diagonal offsets manually.

Definition at line 181 of file dia_matrix.hpp.

template<class __value_type, class __memory_space_type, class __index_type = unsigned int>
void cuv::dia_matrix< __value_type, __memory_space_type, __index_type >::set_offset ( const index_type idx,
const index_type val 
)
inline

Set a single diagonal offset in the matrix.

The main diagonal has offset zero, lower diagonals are negative, higher diagonals are positive.

Parameters
idxthe (internal) index of the offset
valthe offset number

Definition at line 193 of file dia_matrix.hpp.

template<class __value_type, class __memory_space_type, class __index_type = unsigned int>
template<class T >
void cuv::dia_matrix< __value_type, __memory_space_type, __index_type >::set_offsets ( begin,
const T &  end 
)
inline

Set the offsets of the diagonals in the DIA matrix This overload works with any iterator.

The main diagonal has offset zero, lower diagonals are negative, higher diagonals are positive.

Parameters
beginstart of sequence
endone behind end of sequence

Definition at line 157 of file dia_matrix.hpp.

template<class __value_type, class __memory_space_type, class __index_type = unsigned int>
template<class T >
void cuv::dia_matrix< __value_type, __memory_space_type, __index_type >::set_offsets ( const std::vector< T > &  v)
inline

Set the offsets of the diagonals in the DIA matrix.

This overload works with a vector. The main diagonal has offset zero, lower diagonals are negative, higher diagonals are positive.

Parameters
va vector containing all offsets

Definition at line 171 of file dia_matrix.hpp.

template<class __value_type, class __memory_space_type, class __index_type = unsigned int>
std::vector<index_type> cuv::dia_matrix< __value_type, __memory_space_type, __index_type >::shape ( ) const
inline

shape of a dia-matrix.

This is quite inefficient ATM, mainly for compatibility with tensor.

Returns
a vector of height and width

Definition at line 123 of file dia_matrix.hpp.


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