Extended CUDA Library (ecuda)  2.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Types | Public Member Functions | Friends | List of all members
ecuda::matrix< T, Alloc, P > Class Template Reference

A resizable matrix stored in device memory. More...

#include <matrix.hpp>

Inheritance diagram for ecuda::matrix< T, Alloc, P >:

Public Types

typedef base_type::value_type value_type
 cell data type More...
 
typedef Alloc allocator_type
 allocator type More...
 
typedef base_type::size_type size_type
 unsigned integral type More...
 
typedef base_type::difference_type difference_type
 signed integral type More...
 
typedef base_type::reference reference
 cell reference type More...
 
typedef base_type::const_reference const_reference
 cell const reference type More...
 
typedef base_type::pointer pointer
 cell pointer type More...
 
typedef make_const< pointer >::type const_pointer
 cell const pointer type More...
 
typedef base_type::row_type row_type
 matrix row container type More...
 
typedef base_type::column_type column_type
 matrix column container type More...
 
typedef base_type::const_row_type const_row_type
 matrix const row container type More...
 
typedef
base_type::const_column_type 
const_column_type
 matrix const column container type More...
 
typedef base_type::iterator iterator
 iterator type More...
 
typedef base_type::const_iterator const_iterator
 const iterator type More...
 
typedef base_type::reverse_iterator reverse_iterator
 reverse iterator type More...
 
typedef
base_type::const_reverse_iterator 
const_reverse_iterator
 const reverse iterator type More...
 
typedef
impl::matrix_kernel_argument
< T, Alloc > 
kernel_argument
 kernel argument type More...
 
typedef const
impl::matrix_kernel_argument
< T, Alloc > 
const_kernel_argument
 const kernel argument type More...
 

Public Member Functions

__HOST__ matrix (const size_type numberRows=0, const size_type numberColumns=0, const value_type &value=value_type(), const allocator_type &allocator=allocator_type())
 Constructs a matrix with dimensions numberRows x numberColumns filled with copies of elements with value value. More...
 
__HOST__ matrix (const matrix &src)
 Copy constructor. More...
 
__HOST__ matrix (const matrix &src, const allocator_type &alloc)
 Copy constructor. More...
 
__HOST__ matrixoperator= (const matrix &other)
 
__HOST__ __DEVICE__ iterator begin () __NOEXCEPT__
 Returns an iterator to the first element of the container. More...
 
__HOST__ __DEVICE__ iterator end () __NOEXCEPT__
 Returns an iterator to the element following the last element of the container. More...
 
__HOST__ __DEVICE__ const_iterator begin () const __NOEXCEPT__
 Returns an iterator to the first element of the container. More...
 
__HOST__ __DEVICE__ const_iterator end () const __NOEXCEPT__
 Returns an iterator to the element following the last element of the container. More...
 
__HOST__ __DEVICE__
reverse_iterator 
rbegin () __NOEXCEPT__
 Returns a reverse iterator to the first element of the reversed container. More...
 
__HOST__ __DEVICE__
reverse_iterator 
rend () __NOEXCEPT__
 Returns a reverse iterator to the element following the last element of the reversed container. More...
 
__HOST__ __DEVICE__
const_reverse_iterator 
rbegin () const __NOEXCEPT__
 Returns a reverse iterator to the first element of the reversed container. More...
 
__HOST__ __DEVICE__
const_reverse_iterator 
rend () const __NOEXCEPT__
 Returns a reverse iterator to the element following the last element of the reversed container. More...
 
__HOST__ __DEVICE__ size_type size () const __NOEXCEPT__
 Returns the number of elements in the container (numberRows*numberColumns). More...
 
__HOST__ __DEVICE__
__CONSTEXPR__ size_type 
max_size () const __NOEXCEPT__
 Returns the maximum number of elements the container is able to hold due to system or library implementation limitations. More...
 
__HOST__ __DEVICE__ size_type number_rows () const __NOEXCEPT__
 Returns the number of rows in the container. More...
 
__HOST__ __DEVICE__ size_type number_columns () const __NOEXCEPT__
 Returns the number of columns in the container. More...
 
__HOST__ void resize (const size_type newNumberRows, const size_type newNumberColumns, const value_type &value=value_type())
 Resizes the container to have dimensions newNumberRows x newNumberColumns. More...
 
__HOST__ __DEVICE__ bool empty () const __NOEXCEPT__
 Checks if the container has no elements. More...
 
__HOST__ __DEVICE__ row_type get_row (const size_type rowIndex)
 Gets a view object of a single row of the matrix. More...
 
__HOST__ __DEVICE__ const_row_type get_row (const size_type rowIndex) const
 Gets a view object of a single row of the matrix. More...
 
__HOST__ __DEVICE__ column_type get_column (const size_type columnIndex)
 Gets a view object of a single column of the matrix. More...
 
__HOST__ __DEVICE__
const_column_type 
get_column (const size_type columnIndex) const
 Gets a view object of a single column of the matrix. More...
 
__DEVICE__ reference at (size_type rowIndex, size_type columnIndex)
 Returns a reference to the element at specified row and column index, with bounds checking. More...
 
__DEVICE__ const_reference at (size_type rowIndex, size_type columnIndex) const
 Returns a constant reference to the element at specified row and column index, with bounds checking. More...
 
__DEVICE__ reference operator() (const size_type rowIndex, const size_type columnIndex)
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__DEVICE__ const_reference operator() (const size_type rowIndex, const size_type columnIndex) const
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__HOST__ __DEVICE__ row_type operator[] (const size_type rowIndex)
 operator[](rowIndex) alias for get_row(rowIndex) More...
 
__HOST__ __DEVICE__ const_row_type operator[] (const size_type rowIndex) const
 operator[](rowIndex) alias for get_row(rowIndex) More...
 
__DEVICE__ reference front ()
 Returns a reference to the first element in the container. More...
 
__DEVICE__ reference back ()
 Returns a reference to the last element in the container. More...
 
__DEVICE__ const_reference front () const
 Returns a reference to the first element in the container. More...
 
__DEVICE__ const_reference back () const
 Returns a reference to the last element in the container. More...
 
__HOST__ __DEVICE__ pointer data () __NOEXCEPT__
 Returns pointer to the underlying array serving as element storage. More...
 
__HOST__ __DEVICE__ const_pointer data () const __NOEXCEPT__
 Returns pointer to the underlying array serving as element storage. More...
 
__HOST__ __DEVICE__ void fill (const value_type &value)
 Assigns a given value to all elements in the container. More...
 
__HOST__ __DEVICE__ void swap (matrix &other)
 Exchanges the contents of the container with those of the other. More...
 
__HOST__ allocator_type get_allocator () const
 Returns the allocator associated with the container. More...
 
template<class Alloc2 >
__HOST__ __DEVICE__ bool operator== (const matrix< value_type, Alloc2 > &other) const
 Checks if the contents of two matrices are equal. More...
 
template<class Alloc2 >
__HOST__ __DEVICE__ bool operator!= (const matrix< value_type, Alloc2 > &other) const
 Checks if the contents of two matrices are not equal. More...
 
template<class Alloc2 >
__HOST__ __DEVICE__ bool operator< (const matrix< value_type, Alloc2 > &other) const
 Compares the contents of two matrices lexicographically. More...
 
template<class Alloc2 >
__HOST__ __DEVICE__ bool operator> (const matrix< value_type, Alloc2 > &other) const
 Compares the contents of two matrices lexicographically. More...
 
template<class Alloc2 >
__HOST__ __DEVICE__ bool operator<= (const matrix< value_type, Alloc2 > &other) const
 Compares the contents of two matrices lexicographically. More...
 
template<class Alloc2 >
__HOST__ __DEVICE__ bool operator>= (const matrix< value_type, Alloc2 > &other) const
 Compares the contents of two matrices lexicographically. More...
 

Friends

template<typename U , class Alloc2 , class Q >
class matrix
 

Detailed Description

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
class ecuda::matrix< T, Alloc, P >

A resizable matrix stored in device memory.

A matrix is defined as a 2D structure of dimensions rows*columns. The default implementation uses pitched memory where a 2D block of video memory is allocated with width=columns and height=rows. Pitched memory is aligned in a device-dependent manner so that calls to individual elements can be threaded more efficiently (i.e. minimizing the number of read operations required to supply data to multiple threads). Consult the CUDA API documentation for a more verbose explanation.

Methods are prefaced with appropriate keywords to declare them as host and/or device capable. In general: operations requiring memory allocation/deallocation are host only, operations to access the values of specific elements are device only, and copy operations on ranges of data and accessors of general information can be performed on both the host and device.

Memory use can be conceptualized as:

|- columns -|
|---- pitch -----|
_ +-----------+----+
| | |xxxx| x = allocated but not used, just padding to
| | |xxxx| enforce an efficient memory alignment
rows | |xxxx|
| | |xxxx|
|_ +-----------+----+

As a result, it is highly desirable for threading to utilize a column-wise orientation. For example, a good kernel to perform an operation on the elements of a matrix might be:

template<typename T> __global__ void doMatrixOperation( typename ecuda::matrix<T>::kernel_argument matrix )
{
const int row = blockIdx.x;
const int col = blockDim.y*gridDim.y; // each thread gets a different column value
if( row < matrix.number_rows() && col < matrix.number_columns() ) {
T& value = matrix(row,col);
// ... do work on value
}
}

This could be called from host code like:

// ... fill matrix with data
dim3 grid( 100, 1 ), block( 1, 1000 );
doMatrixOperation<<<grid,block>>>( matrix );

Unfortunately, CUDA solutions are very problem specific, so there is no generally applicable example for specifying how thread blocks should be defined. The size of the matrix, hardware limitations, CUDA API limitations, etc. all play a part. For example, the above implementation won't work in earlier versions of CUDA since blockDim.y was limited to 512 (at the time of this writing it was 1024 in the newer versions of CUDA).

Just keep in mind that the column dimension lies in contiguous memory, and the row dimension is contiguous blocks of columns; thus, an implementation that aims to have concurrently running threads accessing column >>>> row will run much more efficiently.

Matrix iterators (via begin(),end(),rbegin(),rend()) and lexicographical comparisons traverse the matrix linearly in row-major fashion (i.e. each column of the first row is traversed, then each column of the next row, and so on...).

Definition at line 126 of file matrix.hpp.

Member Typedef Documentation

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef Alloc ecuda::matrix< T, Alloc, P >::allocator_type

allocator type

Definition at line 134 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::column_type ecuda::matrix< T, Alloc, P >::column_type

matrix column container type

Definition at line 143 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::const_column_type ecuda::matrix< T, Alloc, P >::const_column_type

matrix const column container type

Definition at line 145 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::const_iterator ecuda::matrix< T, Alloc, P >::const_iterator

const iterator type

Definition at line 148 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef const impl::matrix_kernel_argument<T,Alloc> ecuda::matrix< T, Alloc, P >::const_kernel_argument

const kernel argument type

Definition at line 153 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef make_const<pointer>::type ecuda::matrix< T, Alloc, P >::const_pointer

cell const pointer type

Definition at line 140 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::const_reference ecuda::matrix< T, Alloc, P >::const_reference

cell const reference type

Definition at line 138 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::const_reverse_iterator ecuda::matrix< T, Alloc, P >::const_reverse_iterator

const reverse iterator type

Definition at line 150 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::const_row_type ecuda::matrix< T, Alloc, P >::const_row_type

matrix const row container type

Definition at line 144 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::difference_type ecuda::matrix< T, Alloc, P >::difference_type

signed integral type

Definition at line 136 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::iterator ecuda::matrix< T, Alloc, P >::iterator

iterator type

Definition at line 147 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef impl::matrix_kernel_argument<T,Alloc> ecuda::matrix< T, Alloc, P >::kernel_argument

kernel argument type

Definition at line 152 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::pointer ecuda::matrix< T, Alloc, P >::pointer

cell pointer type

Definition at line 139 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::reference ecuda::matrix< T, Alloc, P >::reference

cell reference type

Definition at line 137 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::reverse_iterator ecuda::matrix< T, Alloc, P >::reverse_iterator

reverse iterator type

Definition at line 149 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::row_type ecuda::matrix< T, Alloc, P >::row_type

matrix row container type

Definition at line 142 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::size_type ecuda::matrix< T, Alloc, P >::size_type

unsigned integral type

Definition at line 135 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
typedef base_type::value_type ecuda::matrix< T, Alloc, P >::value_type

cell data type

Definition at line 133 of file matrix.hpp.

Constructor & Destructor Documentation

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ ecuda::matrix< T, Alloc, P >::matrix ( const size_type  numberRows = 0,
const size_type  numberColumns = 0,
const value_type value = value_type(),
const allocator_type allocator = allocator_type() 
)
inline

Constructs a matrix with dimensions numberRows x numberColumns filled with copies of elements with value value.

Parameters
numberRowsnumber of rows (default: 0)
numberColumnsnumber of columns (default: 0)
valuethe value to initialize elements of the matrix with (default: T())
allocatorallocator to use for all memory allocations of this container (does not normally need to be specified, by default the internal ecuda pitched memory allocator)

Definition at line 204 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ ecuda::matrix< T, Alloc, P >::matrix ( const matrix< T, Alloc, P > &  src)
inline

Copy constructor.

Constructs the matrix with a copy of the contents of src.

Parameters
srcAnother matrix object of the same type, whose contents are copied.

Definition at line 219 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ ecuda::matrix< T, Alloc, P >::matrix ( const matrix< T, Alloc, P > &  src,
const allocator_type alloc 
)
inline

Copy constructor.

Constructs the matrix with a copy of the contents of src.

Parameters
srcAnother matrix object of the same type, whose contents are copied.
allocAllocator to use for all memory allocations of this container.

Definition at line 237 of file matrix.hpp.

Member Function Documentation

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::matrix< T, Alloc, P >::at ( size_type  rowIndex,
size_type  columnIndex 
)
inline

Returns a reference to the element at specified row and column index, with bounds checking.

If the row and column are not within the range of the container, the current kernel will exit and cudaGetLastError will return cudaErrorUnknown.

Parameters
rowIndexposition of the row to return
columnIndexposition of the column to return
Returns
Reference to the requested element.

Definition at line 470 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::matrix< T, Alloc, P >::at ( size_type  rowIndex,
size_type  columnIndex 
) const
inline

Returns a constant reference to the element at specified row and column index, with bounds checking.

If the row and column are not within the range of the container, the current kernel will exit and cudaGetLastError will return cudaErrorUnknown.

Parameters
rowIndexposition of the row to return
columnIndexposition of the column to return
Returns
Reference to the requested element.

Definition at line 496 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::matrix< T, Alloc, P >::back ( )
inline

Returns a reference to the last element in the container.

This is effectively the element at position (numberRows-1,numberColumns-1). Calling back on an empty container is undefined.

Returns
Reference to the last element.

Definition at line 564 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::matrix< T, Alloc, P >::back ( ) const
inline

Returns a reference to the last element in the container.

This is effectively the element at position (numberRows-1,numberColumns-1). Calling back on an empty container is undefined.

Returns
Reference to the last element.

Definition at line 582 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ iterator ecuda::matrix< T, Alloc, P >::begin ( )
inline

Returns an iterator to the first element of the container.

If the container is empty, the returned iterator will be equal to end().

Returns
Iterator to the first element.

Definition at line 278 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_iterator ecuda::matrix< T, Alloc, P >::begin ( ) const
inline

Returns an iterator to the first element of the container.

If the container is empty, the returned iterator will be equal to end().

Returns
Iterator to the first element.

Definition at line 296 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ pointer ecuda::matrix< T, Alloc, P >::data ( )
inline

Returns pointer to the underlying array serving as element storage.

The pointer is such that range [data(),data()+size()) is always a valid range, even if the container is empty.

Returns
Pointer to the underlying element storage.

Definition at line 592 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_pointer ecuda::matrix< T, Alloc, P >::data ( ) const
inline

Returns pointer to the underlying array serving as element storage.

The pointer is such that range [data(),data()+size()) is always a valid range, even if the container is empty.

Returns
Pointer to the underlying element storage.

Definition at line 602 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::matrix< T, Alloc, P >::empty ( ) const
inline

Checks if the container has no elements.

Returns
true if the container is empty, false otherwise.

Definition at line 408 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ iterator ecuda::matrix< T, Alloc, P >::end ( )
inline

Returns an iterator to the element following the last element of the container.

The element acts as a placeholder; attempting to access it results in undefined behaviour.

Returns
Iterator to the element following the last element.

Definition at line 287 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_iterator ecuda::matrix< T, Alloc, P >::end ( ) const
inline

Returns an iterator to the element following the last element of the container.

The element acts as a placeholder; attempting to access it results in undefined behaviour.

Returns
Iterator to the element following the last element.

Definition at line 305 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ void ecuda::matrix< T, Alloc, P >::fill ( const value_type value)
inline

Assigns a given value to all elements in the container.

Parameters
valuethe value to assign to the elements

Definition at line 609 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::matrix< T, Alloc, P >::front ( )
inline

Returns a reference to the first element in the container.

This is effectively the element at position (0,0). Calling front on an empty container is undefined.

Returns
Reference to the first element.

Definition at line 555 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::matrix< T, Alloc, P >::front ( ) const
inline

Returns a reference to the first element in the container.

This is effectively the element at position (0,0). Calling front on an empty container is undefined.

Returns
Reference to the first element.

Definition at line 573 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ allocator_type ecuda::matrix< T, Alloc, P >::get_allocator ( ) const
inline

Returns the allocator associated with the container.

Returns
The associated allocator.

Definition at line 628 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ column_type ecuda::matrix< T, Alloc, P >::get_column ( const size_type  columnIndex)
inline

Gets a view object of a single column of the matrix.

The view object is guaranteed to perform no memory allocations or deallocation, and merely holds a pointer to the start of the row and provides methods to traverse, access, and alter the underlying data.

Parameters
columnIndexindex of the column to isolate
Returns
view object for the specified column

Definition at line 445 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_column_type ecuda::matrix< T, Alloc, P >::get_column ( const size_type  columnIndex) const
inline

Gets a view object of a single column of the matrix.

The view object is guaranteed to perform no memory allocations or deallocation, and merely holds a pointer to the start of the row and provides methods to traverse and access the underlying data. In addition, the constness of this matrix is enforced so the view will not allow any alterations to the underlying data.

Parameters
columnIndexindex of the column to isolate
Returns
view object for the specified column

Definition at line 458 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ row_type ecuda::matrix< T, Alloc, P >::get_row ( const size_type  rowIndex)
inline

Gets a view object of a single row of the matrix.

The view object is guaranteed to perform no memory allocations or deallocation, and merely holds a pointer to the start of the row and provides methods to traverse, access, and alter the underlying data.

Parameters
rowIndexof the row to isolate
Returns
view object for the specified row

Definition at line 420 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_row_type ecuda::matrix< T, Alloc, P >::get_row ( const size_type  rowIndex) const
inline

Gets a view object of a single row of the matrix.

The view object is guaranteed to perform no memory allocations or deallocation, and merely holds a pointer to the start of the row and provides methods to traverse and access the underlying data. In addition, the constness of this matrix is enforced so the view will not allow any alterations to the underlying data.

Parameters
rowIndexof the row to isolate
Returns
view object for the specified row

Definition at line 433 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ __CONSTEXPR__ size_type ecuda::matrix< T, Alloc, P >::max_size ( ) const
inline

Returns the maximum number of elements the container is able to hold due to system or library implementation limitations.

Returns
Maximum number of elements.

Definition at line 365 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ size_type ecuda::matrix< T, Alloc, P >::number_columns ( ) const
inline

Returns the number of columns in the container.

Returns
The number of columns in the container.

Definition at line 379 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ size_type ecuda::matrix< T, Alloc, P >::number_rows ( ) const
inline

Returns the number of rows in the container.

Returns
The number of rows in the container.

Definition at line 372 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
template<class Alloc2 >
__HOST__ __DEVICE__ bool ecuda::matrix< T, Alloc, P >::operator!= ( const matrix< value_type, Alloc2 > &  other) const
inline

Checks if the contents of two matrices are not equal.

That is, whether number_rows() != other.number_rows(), number_columns() != other.number_columns(), or whether any element in the this matrix does not compare equal to the element in the other matrix at the same position.

Parameters
othercontainer to compare contents with
Returns
true if the contents are not equal, false otherwise

Definition at line 656 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::matrix< T, Alloc, P >::operator() ( const size_type  rowIndex,
const size_type  columnIndex 
)
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

This is identical to at() but no bounds checking is performed.

Parameters
rowIndexrow of the element to return
columnIndexcolumn of the element to return
Returns
Reference to the requested element.

Definition at line 521 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::matrix< T, Alloc, P >::operator() ( const size_type  rowIndex,
const size_type  columnIndex 
) const
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

This is identical to at() but no bounds checking is performed.

Parameters
rowIndexrow of the element to return
columnIndexcolumn of the element to return
Returns
Reference to the requested element.

Definition at line 532 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
template<class Alloc2 >
__HOST__ __DEVICE__ bool ecuda::matrix< T, Alloc, P >::operator< ( const matrix< value_type, Alloc2 > &  other) const
inline

Compares the contents of two matrices lexicographically.

The order that elements are compared corresponds to their linearized layout (i.e. each column of the first row is compared, then each column of the next row, and so on...).

Parameters
othercontainer to compare contents with
Returns
true if the contents of this matrix are lexicographically less than the other matrix, false otherwise

Definition at line 668 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
template<class Alloc2 >
__HOST__ __DEVICE__ bool ecuda::matrix< T, Alloc, P >::operator<= ( const matrix< value_type, Alloc2 > &  other) const
inline

Compares the contents of two matrices lexicographically.

The order that elements are compared corresponds to their linearized layout (i.e. each column of the first row is compared, then each column of the next row, and so on...).

Parameters
othercontainer to compare contents with
Returns
true if the contents of this matrix are lexicographically less than or equal to the other matrix, false otherwise

Definition at line 698 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ matrix& ecuda::matrix< T, Alloc, P >::operator= ( const matrix< T, Alloc, P > &  other)
inline

Definition at line 245 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
template<class Alloc2 >
__HOST__ __DEVICE__ bool ecuda::matrix< T, Alloc, P >::operator== ( const matrix< value_type, Alloc2 > &  other) const
inline

Checks if the contents of two matrices are equal.

That is, whether number_rows() == other.number_rows(), number_columns() == other.number_columns() and each element in the this matrix compares equal to the other matrix at the same position.

Parameters
othercontainer to compare contents with
Returns
true if the contents are equal, false otherwise

Definition at line 640 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
template<class Alloc2 >
__HOST__ __DEVICE__ bool ecuda::matrix< T, Alloc, P >::operator> ( const matrix< value_type, Alloc2 > &  other) const
inline

Compares the contents of two matrices lexicographically.

The order that elements are compared corresponds to their linearized layout (i.e. each column of the first row is compared, then each column of the next row, and so on...).

Parameters
othercontainer to compare contents with
Returns
true if the contents of this matrix are lexicographically greater than the other matrix, false otherwise

Definition at line 683 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
template<class Alloc2 >
__HOST__ __DEVICE__ bool ecuda::matrix< T, Alloc, P >::operator>= ( const matrix< value_type, Alloc2 > &  other) const
inline

Compares the contents of two matrices lexicographically.

The order that elements are compared corresponds to their linearized layout (i.e. each column of the first row is compared, then each column of the next row, and so on...).

Parameters
othercontainer to compare contents with
Returns
true if the contents of this matrix are lexicographically greater than or equal to the other matrix, false otherwise

Definition at line 710 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ row_type ecuda::matrix< T, Alloc, P >::operator[] ( const size_type  rowIndex)
inline

operator[](rowIndex) alias for get_row(rowIndex)

Parameters
rowIndexindex of the row to isolate
Returns
view object for the specified row

Definition at line 539 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_row_type ecuda::matrix< T, Alloc, P >::operator[] ( const size_type  rowIndex) const
inline

operator[](rowIndex) alias for get_row(rowIndex)

Parameters
rowIndexindex of the row to isolate
Returns
view object for the specified row

Definition at line 546 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ reverse_iterator ecuda::matrix< T, Alloc, P >::rbegin ( )
inline

Returns a reverse iterator to the first element of the reversed container.

It corresponds to the last element of the non-reversed container.

Returns
Reverse iterator to the first element.

Definition at line 314 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_reverse_iterator ecuda::matrix< T, Alloc, P >::rbegin ( ) const
inline

Returns a reverse iterator to the first element of the reversed container.

It corresponds to the last element of the non-reversed container.

Returns
Reverse iterator to the first element.

Definition at line 333 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ reverse_iterator ecuda::matrix< T, Alloc, P >::rend ( )
inline

Returns a reverse iterator to the element following the last element of the reversed container.

It corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behaviour.

Returns
Reverse iterator to the element following the last element.

Definition at line 324 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_reverse_iterator ecuda::matrix< T, Alloc, P >::rend ( ) const
inline

Returns a reverse iterator to the element following the last element of the reversed container.

It corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behaviour.

Returns
Reverse iterator to the element following the last element.

Definition at line 343 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ void ecuda::matrix< T, Alloc, P >::resize ( const size_type  newNumberRows,
const size_type  newNumberColumns,
const value_type value = value_type() 
)
inline

Resizes the container to have dimensions newNumberRows x newNumberColumns.

If the current size is greater in either or both dimensions, the existing elements are truncated.

Parameters
newNumberRowsnew number of rows
newNumberColumnsnew number of columns
valuethe value to initialize the new elements with (default constructed if not specified)

Definition at line 390 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ size_type ecuda::matrix< T, Alloc, P >::size ( ) const
inline

Returns the number of elements in the container (numberRows*numberColumns).

Returns
The number of elements in the container.

Definition at line 357 of file matrix.hpp.

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ void ecuda::matrix< T, Alloc, P >::swap ( matrix< T, Alloc, P > &  other)
inline

Exchanges the contents of the container with those of the other.

Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated.

Although this can be called from both the host and device, a call from the device only swaps the contents of the containers in the calling thread only.

Parameters
othercontainer to exchange the contents with

Definition at line 622 of file matrix.hpp.

Friends And Related Function Documentation

template<typename T, class Alloc = device_pitch_allocator<T>, class P = shared_ptr<T>>
template<typename U , class Alloc2 , class Q >
friend class matrix
friend

Definition at line 158 of file matrix.hpp.


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