|
AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization 00005 // Copyright (2003) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef COO_MATRIX_WITH_PARTITIONED_VIEW_H 00030 #define COO_MATRIX_WITH_PARTITIONED_VIEW_H 00031 00032 #include "AbstractLinAlgPack_COOMatrixClass.hpp" 00033 #include "AbstractLinAlgPack_COOMatrixPartitionedViewClass.hpp" 00034 00035 namespace AbstractLinAlgPack { 00036 00053 class COOMatrixWithPartitionedView { 00054 public: 00055 00056 // ///////////////////////////////////////////////////////////// 00059 00061 typedef COOMatrixPartitionedView<indice_type,value_type> partitioned_view_type; 00063 typedef partitioned_view_type::partition_type partition_type; 00065 typedef partitioned_view_type::EPartitionOrder EPartitionOrder; 00066 00068 00070 size_type rows() const { 00071 return coom_view_.is_initialized() ? coom_view_.rows() : coom_.rows(); 00072 } 00073 00075 size_type cols() const { 00076 return coom_view_.is_initialized() ? coom_view_.cols() : coom_.cols(); 00077 } 00078 00080 COOMatrixWithPartitionedView& operator=(const COOMatrixWithPartitionedView& m) { 00081 coom_ = m.coom_; 00082 coom_view_.bind(coom_view_); 00083 return *this; 00084 } 00085 00090 COOMatrixWithPartitionedView& operator=(const COOMatrix& m) { 00091 coom_ = m; 00092 coom_view_.free(); 00093 return *this; 00094 } 00095 00096 // ///////////////////////////////////////////////////////////// 00102 00107 void resize(size_type rows, size_type cols, size_type nz) { 00108 coom_view_.free(); 00109 coom_.resize(rows,cols,nz); 00110 } 00111 00116 value_type* val() { 00117 return coom_.val(); 00118 } 00123 indice_type* ivect() { 00124 coom_view_.free(); 00125 return coom_.ivect(); 00126 } 00131 indice_type* jvect() { 00132 coom_view_.free(); 00133 return coom_.jvect(); 00134 } 00135 00140 void initialize(std::istream& istrm) { 00141 coom_view_.free(); 00142 coom_.initialize(istrm); 00143 } 00144 00146 00148 const COOMatrix& coom() const { 00149 return coom_; 00150 } 00151 00152 // //////////////////////////////////////////////////////////////// 00155 00161 void create_view( 00162 const size_type row_perm[] 00163 , const size_type col_perm[] 00164 , const size_type num_row_part 00165 , const size_type row_part[] 00166 , const size_type num_col_part 00167 , const size_type col_part[] 00168 , const EPartitionOrder partition_order ) 00169 { 00170 coom_view_.create_view(coom_.rows(),coom_.cols(),coom_.nz(),coom_.val(),coom_.const_ivect() 00171 ,coom_.const_jvect(),row_perm,col_perm,num_row_part,row_part,num_col_part,col_part 00172 ,partition_order); 00173 } 00174 00176 partition_type partition(size_type overall_p) { 00177 return coom_view_.partition(overall_p); 00178 } 00179 00181 partition_type partition(size_type row_p, size_type col_p) { 00182 return coom_view_.partition(row_p, col_p); 00183 } 00184 00186 partition_type partition(Range1D rng_overall_p) { 00187 return coom_view_.partition(rng_overall_p); 00188 } 00189 00191 00193 const partitioned_view_type& coom_view() const { 00194 return coom_view_; 00195 } 00196 00197 00198 private: 00199 COOMatrix coom_; 00200 partitioned_view_type coom_view_; 00201 00202 00203 }; // end class COOMatrixWithPartitionedView 00204 00205 00206 } // end namespace AbstractLinAlgPack 00207 00208 #endif // COO_MATRIX_WITH_PARTITIONED_VIEW_H
1.7.4