ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SparseAssembly.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File SparseAssembly.h -------------------------*/
3/*--------------------------------------------------------------------------*/
69/*--------------------------------------------------------------------------*/
70/*----------------------------- DEFINITIONS --------------------------------*/
71/*--------------------------------------------------------------------------*/
72
73#ifndef __ADS_SparseAssembly
74 #define __ADS_SparseAssembly
75/* self-identification: #endif constant */
76
77/*--------------------------------------------------------------------------*/
78/*------------------------------ INCLUDES ----------------------------------*/
79/*--------------------------------------------------------------------------*/
80
81#include "ADS/Contract.h"
83
84#include <algorithm>
85#include <cstddef>
86#include <cstdint>
87#include <limits>
88#include <utility>
89#include <type_traits>
90#include <vector>
91
92/*--------------------------------------------------------------------------*/
93/*--------------------------- NAMESPACE ------------------------------------*/
94/*--------------------------------------------------------------------------*/
95
96namespace ADS
97{
98
99/*--------------------------------------------------------------------------*/
100/*------------------------- CLASS AssemblyWorkspace ------------------------*/
101/*--------------------------------------------------------------------------*/
102
105template< class I , class V >
107{
108 template< class U > // not zeroed when they grow
109 using Vector = std::vector< U , detail::DefaultInitAllocator< U > >;
110
113 std::vector< std::pair< I , V > > pairs;
114 };
115
116/*--------------------------------------------------------------------------*/
117/*------------------------------ FUNCTIONS ---------------------------------*/
118/*--------------------------------------------------------------------------*/
119
160template< class I , class V , class J >
161std::size_t compressTriplets( std::size_t nmajor , std::size_t nminor ,
162 std::size_t z , const J * major ,
163 const J * minor ,
164 const V * value , I * beg , I * ind , V * val ,
166
168template< class I , class V , class J >
169std::size_t compressTriplets( std::size_t nmajor , std::size_t nminor ,
170 std::size_t z , const J * major ,
171 const J * minor ,
172 const V * value , I * beg , I * ind , V * val );
173
188template< class I , class V , class J >
189std::size_t assembleCsc( std::size_t m , std::size_t n , std::size_t z ,
190 const J * row , const J * col , const V * value ,
191 I * beg , I * ind , V * val ,
193
205template< class I , class V , class J >
206std::size_t assembleCsr( std::size_t m , std::size_t n , std::size_t z ,
207 const J * row , const J * col , const V * value ,
208 I * beg , I * ind , V * val ,
210
211/*--------------------------------------------------------------------------*/
212
213} // end( namespace ADS )
214
215/*--------------------------------------------------------------------------*/
216/*-------------------------- IMPLEMENTATION --------------------------------*/
217/*--------------------------------------------------------------------------*/
218
219#include "ADS/numeric/impl/SparseAssembly.tpp"
220
221/*--------------------------------------------------------------------------*/
222
223#endif /* SparseAssembly.h included */
224
225/*--------------------------------------------------------------------------*/
226/*------------------------ End File SparseAssembly.h -----------------------*/
227/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The dense matrices by rows, beyond the book: DenseMatrix keeps the entries by rows in one contiguous...
std::size_t compressTriplets(std::size_t nmajor, std::size_t nminor, std::size_t z, const J *major, const J *minor, const V *value, I *beg, I *ind, V *val, AssemblyWorkspace< I, V > &work)
the compressed form, by major index, of the triplets of a matrix of , the values of equal places su...
std::size_t assembleCsc(std::size_t m, std::size_t n, std::size_t z, const J *row, const J *col, const V *value, I *beg, I *ind, V *val, AssemblyWorkspace< I, V > &work)
the compressed sparse columns of the matrix of the triplets : beg has places, ind holds the rows; ...
std::size_t assembleCsr(std::size_t m, std::size_t n, std::size_t z, const J *row, const J *col, const V *value, I *beg, I *ind, V *val, AssemblyWorkspace< I, V > &work)
the compressed sparse rows of the same: beg has places, ind holds the columns; the number of the ent...
Definition ADT.h:96
the scratch of compressTriplets(), which keeps its memory from one call to the next
Definition SparseAssembly.h:107
std::vector< U, detail::DefaultInitAllocator< U > > Vector
Definition SparseAssembly.h:109
std::vector< std::pair< I, V > > pairs
a long one, to sort
Definition SparseAssembly.h:113
Vector< I > cursor
the cursor of each major index
Definition SparseAssembly.h:111
Vector< I > mark
the last place of each minor one
Definition SparseAssembly.h:112