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
AbstractLinAlgPack_COOMatrixPartitionedViewClassDecl.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef COO_MATRIX_PARTITIONED_VIEW_CLASS_DECL_H
43 #define COO_MATRIX_PARTITIONED_VIEW_CLASS_DECL_H
44 
45 #include "AbstractLinAlgPack_SparseCOOPtrElement.hpp"
46 #include "AbstractLinAlgPack_TransSparseCOOElementViewIter.hpp"
47 #include "MiRefCount.h"
48 
49 namespace AbstractLinAlgPack {
50 
51 namespace COOMatrixPartitionedViewUtilityPack {
52 template <class T_Indice, class T_Value> class Partition;
53 template <class T_Indice, class T_Value> class TransposedPartition;
54 }
55 
56 // ///////////////////////////////////////////////////////////////////////////////////////
57 // ///////////////////////////////////////////////////////////////////////////////////////
183 template <class T_Indice, class T_Value>
185 public:
186 
187  // //////////////////////////////////////////////////////////////////////////
190 
198  typedef T_Indice indice_type;
200  typedef AbstractLinAlgPack::size_type size_type;
202  typedef ptrdiff_t difference_type;
204  enum EPartitionOrder { PARTITION_BY_ROW, PARTITION_BY_COL };
206  class UninitializedException: public std::logic_error
207  {public: UninitializedException(const std::string& what_arg) : std::logic_error(what_arg) {}};
208 
210 
211  // ///////////////////////////////////////////////////////////////////////////////////////
214 
221 
232 
239  , size_type cols
240  , size_type nz
241  , value_type val[]
242  , const indice_type ivect[]
243  , const indice_type jvect[]
244  , const size_type inv_row_perm[]
245  , const size_type inv_col_perm[]
246  , const size_type num_row_part
247  , const size_type row_part[]
248  , const size_type num_col_part
249  , const size_type col_part[]
251 
252  : num_row_part_(0), num_col_part_(0)
253  {
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);
256  }
257  // I tried defining this function else where as both an inlined and
258  // noninlined function but MS VC++ 5.0 generated
259  // a linking error saying that it could not find this function.
260  // ToDo: Investagate this problem further at a latter time.
261 
335  void create_view(
336  size_type rows
337  , size_type cols
338  , size_type nz
339  , value_type val[]
340  , const indice_type ivect[]
341  , const indice_type jvect[]
342  , const size_type inv_row_perm[]
343  , const size_type inv_col_perm[]
344  , const size_type num_row_part
345  , const size_type row_part[]
346  , const size_type num_col_part
347  , const size_type col_part[]
349 
355  void bind(const COOMatrixPartitionedView& coom_view);
356 
358  void free();
359 
361  bool is_initialized() const;
362 
364 
374 
376  size_type rows() const;
377 
379  size_type cols() const;
380 
382  size_type nz() const;
383 
385  size_type num_row_part() const;
386 
388  size_type num_col_part() const;
389 
395  void get_row_part(indice_type row_part[]) const;
396 
402  void get_col_part(indice_type col_part[]) const;
403 
406 
410  size_type overall_part_num(size_type row_p, size_type col_p) const;
411 
413  size_type row_part_num(size_type overall_p) const;
414 
416  size_type col_part_num(size_type overall_p) const;
417 
419 
429 
430 // ///
431 // /** Allow an implicit conversion from a COOMatrixPartitionedView
432 // * to a partition_type object.
433 // *
434 // * This conversion is equivalent to calling #partition(Range1D())#.
435 // */
436 // operator partition_type();
437 //
438 // ///
439 // operator const partition_type() const;
440 
444 
446  const partition_type operator()() const;
447 
450  partition_type partition(size_type overall_p);
451 
453  const partition_type partition(size_type overall_p) const;
454 
458  partition_type partition(size_type row_p, size_type col_p);
459 
461  const partition_type partition(size_type row_p, size_type col_p) const;
462 
476  partition_type partition(Range1D rng_overall_p);
477 
479  const partition_type partition(Range1D rng_overall_p) const;
480 
482 
484 
485 private:
486  // ////////////////////////////////////////////////////////////////
487  // Private types
488 
489  typedef SparseCOOPtrElement<T_Indice,T_Value> element_type;
490  typedef std::vector<indice_type> vector_indice_type;
491  typedef std::vector<size_type> vector_size_type;
492  typedef std::vector<element_type> ele_type;
493  typedef MemMngPack::RefCount<
494  vector_indice_type> ref_vector_indice_type;
495  typedef MemMngPack::RefCount<
496  vector_size_type> ref_vector_size_type;
497  typedef MemMngPack::RefCount<
498  ele_type> ref_ele_type;
499 
500  // ///////////////////////////////////////////////////////////////
501  // Private data members
502 
503  size_type num_row_part_;
504  // The number of partions the COO matrix is sliced up into by rows.
505 
506  size_type num_col_part_;
507  // The number of partions the COO matrix is sliced up into by columns.
508 
509  ref_vector_size_type ref_row_part_;
510  //
511  // row_part = { row_p_1_i, row_p_2_i,...,row_p_nrp_i, row_p_nrp_last_i + 1 }
512  // where: row_p_k_i is the row indice for row partition k
513  // nrp = num_row_part
514  // row_p_nrp_last_i is the last row indice in the last row partition
515  //
516  // vector (length num_row_part_ + 1) of row indices for the start of the row partitions.
517  // row_part[i - 1] is the row indice for the start of the ith row partition (i = 1,...,num_row_part_).
518  // The last indice gives the row indice that is one past the last row of the last
519  // row partition. It is included for the efficient calculation of the number of rows
520  // in a partition or a set of partitions.
521 
522  ref_vector_size_type ref_col_part_;
523  //
524  // col_part = { col_p_1_i, col_p_2_i,...,col_p_nrp_i, col_p_nrp_last_i + 1 }
525  // where: col_p_k_i is the col indice for col partition k
526  // nrp = num_col_part
527  // col_p_nrp_last_i is the last col indice in the last col partition
528  //
529  // vector (length num_row_part_ + 1) of column indices for the start of the columns partitions.
530  // col_part[j - 1] is the column indice for the start of the jth column partition (j = 1,...,num_col_part_).
531  // The last indice gives the column indice that is one past the last column of the last
532  // column partition. It is included for the efficient calculation of the number of columns
533  // in a partition or a set of partitions.
534 
535  EPartitionOrder partition_order_;
536  // Specifies wheather the partitions are to be orded by columns or rows
537 
538  ref_ele_type ref_ele_;
539  // ToDo: replace with a RefCount<std::vector<element_type>> when you get compiler bug fix.
540  // The storage array (dynamically allocated) for the elements in the COO matrix.
541  // The elements in this array are ordered into partitions defined by the partition_order_.
542  //
543  // ele_
544  // ---------------------
545  // |pval row_i col_i|
546  // || | | | | ||-
547  // || | | | | || parition 1
548  // || | | | | ||
549  // || | | | | ||-
550  // || | | | | || parition 2
551  // || | | | | ||
552  // || | | | | ||-
553  // || | | | | || .
554  // || | | | | || .
555  // || | | | | || .
556  // || | | | | ||
557  // || | | | | ||-
558  // || | | | | || partition num_row_part * num_col_part
559  // || | | | | ||
560  // || | | | | ||-
561  // ---------------------
562 
563  ref_vector_size_type ref_part_start_;
564  //
565  // part_start = { start_1 = 0, start_2,..., start_n, total_nz }
566  //
567  // vector (length num_row_part * num_col_part_ + 1) of the start for the elements in
568  // each partition. ele_[part_start_[overall_p - 1]] gives the first element of partion
569  // overal_p and ele_[part_start_[overall_p] - 1] gives the last element in the partition.
570  // This array is also used to calculate the number of nonzero elements in each parition
571  // and in the overall partition. The last element part_start_[num_row_part * num_col_part_]
572  // gives the total number of nonzeros in all of the partitions and is also used
573  // to allow the calculation of the number of nonzero elements in the last partition.
574 
575  // When the view is uninitialized then ele_, row_part_, col_part_ and part_start_ will
576  // all uninitialized.
577 
578  // ///////////////////////////////////////////////////////////////
579  // Private member functions
580 
581  // assert that the object is initialized
582  void assert_initialized() const;
583 
584  size_type imp_overall_part_num(size_type row_p, size_type col_p) const;
585 
586  size_type imp_row_part_num(size_type overall_p) const;
587 
588  size_type imp_col_part_num(size_type overall_p) const;
589 
590  // Return the partition number given an indice.
591  // Passing the partition vector is an optimization
592  // that allows us to only call .obj() once
593  // on the reference object and thus same some
594  // unnecessary work.
595  size_type part_num(const vector_size_type& part, size_type indice);
596 
597  // Return the overall partition number
598  size_type overall_p_from_ij(const vector_size_type& row_part
599  , const vector_size_type& col_part, size_type i, size_type j);
600 
601  // Return a non-const partition. This is the function
602  // that implements all partition creations.
603  partition_type create_partition(Range1D rng_overall_p) const;
604 
605  // Not defined and not to be called
607 
608 }; // end class COOMatrixPartitionedView
609 
610 
611 namespace COOMatrixPartitionedViewUtilityPack {
612 
617 
618 // ///////////////////////////////////////////////////////////////////////
619 // ///////////////////////////////////////////////////////////////////////
632 template <class T_Indice, class T_Value>
633 class Partition {
634 public:
635  // /////////////////////////////////////////////////////
638 
640  typedef AbstractLinAlgPack::size_type size_type;
644  typedef ptrdiff_t difference_type;
650  typedef const element_type* const_iterator;
651 
653 
654  // /////////////////////////////////////////////////////
657 
664 
676  Partition();
677 
682  Partition(
684  , size_type cols
685  , size_type nz
686  , element_type* ele
689 
701  void initialize(
703  , size_type cols
704  , size_type nz
705  , element_type* ele
708 
713  void bind(const partition_type& partition);
714 
716 
719 
721  size_type rows() const;
723  size_type cols() const ;
725  size_type nz() const;
727  difference_type row_offset() const;
729  difference_type col_offset() const;
731  iterator begin();
733  const_iterator begin() const;
735  iterator end();
737  const_iterator end() const;
738 
740 
742 
743 private:
744  // //////////////////////////////////////////////////////
745  // Private types
746 
747  // //////////////////////////////////////////////////////
748  // Private data members
749 
750  size_type rows_, // The number of rows in this COO matrix
751  cols_, // The number of columns in this COO matrix
752  nz_; // The number of nonzero elements in this COO matrix
753  element_type *ele_; // pointer to array of elements in this COO matrix
754  difference_type row_offset_, // offset for each row indice stored in ele
755  col_offset_; // offset for each column indice stored in ele
756 
757  // //////////////////////////////////////////////////////
758  // Private member functions
759 
760  // assert that we are initialized
761  void assert_initialized() const;
762 
763  // not defined and not to be called
764  Partition& operator=(const Partition&);
765 
766 }; // end class Partition
767 
768 // /////////////////////////////////////////////////////////////////////////////////////
769 // /////////////////////////////////////////////////////////////////////////////////////
791 template <class T_Indice, class T_Value>
792 class TransposedPartition {
793 public:
794  // /////////////////////////////////////////////////////
797 
801  typedef AbstractLinAlgPack::size_type size_type;
803  typedef ptrdiff_t difference_type;
808  element_type*
809  , std::random_access_iterator_tag
810  , typename element_type::indice_type
811  , typename element_type::value_type&
815  const element_type*
816  , std::random_access_iterator_tag
817  , typename element_type::indice_type
818  , const typename element_type::value_type&
820 
822 
823  // /////////////////////////////////////////////////////
826 
833 
838  TransposedPartition(const partition_type& partition);
839 
844  void bind(const partition_type& partition);
845 
847 
850 
852  size_type rows() const;
854  size_type cols() const;
856  size_type nz() const;
858  difference_type row_offset() const;
860  difference_type col_offset() const;
862  iterator begin();
864  const_iterator begin() const;
866  iterator end();
868  const_iterator end() const;
869 
871 
873 
874 private:
875  partition_type partition_; // actually stores a partition object.
876 
877  // Not defined and not to be called
878  TransposedPartition& operator=(const TransposedPartition&);
879 
880 }; // end class TransposedPartition
881 
882 // end COOMatrixPartitionedViewUtilityPack
884 
885 } // end namespace COOMatrixPartitionedViewUtilityPack
886 
887 
888 // //////////////////////////////////////////////////////////////////////////
889 // Nonmember functions
890 
893 template<class T_Indice, class T_Value>
896 {
898  transposed_partition_type;
899  return transposed_partition_type(part);
900 }
901 
902 // ///////////////////////////////////////////////////////////////////////////
903 // Inline member function definitions
904 
905 namespace COOMatrixPartitionedViewUtilityPack {
906 
907 // ///////////////////////////////////////////////////////////////////////////
908 // Inline members for class COOMatrixPartitionedViewUtilityPack::Partition<>
909 
910 // Constructors and initializes
911 
912 template <class T_Indice, class T_Value>
914  : rows_(0), cols_(0), nz_(0), ele_(0), row_offset_(0), col_offset_(0)
915 {}
916 
917 template <class T_Indice, class T_Value>
920  , size_type cols
921  , size_type nz
922  , element_type* ele
923  , difference_type row_offset
924  , difference_type col_offset )
925  : rows_(rows), cols_(cols), nz_(nz), ele_(ele), row_offset_(row_offset)
926  , col_offset_(col_offset)
927 {}
928 
929 template <class T_Indice, class T_Value>
932  , size_type cols
933  , size_type nz
934  , element_type* ele
935  , difference_type row_offset
936  , difference_type col_offset )
937 {
938  rows_ = rows;
939  cols_ = cols;
940  nz_ = nz;
941  ele_ = ele;
942  row_offset_ = row_offset;
943  col_offset_ = col_offset;
944 }
945 
946 template <class T_Indice, class T_Value>
947 inline void Partition<T_Indice,T_Value>::bind(const partition_type& partition) {
948  initialize(partition.rows_,partition.cols_,partition.nz_,partition.ele_
949  ,partition.row_offset_,partition.col_offset_);
950 }
951 
952 // COOMatrixTemplateInterface interface
953 
954 template <class T_Indice, class T_Value>
957 {
958  return rows_;
959 }
960 
961 template <class T_Indice, class T_Value>
964 {
965  return cols_;
966 }
967 
968 template <class T_Indice, class T_Value>
971 {
972  return nz_;
973 }
974 
975 template <class T_Indice, class T_Value>
978 {
979  return row_offset_;
980 }
981 
982 template <class T_Indice, class T_Value>
985 {
986  return col_offset_;
987 }
988 
989 template <class T_Indice, class T_Value>
992 {
993  assert_initialized();
994  return ele_;
995 }
996 
997 template <class T_Indice, class T_Value>
1000 {
1001  assert_initialized();
1002  return ele_;
1003 }
1004 
1005 template <class T_Indice, class T_Value>
1008 {
1009  assert_initialized();
1010  return ele_ + nz_;
1011 }
1012 
1013 template <class T_Indice, class T_Value>
1016 {
1017  assert_initialized();
1018  return ele_ + nz_;
1019 }
1020 
1021 // Private member functions
1022 
1023 template <class T_Indice, class T_Value>
1025  if(!ele_)
1026  throw std::logic_error("Partition<...> :"
1027  "The COO matrix was not initizlized");
1028 }
1029 
1030 
1031 // ///////////////////////////////////////////////////////////////////////////
1032 // Inline members for class COOMatrixPartitionedViewUtilityPack::TransposedPartition<>
1033 
1034 // Constructors and initializes
1035 
1036 template <class T_Indice, class T_Value>
1038  : partition_(partition)
1039 {}
1040 
1041 template <class T_Indice, class T_Value>
1043  partition_.bind(partition);
1044 }
1045 
1046 // COOMatrixTemplateInterface interface
1047 
1048 template <class T_Indice, class T_Value>
1051 {
1052  return partition_.cols();
1053 }
1054 
1055 template <class T_Indice, class T_Value>
1058 {
1059  return partition_.rows();
1060 }
1061 
1062 template <class T_Indice, class T_Value>
1065 {
1066  return partition_.nz();
1067 }
1068 
1069 template <class T_Indice, class T_Value>
1072 {
1073  return partition_.col_offset();
1074 }
1075 
1076 template <class T_Indice, class T_Value>
1079 {
1080  return partition_.row_offset();
1081 }
1082 
1083 template <class T_Indice, class T_Value>
1086 {
1087  return iterator(partition_.begin());
1088 }
1089 
1090 template <class T_Indice, class T_Value>
1093 {
1094  return const_iterator(partition_.begin());
1095 }
1096 
1097 template <class T_Indice, class T_Value>
1100 {
1101  return iterator(partition_.end());
1102 }
1103 
1104 template <class T_Indice, class T_Value>
1107 {
1108  return const_iterator(partition_.end());
1109 }
1110 
1111 } // end namespace COOMatrixPartitionViewUtilityPack
1112 
1113 
1114 // ///////////////////////////////////////////////////////////////////////////
1115 // Inline members for class COOMatrixPartitionedView<>
1116 
1117 // Constructors and initializes
1118 
1119 template <class T_Indice, class T_Value>
1121  : num_row_part_(0), num_col_part_(0)
1122 {}
1123 
1124 template <class T_Indice, class T_Value>
1126  return ref_ele_.has_ref_set();
1127 }
1128 
1129 // Partitioning information
1130 
1131 template <class T_Indice, class T_Value>
1134 {
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];
1138 }
1139 
1140 template <class T_Indice, class T_Value>
1143 {
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];
1147 }
1148 
1149 template <class T_Indice, class T_Value>
1152 {
1153  assert_initialized();
1154  return ref_part_start_.const_obj()[num_row_part_ * num_col_part_];
1155 }
1156 
1157 template <class T_Indice, class T_Value>
1160 {
1161  return num_row_part_;
1162 }
1163 
1164 template <class T_Indice, class T_Value>
1167 {
1168  return num_col_part_;
1169 }
1170 
1171 template <class T_Indice, class T_Value>
1174 {
1175  assert_initialized();
1176  return partition_order_;
1177 }
1178 
1179 template <class T_Indice, class T_Value>
1182 {
1183  assert_initialized();
1184  return imp_overall_part_num(row_p, col_p);
1185 }
1186 
1187 template <class T_Indice, class T_Value>
1190 {
1191  assert_initialized();
1192  return imp_row_part_num(overall_p);
1193 }
1194 
1195 template <class T_Indice, class T_Value>
1198 {
1199  assert_initialized();
1200  return imp_col_part_num(overall_p);
1201 }
1202 
1203 // Partition access
1204 
1205 //template <class T_Indice, class T_Value>
1206 //inline COOMatrixPartitionedView<T_Indice,T_Value>::operator
1207 //COOMatrixPartitionedView<T_Indice,T_Value>::partition_type()
1208 //{
1209 // return partition(Range1D());
1210 //}
1211 
1212 //template <class T_Indice, class T_Value>
1213 //inline COOMatrixPartitionedView<T_Indice,T_Value>::operator
1214 //const COOMatrixPartitionedView<T_Indice,T_Value>::partition_type() const
1215 //{
1216 // return partition(Range1D());
1217 //}
1218 
1219 template <class T_Indice, class T_Value>
1222 {
1223  return partition(Range1D());
1224 }
1225 
1226 template <class T_Indice, class T_Value>
1229 {
1230  return partition(Range1D());
1231 }
1232 
1233 template <class T_Indice, class T_Value>
1236 {
1237  return partition(Range1D(overall_p,overall_p));
1238 }
1239 
1240 template <class T_Indice, class T_Value>
1243 {
1244  return partition(Range1D(overall_p,overall_p));
1245 }
1246 
1247 template <class T_Indice, class T_Value>
1250 {
1251  return partition(overall_part_num(row_p,col_p));
1252 }
1253 
1254 template <class T_Indice, class T_Value>
1257 {
1258  return partition(overall_part_num(row_p,col_p));
1259 }
1260 
1261 template <class T_Indice, class T_Value>
1264 {
1265  return create_partition(rng_overall_p);
1266 }
1267 
1268 template <class T_Indice, class T_Value>
1271 {
1272  return create_partition(rng_overall_p);
1273 }
1274 
1275 // Private member functions
1276 
1277 template <class T_Indice, class T_Value>
1279  if(!is_initialized())
1280  throw UninitializedException("COOMatrixPartitionedView<..>::assert_initialized() :"
1281  " The partitioned view has not been initialized.");
1282 }
1283 
1284 template <class T_Indice, class T_Value>
1286 COOMatrixPartitionedView<T_Indice,T_Value>::imp_overall_part_num(size_type row_p, size_type col_p) const
1287 {
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;
1291 }
1292 
1293 template <class T_Indice, class T_Value>
1295 COOMatrixPartitionedView<T_Indice,T_Value>::imp_row_part_num(size_type overall_p) const
1296 {
1297  return (partition_order_ == PARTITION_BY_ROW) ?
1298  (overall_p - 1) / num_col_part_ + 1 :
1299  (overall_p - 1) % num_row_part_ + 1 ;
1300 }
1301 
1302 template <class T_Indice, class T_Value>
1304 COOMatrixPartitionedView<T_Indice,T_Value>::imp_col_part_num(size_type overall_p) const
1305 {
1306  return (partition_order_ == PARTITION_BY_COL) ?
1307  (overall_p - 1) / num_row_part_ + 1 :
1308  (overall_p - 1) % num_col_part_ + 1 ;
1309 }
1310 
1311 template <class T_Indice, class T_Value>
1313 COOMatrixPartitionedView<T_Indice,T_Value>::overall_p_from_ij(const vector_size_type& row_part
1314  , const vector_size_type& col_part, size_type i, size_type j)
1315 {
1316  return imp_overall_part_num( part_num(row_part,i)
1317  , part_num(col_part,j) );
1318 }
1319 
1320 } // end namespace AbstractLinAlgPack
1321 
1322 #endif // COO_MATRIX_PARTITIONED_VIEW_CLASS_DECL_H
TransposedPartition(const partition_type &partition)
Construct with the partition initialized.
TransSparseCOOElementViewIter< const element_type *, std::random_access_iterator_tag, typename element_type::indice_type, const typename element_type::value_type &, difference_type > const_iterator
size_type cols() const
return the number of columns in the total view
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.
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)
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.
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
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
TransSparseCOOElementViewIter< element_type *, std::random_access_iterator_tag, typename element_type::indice_type, typename element_type::value_type &, difference_type > iterator
partition_type operator()()
Return a partition object for the entire view.
Templateded iterator for iterating through a set of COO Matix elements but viewing them in transpose...
size_t size_type
Sparse pointer element type for a COO matrix (val, ivect, jvect).
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.
size_type col_part_num(size_type overall_p) const
Returns the column parition number (1-based) given the overall partition number (1-based) ...
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.
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.
COOMatrixPartitionedViewUtilityPack::Partition< T_Indice, T_Value > partition_type
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)