Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Public Methods | Public Members | List of all members
cusp::array2d_view< ArrayView, Orientation > Class Template Reference

Detailed description

template<typename ArrayView, class Orientation = cusp::row_major>
class cusp::array2d_view< ArrayView, Orientation >

The array2d_view is a view of a array2d container.

Template Parameters
IteratorThe iterator type used to encapsulate the underlying data.
Overview
array2d_view is a container that wraps existing iterators in array2d datatypes to interoperate with cusp algorithms.
Example
// include cusp array2d header file
#include <cusp/array2d.h>
#include <cusp/print.h>
int main()
{
// Define the container type
// Get reference to array view type
typedef Array::view View;
// Allocate array1d container with 10 elements
Array v(3,3);
// Set the entries in the matrix using shorthand operator
v(0,0) = 0; v(0,1) = 1; v(0,2) = 2;
v(1,0) = 3; v(1,1) = 4; v(1,2) = 5;
v(2,0) = 6; v(2,1) = 7; v(2,2) = 8;
// Create array2d_view, v_view, from array2d v
View v_view(v);
v_view(0,0) = -1; v_view(1,1) = -2; v_view(2,2) = -3;
// print the updated array2d matrix
}
Examples:
array2d_raw.cu.

Definition at line 318 of file array2d.h.

#include <array2d.h>

Inheritance diagram for cusp::array2d_view< ArrayView, Orientation >:

Public Methods

 array2d_view (void)
 
 array2d_view (const array2d_view &a)
 
 array2d_view (array2d< typename Parent::value_type, typename Parent::memory_space, orientation > &a)
 
template<typename Array2 >
 array2d_view (size_t num_rows, size_t num_cols, size_t pitch, const Array2 &values)
 
values_array_type::reference operator() (const size_t i, const size_t j) const
 
void resize (const size_t num_rows, const size_t num_cols)
 
void resize (const size_t num_rows, const size_t num_cols, const size_t pitch)
 
row_view row (size_t i)
 
column_view column (size_t i)
 
row_view row (size_t i) const
 
column_view column (size_t i) const
 

Public Members

size_t pitch
 
values_array_type values
 

Constructor & Destructor Documentation

template<typename ArrayView, class Orientation = cusp::row_major>
cusp::array2d_view< ArrayView, Orientation >::array2d_view ( void  )
inline

This constructor creates an empty array2d vector.

Definition at line 361 of file array2d.h.

template<typename ArrayView, class Orientation = cusp::row_major>
cusp::array2d_view< ArrayView, Orientation >::array2d_view ( const array2d_view< ArrayView, Orientation > &  a)
inline

This constructor creates a array2d_view from another array2d_view.

Parameters
aarray2d_view used to create this array2d_view.

Definition at line 367 of file array2d.h.

template<typename ArrayView, class Orientation = cusp::row_major>
cusp::array2d_view< ArrayView, Orientation >::array2d_view ( array2d< typename Parent::value_type, typename Parent::memory_space, orientation > &  a)
inline

This constructor creates a array2d_view from a array2d container.

Parameters
aarray2d used to construct this array2d_view.

Definition at line 377 of file array2d.h.

template<typename ArrayView, class Orientation = cusp::row_major>
template<typename Array2 >
cusp::array2d_view< ArrayView, Orientation >::array2d_view ( size_t  num_rows,
size_t  num_cols,
size_t  pitch,
const Array2 &  values 
)
inline

This constructor creates a array2d vector with the given shape, fills the entries with a given value and sets the pitch.

Template Parameters
Array2The type of values used to construct this array2d_view.
Parameters
num_rowsThe number of array2d_view rows.
num_colsThe number of array2d_view columns.
valuesThe initial value of all entries.
pitchThe stride between entries in the major dimension.

Definition at line 389 of file array2d.h.

Member Function Documentation

template<typename ArrayView, class Orientation = cusp::row_major>
column_view cusp::array2d_view< ArrayView, Orientation >::column ( size_t  i)

This method generates a array1d_view of column i of this array2d_view matrix

Parameters
iThe column index used to create array1d_view
Returns
array1d_view of column i
template<typename ArrayView, class Orientation = cusp::row_major>
column_view cusp::array2d_view< ArrayView, Orientation >::column ( size_t  i) const

This method generates a const array1d_view of column i of this array2d_view matrix

Parameters
iThe column index used to create array1d_view
Returns
const array1d_view of column i
template<typename ArrayView, class Orientation = cusp::row_major>
values_array_type::reference cusp::array2d_view< ArrayView, Orientation >::operator() ( const size_t  i,
const size_t  j 
) const

Subscript access to the data contained in this array2d_view.

Parameters
iRow index for which data should be accessed.
jColumn index for which data should be accessed.
Returns
Read reference to data.
template<typename ArrayView, class Orientation = cusp::row_major>
void cusp::array2d_view< ArrayView, Orientation >::resize ( const size_t  num_rows,
const size_t  num_cols 
)

This method will resize this array2d_view to the specified dimensions. If the number of total entries is smaller than this array2d_view's current size this array2d_view is truncated, otherwise this array2d_view is extended with the value of new entries undefined.

Parameters
num_rowsThe number of rows this array2d_view should contain.
num_colsThe number of columns this array2d_view should contain.
template<typename ArrayView, class Orientation = cusp::row_major>
void cusp::array2d_view< ArrayView, Orientation >::resize ( const size_t  num_rows,
const size_t  num_cols,
const size_t  pitch 
)

This method will resize this array2d_view to the specified dimensions. If the number of total entries is smaller than this array2d_view's current size this array2d_view is truncated, otherwise this array2d_view is extended with the value of new entries undefined.

Parameters
num_rowsThe number of rows this array2d_view should contain.
num_colsThe number of columns this array2d_view should contain.
pitchThe stride between major dimension entries this array2d_view should contain.
template<typename ArrayView, class Orientation = cusp::row_major>
row_view cusp::array2d_view< ArrayView, Orientation >::row ( size_t  i)

This method generates a array1d_view of row i of this array2d_view matrix

Parameters
iThe row index used to create array1d_view
Returns
array1d_view of row i
template<typename ArrayView, class Orientation = cusp::row_major>
row_view cusp::array2d_view< ArrayView, Orientation >::row ( size_t  i) const

This method generates a const array1d_view of row i of this array2d_view matrix

Parameters
iThe row index used to create array1d_view
Returns
const array1d_view of row i

Member Data Documentation

template<typename ArrayView, class Orientation = cusp::row_major>
size_t cusp::array2d_view< ArrayView, Orientation >::pitch

The stride between consecutive elements along the major dimension.

Definition at line 353 of file array2d.h.

template<typename ArrayView, class Orientation = cusp::row_major>
values_array_type cusp::array2d_view< ArrayView, Orientation >::values

1D array of values.

Definition at line 357 of file array2d.h.