CUSP
Loading...
Searching...
No Matches
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#include <cusp/detail/execution_policy.h>
25
26#include <cstddef>
27
28namespace cusp
29{
30
37/* \cond */
38template <typename DerivedPolicy,
39 typename OffsetArray,
40 typename IndexArray>
41void offsets_to_indices(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
42 const OffsetArray& offsets,
43 IndexArray& indices);
44/* \endcond */
45
81template <typename OffsetArray,
82 typename IndexArray>
83void offsets_to_indices(const OffsetArray& offsets,
84 IndexArray& indices);
85
86/* \cond */
87template <typename DerivedPolicy,
88 typename IndexArray,
89 typename OffsetArray>
90void indices_to_offsets(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
91 const IndexArray& indices,
92 OffsetArray& offsets);
93/* \endcond */
94
131template <typename IndexArray,
132 typename OffsetArray>
133void indices_to_offsets(const IndexArray& indices,
134 OffsetArray& offsets);
135
136/* \cond */
137template <typename DerivedPolicy,
138 typename MatrixType,
139 typename ArrayType>
140void extract_diagonal(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
141 const MatrixType& A,
142 ArrayType& output);
143/* \endcond */
144
182template <typename MatrixType,
183 typename ArrayType>
184void extract_diagonal(const MatrixType& A,
185 ArrayType& output);
186
187/* \cond */
188template <typename DerivedPolicy,
189 typename ArrayType1,
190 typename ArrayType2>
191size_t count_diagonals(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
192 const size_t num_rows,
193 const size_t num_cols,
194 const ArrayType1& row_indices,
195 const ArrayType2& column_indices );
196/* \endcond */
197
233template <typename ArrayType1,
234 typename ArrayType2>
235size_t count_diagonals(const size_t num_rows,
236 const size_t num_cols,
237 const ArrayType1& row_indices,
238 const ArrayType2& column_indices);
239
240/* \cond */
241template <typename DerivedPolicy,
242 typename ArrayType>
243size_t compute_max_entries_per_row(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
244 const ArrayType& row_offsets);
245/* \endcond */
246
275template <typename ArrayType>
276size_t compute_max_entries_per_row(const ArrayType& row_offsets);
277
278/* \cond */
279template <typename DerivedPolicy,
280 typename ArrayType>
281size_t compute_optimal_entries_per_row(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
282 const ArrayType& row_offsets,
283 float relative_speed = 3.0f,
284 size_t breakeven_threshold = 4096);
285/* \endcond */
286
319template <typename ArrayType>
320size_t compute_optimal_entries_per_row(const ArrayType& row_offsets,
321 float relative_speed = 3.0f,
322 size_t breakeven_threshold = 4096);
326} // end namespace cusp
327
328#include <cusp/detail/format_utils.inl>
329
void offsets_to_indices(const OffsetArray &offsets, IndexArray &indices)
Expand CSR row offsets to COO row indices.
void extract_diagonal(const MatrixType &A, ArrayType &output)
Extract the main diagonal of a matrix.
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 indices_to_offsets(const IndexArray &indices, OffsetArray &offsets)
Compress COO row indices to CSR row offsets.
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.
size_t compute_max_entries_per_row(const ArrayType &row_offsets)
Compute the maximum row length of a matrix.