Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Public Methods | Public Members | List of all members
cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace > Class Template Reference

Detailed description

template<typename ArrayType, typename IndexType, typename MemorySpace>
class cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >

View of a permutation_matrix.

Template Parameters
ArrayType of permutation array view
IndexTypeType used for matrix indices (e.g. int).
MemorySpaceA memory space (e.g. cusp::host_memory or cusp::device_memory)
Overview

A permutation_matrix_view is a view of a permutation_matrix constructed from existing data or iterators.

Example
The following code snippet demonstrates how to create a 3-by-3 permutation_matrix on the host with 3 nonzeros and permutes a coo_matrix by first by row and then by column.
// include the permutation_matrix header file
#include <cusp/multiply.h>
#include <cusp/print.h>
int main()
{
// allocate storage for (3,3) matrix with 5 nonzeros
// initialize matrix entries on host
A.row_indices[0] = 0; A.column_indices[0] = 0; A.values[0] = 10;
A.row_indices[1] = 0; A.column_indices[1] = 2; A.values[1] = 20;
A.row_indices[2] = 0; A.column_indices[2] = 0; A.values[2] = 30;
A.row_indices[3] = 1; A.column_indices[3] = 1; A.values[3] = 40;
A.row_indices[4] = 2; A.column_indices[4] = 2; A.values[4] = 50;
// A now represents the following matrix
// [10 0 20]
// [30 40 0]
// [ 0 0 50]
// generate a index permutation that swaps row or column 0 and 2
ArrayType permutation(3);
permutation[0] = 2; // 0 maps to 2
permutation[1] = 1; // 1 maps to 1
permutation[2] = 0; // 2 maps to 0
// allocate storage for (3,3) matrix with 3 nonzeros
// P now represents the following permutation matrix
// [0 0 1]
// [0 1 0]
// [1 0 0]
// permute the rows of A
cusp::multiply(P, A, PA);
// permute the column of PA
cusp::multiply(PA, P, PAP);
// print the permuted matrix
}

Definition at line 34 of file permutation_matrix.h.

#include <permutation_matrix.h>

Inheritance diagram for cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >:

Public Methods

 permutation_matrix_view (void)
 
 permutation_matrix_view (const size_t num_rows, ArrayType &permutation)
 
 permutation_matrix_view (const size_t num_rows, const ArrayType &permutation)
 
 permutation_matrix_view (permutation_matrix< IndexType, MemorySpace > &matrix)
 
 permutation_matrix_view (const permutation_matrix< IndexType, MemorySpace > &matrix)
 
 permutation_matrix_view (permutation_matrix_view< ArrayType > &matrix)
 
 permutation_matrix_view (const permutation_matrix_view< ArrayType > &matrix)
 
void resize (const size_t num_rows)
 
template<typename MatrixType >
void symmetric_permute (MatrixType &matrix)
 

Public Members

permutation_array_type permutation
 

Constructor & Destructor Documentation

template<typename ArrayType, typename IndexType, typename MemorySpace>
cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::permutation_matrix_view ( void  )
inline

Construct an empty permutation_matrix_view.

Definition at line 297 of file permutation_matrix.h.

template<typename ArrayType, typename IndexType, typename MemorySpace>
cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::permutation_matrix_view ( const size_t  num_rows,
ArrayType &  permutation 
)
inline

Construct a permutation_matrix_view with a specific number of rows from an existing array denoting the permutation indices.

Parameters
num_rowsNumber of rows.
permutationArray containing the permutation indices.

Definition at line 306 of file permutation_matrix.h.

template<typename ArrayType, typename IndexType, typename MemorySpace>
cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::permutation_matrix_view ( const size_t  num_rows,
const ArrayType &  permutation 
)
inline

Construct a permutation_matrix_view with a specific number of rows from an existing const array denoting the permutation indices.

Parameters
num_rowsNumber of rows.
permutationArray containing the permutation indices.

Definition at line 316 of file permutation_matrix.h.

template<typename ArrayType, typename IndexType, typename MemorySpace>
cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::permutation_matrix_view ( permutation_matrix< IndexType, MemorySpace > &  matrix)
inline

Construct a permutation_matrix_view from a existing permutation_matrix.

Parameters
matrixpermutation_matrix used to create view.

Definition at line 324 of file permutation_matrix.h.

template<typename ArrayType, typename IndexType, typename MemorySpace>
cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::permutation_matrix_view ( const permutation_matrix< IndexType, MemorySpace > &  matrix)
inline

Construct a permutation_matrix_view from a existing const permutation_matrix.

Parameters
matrixpermutation_matrix used to create view.

Definition at line 332 of file permutation_matrix.h.

template<typename ArrayType, typename IndexType, typename MemorySpace>
cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::permutation_matrix_view ( permutation_matrix_view< ArrayType > &  matrix)
inline

Construct a permutation_matrix_view from a existing permutation_matrix_view.

Parameters
matrixpermutation_matrix_view used to create view.

Definition at line 340 of file permutation_matrix.h.

template<typename ArrayType, typename IndexType, typename MemorySpace>
cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::permutation_matrix_view ( const permutation_matrix_view< ArrayType > &  matrix)
inline

Construct a permutation_matrix_view from a existing const permutation_matrix_view.

Parameters
matrixpermutation_matrix_view used to create view.

Definition at line 348 of file permutation_matrix.h.

Member Function Documentation

template<typename ArrayType, typename IndexType, typename MemorySpace>
void cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::resize ( const size_t  num_rows)

Resize matrix dimensions and underlying storage

Parameters
num_rowsNumber of rows.
template<typename ArrayType, typename IndexType, typename MemorySpace>
template<typename MatrixType >
void cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::symmetric_permute ( MatrixType &  matrix)

Permute rows and columns of matrix elements

Parameters
matrixInput matrix to apply symmetric permutation.

Member Data Documentation

template<typename ArrayType, typename IndexType, typename MemorySpace>
permutation_array_type cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace >::permutation

Storage for the permutation indices

Definition at line 293 of file permutation_matrix.h.