Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
csr_to_asr.h
Go to the documentation of this file.
1#ifndef _CSR_TO_ASR_H
2#define _CSR_TO_ASR_H
23
24namespace rheolef {
25/*F:
26NAME: csr_to_asr -- sequential sparse matrix convertion (@PACKAGE@ @VERSION@)
27DESCRIPTION:
28 Convert sequential "csr" to sequential "asr" sparse matrix format.
29ALGORITHM:
30 csr_build_from_asr
31
32 "input": the sparse asr matrix
33 | ia(0:nrow-1), a(0:nnz-1)
34 | ib(0:2*nrow+1), op(.)
35 "ouput": the sparse csr matrix
36 | b(0:nnz-1)
37 begin
38 | q := 0
39 | for i := 0 to nrow-1 do
40 | q := ib(2*i)
41 | for p := ia(i) to ia(i+1)-1 do
42 | b(q) := op(a(p))
43 | q := q + 1
44 | endfor
45 | endfor
46 end
47COMPLEXITY:
48 Time and memory complexity is O(nnz).
49NOTE:
50 The output arrays are supposed to be coorectly allocated,
51 i.e. large enough.
52
53 The pointer array "ib" is taken as input parameter,
54 since practical C++ "asr" implementation uses STL "map"
55 for data storage. Thus "ib(.)" is an array of STL map,
56 and this algorithm is only formal.
57 METHODS: @csr_to_asr
58AUTHORS:
59 LMC-IMAG, 38041 Grenoble cedex 9, France
60 | Pierre.Saramito@imag.fr
61DATE: 22 march 1999
62END:
63*/
64//<csr_to_asr:
65template <
66 class InputPtrIterator,
67 class InputDataIterator,
68 class UnaryOperation,
69 class OutputPtrIterator>
70OutputPtrIterator
72 InputPtrIterator iter_ptr_a,
73 InputPtrIterator last_ptr_a,
74 InputDataIterator iter_data_a,
75 UnaryOperation op,
76 OutputPtrIterator iter_ptr_b)
77{
78 InputPtrIterator first_ptr_a = iter_ptr_a;
79 InputDataIterator first_data_a = iter_data_a;
80 InputPtrIterator next_ptr_a = iter_ptr_a;
81 next_ptr_a++;
82 while (next_ptr_a != last_ptr_a) {
83 InputDataIterator last_data_a = (*next_ptr_a);
84 while (iter_data_a != last_data_a) {
85 (*iter_ptr_b).insert(op(*iter_data_a));
86 iter_data_a++;
87 }
88 next_ptr_a++;
89 iter_ptr_b++;
90 }
91 return iter_ptr_b;
92}
93//>csr_to_asr:
94} // namespace rheolef
95#endif // _CSR_TO_ASR_H
This file is part of Rheolef.
OutputPtrIterator csr_to_asr(InputPtrIterator iter_ptr_a, InputPtrIterator last_ptr_a, InputDataIterator iter_data_a, UnaryOperation op, OutputPtrIterator iter_ptr_b)
Definition csr_to_asr.h:71