AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | List of all members
AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value > Class Template Reference

COO Matrix partitioning view class. More...

#include <AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp>

Inheritance diagram for AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >:
Inheritance graph
[legend]

Classes

class  UninitializedException
 

Public Types

enum  EPartitionOrder
 
typedef
COOMatrixPartitionedViewUtilityPack::Partition
< T_Indice, T_Value > 
partition_type
 
typedef
COOMatrixPartitionedViewUtilityPack::TransposedPartition
< T_Indice, T_Value > 
transposed_partition_type
 
typedef T_Indice indice_type
 
typedef
AbstractLinAlgPack::size_type 
size_type
 
typedef ptrdiff_t difference_type
 

Constructors and initializes

The default copy constructor is allowed. The constructed object will share the storage space for the COO matrix view.

 COOMatrixPartitionedView ()
 Construct with no view set. More...
 
 COOMatrixPartitionedView (size_type rows, size_type cols, size_type nz, value_type val[], const indice_type ivect[], const indice_type jvect[], const size_type inv_row_perm[], const size_type inv_col_perm[], const size_type num_row_part, const size_type row_part[], const size_type num_col_part, const size_type col_part[], const EPartitionOrder partition_order)
 Construct with a view to a partitioned COO matrix set. More...
 
void create_view (size_type rows, size_type cols, size_type nz, value_type val[], const indice_type ivect[], const indice_type jvect[], const size_type inv_row_perm[], const size_type inv_col_perm[], const size_type num_row_part, const size_type row_part[], const size_type num_col_part, const size_type col_part[], const EPartitionOrder partition_order)
 Crete a view to a COO matrix. More...
 
void bind (const COOMatrixPartitionedView &coom_view)
 Bind the view of another partitioned matrix. More...
 
void free ()
 Free the allocated memory and make uninitialized. More...
 
bool is_initialized () const
 Returns true if a view has been initialized. More...
 

Partitioning information

All of these member functions have the followin preconditions:

Preconditions:{itemize} is_initialized() == true# (throw #UninitializedException#) {itemize}

size_type rows () const
 return the number of rows of the total view More...
 
size_type cols () const
 return the number of columns in the total view More...
 
size_type nz () const
 return the number of nonzero elements in the total view More...
 
size_type num_row_part () const
 return the number row partitions More...
 
size_type num_col_part () const
 return the number column partitions More...
 
void get_row_part (indice_type row_part[]) const
 get the array of row partitions. More...
 
void get_col_part (indice_type col_part[]) const
 get the array of column partitions. More...
 
EPartitionOrder partition_order () const
 Returns whether the paritions or sorted by row or by column. More...
 
size_type overall_part_num (size_type row_p, size_type col_p) const
 Returns the overall partition number (1 to num_row_part() * num_col_part()#) given the row (1 to num_row_part()#) and column (1 to num_col_part()#) partition numbers. More...
 
size_type row_part_num (size_type overall_p) const
 Returns the row parition number (1-based) given the overall partition number (1-based) More...
 
size_type col_part_num (size_type overall_p) const
 Returns the column parition number (1-based) given the overall partition number (1-based) More...
 

Partition access

All of these member functions have the followin preconditions:

Preconditions:{itemize} is_initialized() == true# (throw #UninitializedException#) {itemize}

partition_type operator() ()
 Return a partition object for the entire view. More...
 
const partition_type operator() () const
 
partition_type partition (size_type overall_p)
 Return a partition object for a parition given its overall partition number (1-based). More...
 
const partition_type partition (size_type overall_p) const
 
partition_type partition (size_type row_p, size_type col_p)
 Return a partition object for a parition given its row and column partition numbers. More...
 
const partition_type partition (size_type row_p, size_type col_p) const
 
partition_type partition (Range1D rng_overall_p)
 Return a partition object for a range of continous overall partition numbers. More...
 
const partition_type partition (Range1D rng_overall_p) const
 

Detailed Description

template<class T_Indice, class T_Value>
class AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >

COO Matrix partitioning view class.

This class is used to provide a set of views (partitions) of a permuted sparse coordinate (COO) matrix sorted in Fortran like compatable arrays (val, ivect, jvect).

The function create_view(...)# or a constructor is called to setup a view. In these initizliation functions the Fortran compatable COO matrix is specified as:\ (rows#,cols#,nz#,#val#(nz#),#ivect#(nz#),#jvect#(nz#))\ The row and column permutations are given as a set of inverse permutation vectors:\ (#inv_row_perm#(rows#),#inv_col_perm#(cols#))\ And the row and column partitioning is given as: (num_row_part#,#row_part#(num_row_part#),num_col_part#,#col_part#(num_col_part#))

After these function execute successfully the object provides views to the given partitions (singular or consecutive) of the given permuted COO matrix. The partitions are ordered by column or by row depending on the value of partition_order#.

For example, concider the following permuted and partitioned sparse COO matrix: {verbatim}

   Non-permuted COO matrix    

1 2 3 4 5


1 | 1.2 1.4 |

2 | 2.1 2.2 2.4 2.5 |

3 | 3.3 |

4 | 4.5 |

5 | 5.1 5.2 5.3 5.4 |

6 | 6.3 6.5 |

7 | 7.1 7.4 |

8 | 8.2 8.3 |

==>

 Permuted and partitioned COO matrix

    1       3       5       2       4

| 1 2 3 4 5 | — — — — — | 2 | 1 | 2.1 2.5 + 2.2 2.4 | | + 3 | 2 | 3.3 + | | + 6 | 3 | 6.3 6.5 + | | +++++++++++++++++++++++++++++++++++++ 1 | 4 | + 1.2 1.4 | | + 4 | 5 | 4.5 + | | + 5 | 6 | 5.1 5.3 + 5.2 5.4 | | + 7 | 7 | 7.1 + 7.4 | | + 8 | 8 | 8.3 + 8.2 |

{verbatim} The following quantities are used to specify the example shown above: {verbatim}

rows = 8, cols = 5, nz = 18 val = { 2.1,5.1,7.1,1.2,2.2,5.2,8.2,3.3,5.3,6.3,8.3,1.4,2.4,5.4,7.4,2.5,4.5,6.5 } ivect = { 2, 5, 7, 1, 2, 5, 8, 3, 5, 6, 8, 1, 2, 5, 7, 2, 4, 6 } jvect = { 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5 }

inv_row_perm = { 4, 1, 2, 5, 6, 3, 7, 8 } inv_col_perm = { 1, 4, 2, 5, 3 }

num_row_part = 2 row_part = { 1, 4, 9 } num_col_part = 2 col_part = { 1, 4, 6 }

{verbatim} The partitions are ordered by row or column counting from the upper left hand partition. For this example the partitions are numbered as: {verbatim} partition_order = PARTITION_BY_ROW partition_order = PARTITION_BY_COL


1 2 1 3
3 4 2 4

{verbatim} The overall partition number is given by a call to #overall_part_num(row_p,col_p)# where #row_p# and #col_p# are the row and column parition numbers respectively. In the example, the lower left partition has #row_p# = 2 and #col_p# = 1 and #overall_part_num(row_p,col_p)# would return 3 for partition_order = PARTITION_BY_ROW# and 2 for partition_order = PARTITION_BY_COL#.

Also, given the overall partition number you can obtain the row and column partition numbers by calling #row_part_num(overall_p)# and #col_part_num(overall_p)# respectively.

The row and column indices for the partitions can be extracted with calls to #get_row_part(row_part)# and #get_col_part(col_part)# respectively.

Actual paritions or consecutive partitions are accessed by way of objects of the types partition_type# and transposed_partition_type#. These types conform to the COOMatrixTemplateInterface specification so they can be used with the associated templated linear algebra operations. A partition_type# object is created by a call to #partition(overall_p)# or #partition(row_p,col_p)# for single partitions and #partition(Range1D(overall_p1,overall_p2))# for consecutive partitions. For example you could create a partition object for the first partition by calling #partition(1)# or #partition(1,1)# or #partition(Range1D(1,1))#. You can create a transposed parition object by calling the nonmember function transposed_partition_type trans(parition_type&)#. In the above example, using parition ordering by column you could create a transposed view of the two left hand side partitions by calling trans(this->partition(Range1D(1,2)))#.

All of this gives the client a lot of flexibility in how a COO matrix is accessed.

The default copy constructor is allowed. The default assignment operator is not allowed.

Definition at line 184 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

Member Typedef Documentation

template<class T_Indice, class T_Value>
typedef COOMatrixPartitionedViewUtilityPack::Partition<T_Indice,T_Value> AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::partition_type
template<class T_Indice, class T_Value>
typedef COOMatrixPartitionedViewUtilityPack::TransposedPartition<T_Indice,T_Value> AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::transposed_partition_type
template<class T_Indice, class T_Value>
typedef T_Indice AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::indice_type
template<class T_Indice, class T_Value>
typedef AbstractLinAlgPack::size_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::size_type
template<class T_Indice, class T_Value>
typedef ptrdiff_t AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::difference_type

Member Enumeration Documentation

template<class T_Indice, class T_Value>
enum AbstractLinAlgPack::COOMatrixPartitionedView::EPartitionOrder

Constructor & Destructor Documentation

template<class T_Indice , class T_Value >
AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::COOMatrixPartitionedView ( )
inline

Construct with no view set.

Postconditions:{itemize} rows() == 0# cols() == 0# nz() == 0# {itemize}

Definition at line 1120 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice, class T_Value>
AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::COOMatrixPartitionedView ( size_type  rows,
size_type  cols,
size_type  nz,
value_type  val[],
const indice_type  ivect[],
const indice_type  jvect[],
const size_type  inv_row_perm[],
const size_type  inv_col_perm[],
const size_type  num_row_part,
const size_type  row_part[],
const size_type  num_col_part,
const size_type  col_part[],
const EPartitionOrder  partition_order 
)
inline

Construct with a view to a partitioned COO matrix set.

Equivalent to calling the default constructor then create_view(...)#.

Definition at line 237 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

Member Function Documentation

template<class T_Indice , class T_Value >
void AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::create_view ( size_type  rows,
size_type  cols,
size_type  nz,
value_type  val[],
const indice_type  ivect[],
const indice_type  jvect[],
const size_type  inv_row_perm[],
const size_type  inv_col_perm[],
const size_type  num_row_part,
const size_type  row_part[],
const size_type  num_col_part,
const size_type  col_part[],
const EPartitionOrder  partition_order 
)

Crete a view to a COO matrix.

The arguments to this function specify COO matrix (rows#,cols#,nz#,#val#(nz#),#ivect#(nz#),#jvect#(nz#)) a set of row and column permutations (#inv_row_perm#(rows#),#inv_col_perm#(cols#)) and a set of row and column partitions: (num_row_part#,#row_part#(num_row_part#),num_col_part#,#col_part#(num_col_part#))

After this function executes successfully #this# object provides views to the given partitions (singular or consecutive) of the given permuted COO matrix. The partitions are ordered by column or by row depending on the value of partition_order#.

Warning! Duplicate elements (#ivect[k1] == ivect[k2] && jvect[k1] == jvect[k2]#) are not looked for in the input COO matrix. It is up to the client to make sure that there are no duplicates since this is an expensive test since the matrix elements are not assumed to be sorted.

It is important to note that #this# object keeps a pointer to the array of nonzero elements in #val# passed into this function. Therefore, the numerical values of these elements can be altered and #this# object will still provide the view into this coordinate matrix. If the memory pointed to by #val# change then this operation must be called again setupd the view again.

Preconditions:{itemize} nz <= rows * cols#, (throw #std::invalid_argument#) rows >= ivect[#k#] >= 1#, k = 0,...,nz-1# (throw #std::out_of_range#) cols >= jvect[#k#] >= 1#, k = 0,...,nz-1# (throw #std::out_of_range#) num_row_part <= rows#, (throw #std::invalid_argument#) num_col_part <= cols#, (throw #std::invalid_argument#) rows >= inv_row_perm[#i#] >= 1#, i = 0,...,rows-1# (throw #std::out_of_range#) cols >= inv_col_perm[#j#] >= 1#, j = 0,...,cols-1# (throw #std::out_of_range#) #inv_row_perm[#i1#] != inv_row_perm[#i2]#, for i1 anb i2 in set {0,...,rows-1#} #inv_col_perm[#j1#] != inv_col_perm[#j2]#, for j1 anb j2 in set {0,...,cols-1#} #row_part[#k+1#] > row_part[#k#]#, k = 0,...,num_row_part-2# (throw #std::domain_error#) #col_part[#k+1#] > col_part[#k#]#, k = 0,...,num_col_part-2# (throw #std::domain_error#) #row_part[num_row_part-1] <= rows + 1# (throw #std::out_of_range#) #col_part[num_col_part-1] <= cols + 1# (throw #std::out_of_range#) partition_order == PARTITION_BY_ROW || partition_order == PARTITION_BY_COL# (throw #std::invalid_argument#) {itemize}

Postconditions:{itemize} ? {itemize}

Parameters
rowsnumber of rows in the COO matrix.
colsnumber of columns in the COO matrix.
nznumber of nonzero elements in the COO matrix.
valarray (length nz#) of the values of the nonzero elements in the COO matrix.
ivectarray (length nz#) of the row indices (1-based) in the original COO matrix.
jvectarray (length nz#) of the column indices (1-based) in the original COO matrix.
inv_row_permarray (length rows#) for the inverse row permutations. row_i_new == #inv_row_perm[#row_i_old#]#.
inv_col_permarray (length cols#) for the inverse column permutations. col_j_new == #inv_col_perm[#col_j_old#]#..
num_row_partnumber of row partitions for the partitioned view to create.
row_partarray (length num_row_part#) that specifies the row partitions. The first num_row_part# elements of #row_part# give the row indices for the starts of the partitions. The last element gives the row indice one past the last row in the last partition.
num_col_partnumber of column partitions for the partitioned view to create.
col_partarray (length num_col_part#) that specifies the column partitions. The first num_col_part# elements of #col_part# give the column indices for the starts of the partitions. The last element gives the column indice one past the last column in the last partition.
parition_orderPARTITION_BY_ROW: the overall partitions are numbered from left to right by row starting at the upper left partition. PARTITION_BY_COL the overall partitions are numbered from top to bottom by column starting at the upper left partition.

Definition at line 57 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDef.hpp.

template<class T_Indice , class T_Value >
void AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::bind ( const COOMatrixPartitionedView< T_Indice, T_Value > &  coom_view)

Bind the view of another partitioned matrix.

After being called #this# and #coom_view# will share storage for the same COO matrix view.

Definition at line 238 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDef.hpp.

template<class T_Indice , class T_Value >
void AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::free ( )

Free the allocated memory and make uninitialized.

Definition at line 250 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDef.hpp.

template<class T_Indice , class T_Value >
bool AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::is_initialized ( ) const
inline

Returns true if a view has been initialized.

Definition at line 1125 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::size_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::rows ( ) const
inline

return the number of rows of the total view

Definition at line 1133 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::size_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::cols ( ) const
inline

return the number of columns in the total view

Definition at line 1142 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::size_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::nz ( ) const
inline

return the number of nonzero elements in the total view

Definition at line 1151 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::size_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::num_row_part ( ) const
inline

return the number row partitions

Definition at line 1159 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::size_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::num_col_part ( ) const
inline

return the number column partitions

Definition at line 1166 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
void AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::get_row_part ( indice_type  row_part[]) const

get the array of row partitions.

Parameters
row_part[O] array (length #this->num_row_part() + 1#) of row indices of start of the row partitions.

Definition at line 261 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDef.hpp.

template<class T_Indice , class T_Value >
void AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::get_col_part ( indice_type  col_part[]) const

get the array of column partitions.

Parameters
col_part[O] array (length #this->num_col_part() + 1#) of column indices of start of the column partitions.

Definition at line 269 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDef.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::EPartitionOrder AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::partition_order ( ) const
inline

Returns whether the paritions or sorted by row or by column.

Definition at line 1173 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::size_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::overall_part_num ( size_type  row_p,
size_type  col_p 
) const
inline

Returns the overall partition number (1 to num_row_part() * num_col_part()#) given the row (1 to num_row_part()#) and column (1 to num_col_part()#) partition numbers.

Definition at line 1181 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::size_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::row_part_num ( size_type  overall_p) const
inline

Returns the row parition number (1-based) given the overall partition number (1-based)

Definition at line 1189 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::size_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::col_part_num ( size_type  overall_p) const
inline

Returns the column parition number (1-based) given the overall partition number (1-based)

Definition at line 1197 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::partition_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::operator() ( )
inline

Return a partition object for the entire view.

Allow an implicit conversion from a COOMatrixPartitionedView to a partition_type object.

This conversion is equivalent to calling #partition(Range1D())#.

Definition at line 1221 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
const COOMatrixPartitionedView< T_Indice, T_Value >::partition_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::operator() ( ) const
inline
template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::partition_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::partition ( size_type  overall_p)
inline

Return a partition object for a parition given its overall partition number (1-based).

Definition at line 1235 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
const COOMatrixPartitionedView< T_Indice, T_Value >::partition_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::partition ( size_type  overall_p) const
inline
template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::partition_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::partition ( size_type  row_p,
size_type  col_p 
)
inline

Return a partition object for a parition given its row and column partition numbers.

Definition at line 1249 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
const COOMatrixPartitionedView< T_Indice, T_Value >::partition_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::partition ( size_type  row_p,
size_type  col_p 
) const
inline
template<class T_Indice , class T_Value >
COOMatrixPartitionedView< T_Indice, T_Value >::partition_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::partition ( Range1D  rng_overall_p)
inline

Return a partition object for a range of continous overall partition numbers.

This is probably only usefull when a set of rows of submatrices or column submatrices need to be accessed. For example, if the paritions are ordered by column and if you want to access the first n columns of partition submatrices you would call.

#this->partition(Range1D(1,this->overall_part_num(this->num_row_part(),n)))#

Parameters
rng_overall_p[I] the range of overall partitions. If #rng_overall_p.full_range() == true# then all of the partitions will be returned.

Definition at line 1263 of file AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp.

template<class T_Indice , class T_Value >
const COOMatrixPartitionedView< T_Indice, T_Value >::partition_type AbstractLinAlgPack::COOMatrixPartitionedView< T_Indice, T_Value >::partition ( Range1D  rng_overall_p) const
inline

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