33 #ifndef __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__SCHUR_SLICING_H_
34 #define __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__SCHUR_SLICING_H_
67 template <
class TVec,
size_t N>
111 for (
size_t i=0; i< ntypes; ++i)
124 for (
size_t i=0; i< ntypes; ++i)
134 for (
size_t tt=0; tt<N; ++tt)
161 small_dst.resize(slice_desc.size());
162 slice_desc_set::const_iterator elem = slice_desc.begin();
163 for (
size_t i=0; i<slice_desc.size(); ++i, ++elem)
164 { small_dst[i] = full_src[*elem]; }
175 slice_desc_set::const_iterator elem = slice_desc.begin();
176 for (
size_t i=0; i<slice_desc.size(); ++i, ++elem)
179 full_dst[*elem] = small_src[i];
188 small_dst.resize(slice_desc.size());
189 slice_desc_set::const_iterator elem = slice_desc.begin();
190 for (
size_t i=0; i<slice_desc.size(); ++i, ++elem)
191 { small_dst[i] += sigma*full_src[*elem]; }
199 slice_desc_set::const_iterator elem = slice_desc.begin();
200 for (
size_t i=0; i<slice_desc.size(); ++i, ++elem)
201 { full_dst[*elem] += sigma*small_src[i]; }
222 UG_DLOG(
SchurDebug, 5,
"SlicingData::get_matrix:" << row_slice.size() <<
"x" << col_slice.size()<< std::endl)
223 Aslice.resize_and_clear(row_slice.size(), col_slice.size());
226 for (slice_desc_set::const_iterator elem = row_slice.begin();
227 elem!=row_slice.end(); ++elem, ++ii)
230 for(
typename MT::const_row_iterator it = A.begin_row(i);
231 it != A.end_row(i); ++it)
234 const int j=it.index();
239 Aslice(ii, jj) = it.value();
248 {
return slice(type).size();}
263 uint mask = full_src.get_storage_mask();
264 clone->set_storage_type(mask);
277 vectorslice.resize(slice_desc.size());
283 uint mask = full_src.get_storage_mask();
284 vectorslice->set_storage_type(mask);
321 index = myset.size();
324 slice_desc_set::const_iterator it = lower_bound(myset.begin(), myset.end(), gindex);
325 if (it != myset.end() && *it == gindex) {
327 index = std::distance(myset.begin(), it);
331 UG_ASSERT( (!found || index<(
int)myset.size()) ,
"Invalid index found!");
352 return slice_layouts;
361 for (iter = il.
begin(); iter!=il.
end(); ++iter)
368 for (eiter = interf.
begin(); eiter!=interf.
end(); ++eiter)
373 bool found=
find_index(type, myindex, newindex);
Definition: smart_pointer.h:296
Definition: smart_pointer.h:108
You may add elements to this interface and iterate over them.
Definition: pcl_communication_structs.h:207
iterator end()
Definition: pcl_communication_structs.h:293
iterator begin()
Definition: pcl_communication_structs.h:292
Element & get_element(iterator iter)
Definition: pcl_communication_structs.h:298
iterator erase(iterator iter)
Definition: pcl_communication_structs.h:286
iterator end(size_t level=0)
returns the iterator to the last interface of the layout.
Definition: pcl_communication_structs.h:492
iterator begin(size_t level=0)
returns the iterator to the first interface of the layout.
Definition: pcl_communication_structs.h:486
Interface & interface(iterator iter)
returns the interface to the given iterator.
Definition: pcl_communication_structs.h:505
InterfaceMap::iterator iterator
An iterator that allows to iterate over the interfaces stored in the layout.
Definition: pcl_communication_structs.h:476
Extends the HorizontalAlgebraLayouts by vertical layouts.
Definition: algebra_layouts.h:121
void fill_set_mappings()
Auto fill for sets.
Definition: slicing.h:120
SmartPtr< VT > slice_clone_without_values(const VT &full_src, slice_desc_type type) const
Create a (partial) clone of the vector, without copying values.
Definition: slicing.h:253
void subtract_vector_slice(const VT &small_src, VT &full_dst, slice_desc_type desc) const
substract: small vector -> slice of a vector
Definition: slicing.h:212
slice_desc_type get_type(size_t index)
returns type for a global index
Definition: slicing.h:302
SmartPtr< AlgebraLayouts > create_slice_layouts(ConstSmartPtr< AlgebraLayouts > fullLayouts, slice_desc_type type) const
Create new slice layouts (as a subset from full layouts).
Definition: slicing.h:338
void add_vector_slice(const VT &small_src, VT &full_dst, slice_desc_type desc, double sigma=1.0) const
Add: small vector -> slice of a vector.
Definition: slicing.h:196
SlicingData()
Constructor.
Definition: slicing.h:83
SlicingData(const slice_desc_type_vector &types)
Definition: slicing.h:87
TVec slice_desc_type_vector
Definition: slicing.h:72
void get_vector_slice(const VT &full_src, slice_desc_type desc, VT &small_dst) const
Copy: slice of vector -> small vector.
Definition: slicing.h:156
void replace_indices_in_layout(slice_desc_type type, IndexLayout &il) const
Definition: slicing.h:356
std::vector< int > slice_desc_set
Definition: slicing.h:71
bool m_valid
Definition: slicing.h:76
size_t get_num_elems(slice_desc_type type) const
Number of elements for each type.
Definition: slicing.h:247
void add_vector_slice(const VT &full_src, slice_desc_type desc, VT &small_dst, double sigma=1.0) const
Add: slice of vector -> small vector.
Definition: slicing.h:185
void reset_set_mappings()
Clear & auto fill.
Definition: slicing.h:143
bool is_valid()
Definition: slicing.h:101
slice_desc_set & slice(slice_desc_type type)
Definition: slicing.h:310
TVec::value_type slice_desc_type
Definition: slicing.h:73
const slice_desc_set & slice(slice_desc_type type) const
returns the set of global indices for a given type
Definition: slicing.h:307
void set_vector_slice(const VT &small_src, VT &full_dst, slice_desc_type desc) const
Copy: small vector -> slice of a vector.
Definition: slicing.h:171
slice_desc_type_vector m_slice_types
global vector with mappings iglobal -> type(iglobal)
Definition: slicing.h:77
void get_matrix(const MT &A, slice_desc_type row_type, slice_desc_type col_type, MT &Aslice) const
Definition: slicing.h:218
void setup_slice_like(const VT &full_src, slice_desc_type type, VT &vectorslice) const
Sets an existing sliced vector up correctly.
Definition: slicing.h:273
slice_desc_set m_slice_set[N]
N mappings: islice(type) -> iglobal.
Definition: slicing.h:78
void subtract_vector_slice(const VT &full_src, slice_desc_type desc, VT &small_dst) const
substract: slice of vector -> small vector
Definition: slicing.h:207
SmartPtr< VT > slice_clone(const VT &full_src, slice_desc_type type) const
Create a (partial) clone.
Definition: slicing.h:291
void clear_set_mappings()
Clear all sets.
Definition: slicing.h:108
bool find_index(slice_desc_type type, int gindex, int &index) const
returns: local index for a global index (if found) or undefined else.
Definition: slicing.h:315
void set_types(const slice_desc_type_vector &types, bool bClear=false)
Copy types.
Definition: slicing.h:94
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_DLOG(__debugID__, level, msg)
Definition: log.h:298
unsigned int uint
Definition: types.h:114
DebugID SchurDebug
todo: replace DebugID
Definition: schur.h:55
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition: smart_pointer.h:836
T value_type
Definition: sparsematrix_interface.h:2