CUSP
Loading...
Searching...
No Matches
cusp::permutation_matrix_view< ArrayType, IndexType, MemorySpace > Class Template Reference

#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
 

Detailed description

template<typename ArrayType, typename IndexType = typename ArrayType::value_type, typename MemorySpace = typename ArrayType::memory_space>
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
}
The array1d class is a 1D vector container that may contain elements stored in "host" or "device" mem...
Definition array1d.h:99
Coordinate (COO) representation a sparse matrix.
Definition coo_matrix.h:117
View of a permutation_matrix.
permutation_array_type permutation
Coordinate matrix format.
void print(const Printable &p)
print a textual representation of an object
void multiply(const LinearOperator &A, const MatrixOrVector1 &B, MatrixOrVector2 &C)
Implements matrix-matrix and matrix-vector multiplication.
Matrix multiplication.
A permutation matrix.
Print textual representation of an object.

Definition at line 276 of file permutation_matrix.h.

Constructor & Destructor Documentation

◆ permutation_matrix_view() [1/7]

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

Construct an empty permutation_matrix_view.

Definition at line 298 of file permutation_matrix.h.

◆ permutation_matrix_view() [2/7]

template<typename ArrayType , typename IndexType = typename ArrayType::value_type, typename MemorySpace = typename ArrayType::memory_space>
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 307 of file permutation_matrix.h.

◆ permutation_matrix_view() [3/7]

template<typename ArrayType , typename IndexType = typename ArrayType::value_type, typename MemorySpace = typename ArrayType::memory_space>
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 317 of file permutation_matrix.h.

◆ permutation_matrix_view() [4/7]

template<typename ArrayType , typename IndexType = typename ArrayType::value_type, typename MemorySpace = typename ArrayType::memory_space>
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 325 of file permutation_matrix.h.

◆ permutation_matrix_view() [5/7]

template<typename ArrayType , typename IndexType = typename ArrayType::value_type, typename MemorySpace = typename ArrayType::memory_space>
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 333 of file permutation_matrix.h.

◆ permutation_matrix_view() [6/7]

template<typename ArrayType , typename IndexType = typename ArrayType::value_type, typename MemorySpace = typename ArrayType::memory_space>
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 341 of file permutation_matrix.h.

◆ permutation_matrix_view() [7/7]

template<typename ArrayType , typename IndexType = typename ArrayType::value_type, typename MemorySpace = typename ArrayType::memory_space>
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 349 of file permutation_matrix.h.

Member Function Documentation

◆ resize()

template<typename ArrayType , typename IndexType = typename ArrayType::value_type, typename MemorySpace = typename ArrayType::memory_space>
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.

◆ symmetric_permute()

template<typename ArrayType , typename IndexType = typename ArrayType::value_type, typename MemorySpace = typename ArrayType::memory_space>
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

◆ permutation

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

Storage for the permutation indices

Definition at line 294 of file permutation_matrix.h.