42 #ifndef COO_MATRIX_PARTITIONED_VIEW_CLASS_DECL_H
43 #define COO_MATRIX_PARTITIONED_VIEW_CLASS_DECL_H
47 #include "MiRefCount.h"
49 namespace AbstractLinAlgPack {
51 namespace COOMatrixPartitionedViewUtilityPack {
52 template <
class T_Indice,
class T_Value>
class Partition;
183 template <
class T_Indice,
class T_Value>
254 create_view(rows, cols, nz, val, ivect, jvect, inv_row_perm, inv_col_perm, num_row_part
255 , row_part, num_col_part, col_part, partition_order);
493 typedef MemMngPack::RefCount<
495 typedef MemMngPack::RefCount<
497 typedef MemMngPack::RefCount<
611 namespace COOMatrixPartitionedViewUtilityPack {
632 template <
class T_Indice,
class T_Value>
791 template <
class T_Indice,
class T_Value>
809 , std::random_access_iterator_tag
810 ,
typename element_type::indice_type
816 , std::random_access_iterator_tag
817 ,
typename element_type::indice_type
893 template<
class T_Indice,
class T_Value>
898 transposed_partition_type;
899 return transposed_partition_type(part);
905 namespace COOMatrixPartitionedViewUtilityPack {
912 template <
class T_Indice,
class T_Value>
914 : rows_(0), cols_(0), nz_(0), ele_(0), row_offset_(0), col_offset_(0)
917 template <
class T_Indice,
class T_Value>
925 : rows_(rows), cols_(cols), nz_(nz), ele_(ele), row_offset_(row_offset)
926 , col_offset_(col_offset)
929 template <
class T_Indice,
class T_Value>
942 row_offset_ = row_offset;
943 col_offset_ = col_offset;
946 template <
class T_Indice,
class T_Value>
954 template <
class T_Indice,
class T_Value>
961 template <
class T_Indice,
class T_Value>
968 template <
class T_Indice,
class T_Value>
975 template <
class T_Indice,
class T_Value>
982 template <
class T_Indice,
class T_Value>
989 template <
class T_Indice,
class T_Value>
993 assert_initialized();
997 template <
class T_Indice,
class T_Value>
1001 assert_initialized();
1005 template <
class T_Indice,
class T_Value>
1009 assert_initialized();
1013 template <
class T_Indice,
class T_Value>
1017 assert_initialized();
1023 template <
class T_Indice,
class T_Value>
1026 throw std::logic_error(
"Partition<...> :"
1027 "The COO matrix was not initizlized");
1036 template <
class T_Indice,
class T_Value>
1038 : partition_(partition)
1041 template <
class T_Indice,
class T_Value>
1043 partition_.bind(partition);
1048 template <
class T_Indice,
class T_Value>
1052 return partition_.cols();
1055 template <
class T_Indice,
class T_Value>
1059 return partition_.rows();
1062 template <
class T_Indice,
class T_Value>
1066 return partition_.nz();
1069 template <
class T_Indice,
class T_Value>
1073 return partition_.col_offset();
1076 template <
class T_Indice,
class T_Value>
1080 return partition_.row_offset();
1083 template <
class T_Indice,
class T_Value>
1087 return iterator(partition_.begin());
1090 template <
class T_Indice,
class T_Value>
1097 template <
class T_Indice,
class T_Value>
1104 template <
class T_Indice,
class T_Value>
1119 template <
class T_Indice,
class T_Value>
1121 : num_row_part_(0), num_col_part_(0)
1124 template <
class T_Indice,
class T_Value>
1126 return ref_ele_.has_ref_set();
1131 template <
class T_Indice,
class T_Value>
1135 assert_initialized();
1136 const std::vector<size_type> &row_part = ref_row_part_.const_obj();
1137 return row_part[num_row_part_] - row_part[0];
1140 template <
class T_Indice,
class T_Value>
1144 assert_initialized();
1145 const std::vector<size_type> &col_part = ref_col_part_.const_obj();
1146 return col_part[num_col_part_] - col_part[0];
1149 template <
class T_Indice,
class T_Value>
1153 assert_initialized();
1154 return ref_part_start_.const_obj()[num_row_part_ * num_col_part_];
1157 template <
class T_Indice,
class T_Value>
1161 return num_row_part_;
1164 template <
class T_Indice,
class T_Value>
1168 return num_col_part_;
1171 template <
class T_Indice,
class T_Value>
1175 assert_initialized();
1176 return partition_order_;
1179 template <
class T_Indice,
class T_Value>
1183 assert_initialized();
1184 return imp_overall_part_num(row_p, col_p);
1187 template <
class T_Indice,
class T_Value>
1191 assert_initialized();
1192 return imp_row_part_num(overall_p);
1195 template <
class T_Indice,
class T_Value>
1199 assert_initialized();
1200 return imp_col_part_num(overall_p);
1219 template <
class T_Indice,
class T_Value>
1226 template <
class T_Indice,
class T_Value>
1233 template <
class T_Indice,
class T_Value>
1237 return partition(
Range1D(overall_p,overall_p));
1240 template <
class T_Indice,
class T_Value>
1244 return partition(
Range1D(overall_p,overall_p));
1247 template <
class T_Indice,
class T_Value>
1251 return partition(overall_part_num(row_p,col_p));
1254 template <
class T_Indice,
class T_Value>
1258 return partition(overall_part_num(row_p,col_p));
1261 template <
class T_Indice,
class T_Value>
1265 return create_partition(rng_overall_p);
1268 template <
class T_Indice,
class T_Value>
1272 return create_partition(rng_overall_p);
1277 template <
class T_Indice,
class T_Value>
1279 if(!is_initialized())
1281 " The partitioned view has not been initialized.");
1284 template <
class T_Indice,
class T_Value>
1288 return (partition_order_ == PARTITION_BY_ROW) ?
1289 (row_p - 1) * num_col_part_ + col_p :
1290 (col_p - 1) * num_row_part_ + row_p;
1293 template <
class T_Indice,
class T_Value>
1297 return (partition_order_ == PARTITION_BY_ROW) ?
1298 (overall_p - 1) / num_col_part_ + 1 :
1299 (overall_p - 1) % num_row_part_ + 1 ;
1302 template <
class T_Indice,
class T_Value>
1306 return (partition_order_ == PARTITION_BY_COL) ?
1307 (overall_p - 1) / num_row_part_ + 1 :
1308 (overall_p - 1) % num_col_part_ + 1 ;
1311 template <
class T_Indice,
class T_Value>
1316 return imp_overall_part_num( part_num(row_part,i)
1317 , part_num(col_part,j) );
1322 #endif // COO_MATRIX_PARTITIONED_VIEW_CLASS_DECL_H
ptrdiff_t difference_type
TransposedPartition(const partition_type &partition)
Construct with the partition initialized.
difference_type col_offset() const
TransSparseCOOElementViewIter< const element_type *, std::random_access_iterator_tag, typename element_type::indice_type, const typename element_type::value_type &, difference_type > const_iterator
difference_type col_offset_
COOMatrixPartitionedViewUtilityPack::TransposedPartition< T_Indice, T_Value > trans(COOMatrixPartitionedViewUtilityPack::Partition< T_Indice, T_Value > &part)
Create a transposed view of a partition object.
size_type cols() const
return the number of columns in the total view
void assert_initialized() const
void bind(const partition_type &partition)
bind to a partion.
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_...
bool is_initialized() const
Returns true if a view has been initialized.
ref_vector_size_type ref_part_start_
void assert_initialized() const
COOMatrixPartitionedView & operator=(const COOMatrixPartitionedView &)
size_type overall_p_from_ij(const vector_size_type &row_part, const vector_size_type &col_part, size_type i, size_type j)
RTOp_value_type value_type
std::vector< size_type > vector_size_type
size_type row_part_num(size_type overall_p) const
Returns the row parition number (1-based) given the overall partition number (1-based) ...
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return rows of a possible transposed matrix.
void initialize(size_type rows, size_type cols, size_type nz, element_type *ele, difference_type row_offset, difference_type col_offset)
Initialize the COO matrix.
size_type imp_row_part_num(size_type overall_p) const
partition_type partition(size_type overall_p)
Return a partition object for a parition given its overall partition number (1-based).
size_type rows() const
return the number of rows of the total view
COO Matrix partitioning view class.
SparseCOOPtrElement< T_Indice, T_Value > element_type
difference_type row_offset() const
UninitializedException(const std::string &what_arg)
void bind(const COOMatrixPartitionedView &coom_view)
Bind the view of another partitioned matrix.
EPartitionOrder partition_order() const
Returns whether the paritions or sorted by row or by column.
void get_row_part(indice_type row_part[]) const
get the array of row partitions.
COOMatrixPartitionedViewUtilityPack::TransposedPartition< T_Indice, T_Value > transposed_partition_type
std::vector< element_type > ele_type
const element_type * const_iterator
TransSparseCOOElementViewIter< element_type *, std::random_access_iterator_tag, typename element_type::indice_type, typename element_type::value_type &, difference_type > iterator
std::vector< indice_type > vector_indice_type
partition_type operator()()
Return a partition object for the entire view.
Partition< T_Indice, T_Value > partition_type
const f_int f_dbl_prec const f_int const f_int const f_int jvect[]
. One-based subregion index range class.
RTOp_index_type size_type
EPartitionOrder partition_order_
Partition< T_Indice, T_Value > partition_type
Templateded iterator for iterating through a set of COO Matix elements but viewing them in transpose...
void bind(const partition_type &partition)
bind to a partion.
Partition & operator=(const Partition &)
Class for the transpose of a Partition.
AbstractLinAlgPack::size_type size_type
ref_vector_size_type ref_row_part_
Sparse pointer element type for a COO matrix (val, ivect, jvect).
MemMngPack::RefCount< ele_type > ref_ele_type
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.
COOMatrixPartitionedView()
Construct with no view set.
const f_int f_dbl_prec const f_int const f_int ivect[]
difference_type row_offset() const
ref_vector_size_type ref_col_part_
size_type imp_col_part_num(size_type overall_p) const
ptrdiff_t difference_type
AbstractLinAlgPack::size_type size_type
size_type col_part_num(size_type overall_p) const
Returns the column parition number (1-based) given the overall partition number (1-based) ...
partition_type partition_
partition_type create_partition(Range1D rng_overall_p) const
MemMngPack::RefCount< vector_size_type > ref_vector_size_type
size_type num_col_part() const
return the number column partitions
size_type part_num(const vector_size_type &part, size_type indice)
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.
size_type nz() const
return the number of nonzero elements in the total view
void free()
Free the allocated memory and make uninitialized.
TransposedPartition & operator=(const TransposedPartition &)
void get_col_part(indice_type col_part[]) const
get the array of column partitions.
Class for a partition or a set of continous partitions in a partitioned COO matrix.
AbstractLinAlgPack::size_type size_type
SparseCOOPtrElement< T_Indice, T_Value > element_type
difference_type row_offset_
COOMatrixPartitionedViewUtilityPack::Partition< T_Indice, T_Value > partition_type
SparseCOOPtrElement< T_Indice, T_Value > element_type
ptrdiff_t difference_type
Partition()
Constructs an uninitialized partition view.
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.
RangePack::Range1D Range1D
MemMngPack::RefCount< vector_indice_type > ref_vector_indice_type
size_type num_row_part() const
return the number row partitions
size_type imp_overall_part_num(size_type row_p, size_type col_p) const
difference_type col_offset() const