/[escript]/trunk/cusplibrary/cusp/dia_matrix.h
ViewVC logotype

Diff of /trunk/cusplibrary/cusp/dia_matrix.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5209 by caltinay, Tue Oct 21 06:50:20 2014 UTC revision 5225 by caltinay, Mon Oct 27 01:33:45 2014 UTC
# Line 75  namespace cusp Line 75  namespace cusp
75   *  A.values(1,2) =  0;  // outside matrix   *  A.values(1,2) =  0;  // outside matrix
76   *  A.values(2,0) = 40;   *  A.values(2,0) = 40;
77   *  A.values(3,0) = 60;   *  A.values(3,0) = 60;
78   *     *
79   *  // second diagonal   *  // second diagonal
80   *  A.values(0,1) = 10;   *  A.values(0,1) = 10;
81   *  A.values(1,1) =  0;   *  A.values(1,1) =  0;
# Line 105  class dia_matrix : public detail::matrix Line 105  class dia_matrix : public detail::matrix
105    typedef cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::dia_format> Parent;    typedef cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::dia_format> Parent;
106    public:    public:
107      // TODO statically assert is_signed<IndexType>      // TODO statically assert is_signed<IndexType>
108        
109      /*! rebind matrix to a different MemorySpace      /*! rebind matrix to a different MemorySpace
110       */       */
111      template<typename MemorySpace2>      template<typename MemorySpace2>
# Line 114  class dia_matrix : public detail::matrix Line 114  class dia_matrix : public detail::matrix
114      /*! type of diagonal offsets array      /*! type of diagonal offsets array
115       */       */
116      typedef typename cusp::array1d<IndexType, MemorySpace>                     diagonal_offsets_array_type;      typedef typename cusp::array1d<IndexType, MemorySpace>                     diagonal_offsets_array_type;
117        
118      /*! type of values array      /*! type of values array
119       */       */
120      typedef typename cusp::array2d<ValueType, MemorySpace, cusp::column_major> values_array_type;      typedef typename cusp::array2d<ValueType, MemorySpace, cusp::column_major> values_array_type;
# Line 128  class dia_matrix : public detail::matrix Line 128  class dia_matrix : public detail::matrix
128      typedef typename cusp::dia_matrix_view<typename diagonal_offsets_array_type::view,      typedef typename cusp::dia_matrix_view<typename diagonal_offsets_array_type::view,
129                                             typename values_array_type::view,                                             typename values_array_type::view,
130                                             IndexType, ValueType, MemorySpace> view;                                             IndexType, ValueType, MemorySpace> view;
131        
132      /*! equivalent const_view type      /*! equivalent const_view type
133       */       */
134      typedef typename cusp::dia_matrix_view<typename diagonal_offsets_array_type::const_view,      typedef typename cusp::dia_matrix_view<typename diagonal_offsets_array_type::const_view,
# Line 138  class dia_matrix : public detail::matrix Line 138  class dia_matrix : public detail::matrix
138      /*! Storage for the diagonal offsets.      /*! Storage for the diagonal offsets.
139       */       */
140      diagonal_offsets_array_type diagonal_offsets;      diagonal_offsets_array_type diagonal_offsets;
141        
142      /*! Storage for the nonzero entries of the DIA data structure.      /*! Storage for the nonzero entries of the DIA data structure.
143       */       */
144      values_array_type values;      values_array_type values;
145            
146      /*! Indicator for matrix symmetry. If true, only non-negative diagonal      /*! Indicator for matrix symmetry. If true, only non-negative diagonal
147       *  offsets are stored.       *  offsets are stored.
148       */       */
# Line 170  class dia_matrix : public detail::matrix Line 170  class dia_matrix : public detail::matrix
170          // TODO use array2d constructor when it can accept pitch          // TODO use array2d constructor when it can accept pitch
171          values.resize(num_rows, num_diagonals, detail::round_up(num_rows, alignment));          values.resize(num_rows, num_diagonals, detail::round_up(num_rows, alignment));
172        }        }
173        
174      /*! Construct a \p dia_matrix from another matrix.      /*! Construct a \p dia_matrix from another matrix.
175       *       *
176       *  \param matrix Another sparse or dense matrix.       *  \param matrix Another sparse or dense matrix.
177       */       */
178      template <typename MatrixType>      template <typename MatrixType>
179      dia_matrix(const MatrixType& matrix);      dia_matrix(const MatrixType& matrix);
180        
181      /*! Resize matrix dimensions and underlying storage      /*! Resize matrix dimensions and underlying storage
182       */       */
183      void resize(size_t num_rows, size_t num_cols, size_t num_entries,      void resize(size_t num_rows, size_t num_cols, size_t num_entries,
# Line 187  class dia_matrix : public detail::matrix Line 187  class dia_matrix : public detail::matrix
187        diagonal_offsets.resize(num_diagonals);        diagonal_offsets.resize(num_diagonals);
188        values.resize(num_rows, num_diagonals);        values.resize(num_rows, num_diagonals);
189      }      }
190                  
191      /*! Resize matrix dimensions and underlying storage      /*! Resize matrix dimensions and underlying storage
192       */       */
193      void resize(size_t num_rows, size_t num_cols, size_t num_entries,      void resize(size_t num_rows, size_t num_cols, size_t num_entries,
# Line 197  class dia_matrix : public detail::matrix Line 197  class dia_matrix : public detail::matrix
197        diagonal_offsets.resize(num_diagonals);        diagonal_offsets.resize(num_diagonals);
198        values.resize(num_rows, num_diagonals, detail::round_up(num_rows, alignment));        values.resize(num_rows, num_diagonals, detail::round_up(num_rows, alignment));
199      }      }
200        
201      /*! Swap the contents of two \p dia_matrix objects.      /*! Swap the contents of two \p dia_matrix objects.
202       *       *
203       *  \param matrix Another \p dia_matrix with the same IndexType and ValueType.       *  \param matrix Another \p dia_matrix with the same IndexType and ValueType.
# Line 209  class dia_matrix : public detail::matrix Line 209  class dia_matrix : public detail::matrix
209        values.swap(matrix.values);        values.swap(matrix.values);
210        thrust::swap(symmetric, matrix.symmetric);        thrust::swap(symmetric, matrix.symmetric);
211      }      }
212        
213      /*! Assignment from another matrix.      /*! Assignment from another matrix.
214       *       *
215       *  \param matrix Another sparse or dense matrix.       *  \param matrix Another sparse or dense matrix.
# Line 219  class dia_matrix : public detail::matrix Line 219  class dia_matrix : public detail::matrix
219  }; // class dia_matrix  }; // class dia_matrix
220  /*! \}  /*! \}
221   */   */
222        
223  /*! \addtogroup sparse_matrix_views Sparse Matrix Views  /*! \addtogroup sparse_matrix_views Sparse Matrix Views
224   *  \ingroup sparse_matrices   *  \ingroup sparse_matrices
225   *  \{   *  \{
# Line 246  class dia_matrix_view : public detail::m Line 246  class dia_matrix_view : public detail::m
246      /*! type of \c diagonal_offsets array      /*! type of \c diagonal_offsets array
247       */       */
248      typedef Array1 diagonal_offsets_array_type;      typedef Array1 diagonal_offsets_array_type;
249        
250      /*! type of \c column_indices array      /*! type of \c column_indices array
251       */       */
252      typedef Array2 values_array_type;      typedef Array2 values_array_type;
# Line 280  class dia_matrix_view : public detail::m Line 280  class dia_matrix_view : public detail::m
280      dia_matrix_view(size_t num_rows, size_t num_cols, size_t num_entries,      dia_matrix_view(size_t num_rows, size_t num_cols, size_t num_entries,
281                      const OtherArray1& diagonal_offsets, const OtherArray2& values)                      const OtherArray1& diagonal_offsets, const OtherArray2& values)
282      : Parent(num_rows, num_cols, num_entries), diagonal_offsets(diagonal_offsets), values(values) {}      : Parent(num_rows, num_cols, num_entries), diagonal_offsets(diagonal_offsets), values(values) {}
283        
284      template <typename Matrix>      template <typename Matrix>
285      dia_matrix_view(Matrix& A)      dia_matrix_view(Matrix& A)
286      : Parent(A), diagonal_offsets(A.diagonal_offsets), values(A.values) {}      : Parent(A), diagonal_offsets(A.diagonal_offsets), values(A.values) {}
287        
288      template <typename Matrix>      template <typename Matrix>
289      dia_matrix_view(const Matrix& A)      dia_matrix_view(const Matrix& A)
290      : Parent(A), diagonal_offsets(A.diagonal_offsets), values(A.values) {}      : Parent(A), diagonal_offsets(A.diagonal_offsets), values(A.values) {}
291        
292      /*! Resize matrix dimensions and underlying storage      /*! Resize matrix dimensions and underlying storage
293       */       */
294      void resize(size_t num_rows, size_t num_cols, size_t num_entries,      void resize(size_t num_rows, size_t num_cols, size_t num_entries,
# Line 298  class dia_matrix_view : public detail::m Line 298  class dia_matrix_view : public detail::m
298        diagonal_offsets.resize(num_diagonals);        diagonal_offsets.resize(num_diagonals);
299        values.resize(num_rows, num_diagonals);        values.resize(num_rows, num_diagonals);
300      }      }
301                  
302      /*! Resize matrix dimensions and underlying storage      /*! Resize matrix dimensions and underlying storage
303       */       */
304      void resize(size_t num_rows, size_t num_cols, size_t num_entries,      void resize(size_t num_rows, size_t num_cols, size_t num_entries,
# Line 327  template <typename Array1, Line 327  template <typename Array1,
327            typename MemorySpace>            typename MemorySpace>
328  dia_matrix_view<Array1,Array2,IndexType,ValueType,MemorySpace>  dia_matrix_view<Array1,Array2,IndexType,ValueType,MemorySpace>
329  make_dia_matrix_view(const dia_matrix_view<Array1,Array2,IndexType,ValueType,MemorySpace>& m);  make_dia_matrix_view(const dia_matrix_view<Array1,Array2,IndexType,ValueType,MemorySpace>& m);
330        
331  template <typename IndexType, typename ValueType, class MemorySpace>  template <typename IndexType, typename ValueType, class MemorySpace>
332  typename dia_matrix<IndexType,ValueType,MemorySpace>::view  typename dia_matrix<IndexType,ValueType,MemorySpace>::view
333  make_dia_matrix_view(dia_matrix<IndexType,ValueType,MemorySpace>& m);  make_dia_matrix_view(dia_matrix<IndexType,ValueType,MemorySpace>& m);
# Line 337  typename dia_matrix<IndexType,ValueType, Line 337  typename dia_matrix<IndexType,ValueType,
337  make_dia_matrix_view(const dia_matrix<IndexType,ValueType,MemorySpace>& m);  make_dia_matrix_view(const dia_matrix<IndexType,ValueType,MemorySpace>& m);
338  /*! \} // end Views  /*! \} // end Views
339   */   */
340        
341  } // end namespace cusp  } // end namespace cusp
342    
343  #include <cusp/array2d.h>  #include <cusp/array2d.h>

Legend:
Removed from v.5209  
changed lines
  Added in v.5225

  ViewVC Help
Powered by ViewVC 1.1.26