CUSP
Loading...
Searching...
No Matches
cusp::array2d_view< ArrayView, Orientation > Class Template Reference

#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
 
transpose_const_view_type T (void) const
 

Public Members

size_t pitch
 
values_array_type values
 

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
}
2D array of elements that may reside in "host" or "device" memory space
The array2d class is a 2D vector container that may contain elements stored in "host" or "device" mem...
Definition array2d.h:94
void print(const Printable &p)
print a textual representation of an object
Print textual representation of an object.

Definition at line 328 of file array2d.h.

Constructor & Destructor Documentation

◆ array2d_view() [1/4]

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 376 of file array2d.h.

◆ array2d_view() [2/4]

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 382 of file array2d.h.

◆ array2d_view() [3/4]

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 392 of file array2d.h.

◆ array2d_view() [4/4]

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 404 of file array2d.h.

Member Function Documentation

◆ column() [1/2]

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

◆ column() [2/2]

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

◆ operator()()

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.

◆ resize() [1/2]

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.

◆ resize() [2/2]

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.

◆ row() [1/2]

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

◆ row() [2/2]

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

◆ T()

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

Construct a array2d_view of current matrix with opposite orientation. Mainly useful for interacting with BLAS routines.

Returns
array2d_view with new orientation.

Member Data Documentation

◆ pitch

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 368 of file array2d.h.

◆ values

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

1D array of values.

Definition at line 372 of file array2d.h.