Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
format_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2014 NVIDIA Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
21 #pragma once
22 
23 #include <cusp/detail/config.h>
24 
25 #include <thrust/execution_policy.h>
26 
27 namespace cusp
28 {
29 
36 /* \cond */
37 template <typename DerivedPolicy, typename OffsetArray, typename IndexArray>
38 void offsets_to_indices(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
39  const OffsetArray& offsets,
40  IndexArray& indices);
41 /* \endcond */
42 
78 template <typename OffsetArray, typename IndexArray>
79 void offsets_to_indices(const OffsetArray& offsets,
80  IndexArray& indices);
81 
82 /* \cond */
83 template <typename DerivedPolicy, typename IndexArray, typename OffsetArray>
84 void indices_to_offsets(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
85  const IndexArray& indices,
86  OffsetArray& offsets);
87 /* \endcond */
88 
125 template <typename IndexArray, typename OffsetArray>
126 void indices_to_offsets(const IndexArray& indices,
127  OffsetArray& offsets);
128 
129 /* \cond */
130 template <typename DerivedPolicy, typename MatrixType, typename ArrayType>
131 void extract_diagonal(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
132  const MatrixType& A,
133  ArrayType& output);
134 /* \endcond */
135 
173 template <typename MatrixType, typename ArrayType>
174 void extract_diagonal(const MatrixType& A, ArrayType& output);
175 
176 /* \cond */
177 template <typename DerivedPolicy, typename ArrayType1, typename ArrayType2>
178 size_t count_diagonals(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
179  const size_t num_rows,
180  const size_t num_cols,
181  const ArrayType1& row_indices,
182  const ArrayType2& column_indices );
183 /* \endcond */
184 
220 template <typename ArrayType1, typename ArrayType2>
221 size_t count_diagonals(const size_t num_rows,
222  const size_t num_cols,
223  const ArrayType1& row_indices,
224  const ArrayType2& column_indices);
225 
226 /* \cond */
227 template <typename DerivedPolicy, typename ArrayType>
228 size_t compute_max_entries_per_row(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
229  const ArrayType& row_offsets);
230 /* \endcond */
231 
260 template <typename ArrayType>
261 size_t compute_max_entries_per_row(const ArrayType& row_offsets);
262 
263 /* \cond */
264 template <typename DerivedPolicy, typename ArrayType>
265 size_t compute_optimal_entries_per_row(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
266  const ArrayType& row_offsets,
267  float relative_speed = 3.0f,
268  size_t breakeven_threshold = 4096);
269 /* \endcond */
270 
303 template <typename ArrayType>
304 size_t compute_optimal_entries_per_row(const ArrayType& row_offsets,
305  float relative_speed = 3.0f,
306  size_t breakeven_threshold = 4096);
310 } // end namespace cusp
311 
312 #include <cusp/detail/format_utils.inl>
313 
size_t compute_optimal_entries_per_row(const ArrayType &row_offsets, float relative_speed=3.0f, size_t breakeven_threshold=4096)
Compute the optimal number of entries per row of HYB matrix.
void offsets_to_indices(const OffsetArray &offsets, IndexArray &indices)
Expand CSR row offsets to COO row indices.
size_t count_diagonals(const size_t num_rows, const size_t num_cols, const ArrayType1 &row_indices, const ArrayType2 &column_indices)
Count the number of occupied diagonals in the input matrix.
void extract_diagonal(const MatrixType &A, ArrayType &output)
Extract the main diagonal of a matrix.
void indices_to_offsets(const IndexArray &indices, OffsetArray &offsets)
Compress COO row indices to CSR row offsets.
size_t compute_max_entries_per_row(const ArrayType &row_offsets)
Compute the maximum row length of a matrix.