/usr/include/rheolef/disarray_seq.icc is in librheolef-dev 6.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | ///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// =========================================================================
# include "rheolef/disarray.h"
# include "rheolef/load_chunk.h"
namespace rheolef {
// ----------------------------------------------------------------------------
// class member functions
// ----------------------------------------------------------------------------
template <class T, class A>
disarray_rep<T,sequential,A>::disarray_rep (const A& alloc)
: std::vector<T,A>(alloc),
_ownership ()
{
}
template <class T, class A>
disarray_rep<T,sequential,A>::disarray_rep (size_type loc_size1, const T& init_val, const A& alloc)
: std::vector<T,A>(loc_size1, init_val, alloc),
_ownership (distributor (distributor::decide, communicator(), loc_size1))
{
}
template <class T, class A>
disarray_rep<T,sequential,A>::disarray_rep (const distributor& ownership, const T& init_val, const A& alloc)
: std::vector<T,A>(ownership.size(),init_val,alloc),
_ownership(ownership)
{
}
template <class T, class A>
disarray_rep<T,sequential,A>::disarray_rep (const disarray_rep<T,sequential,A>& x)
: std::vector<T,A>(x.size()),
_ownership(x._ownership)
{
std::copy (x.begin(), x.end(), begin());
}
template <class T, class A>
void
disarray_rep<T,sequential,A>::resize (const distributor& ownership, const T& init_val)
{
// note: also called by disarray_rep<T,distributed,A>, so should works in distributed mode
_ownership = ownership;
std::vector<T,A>::resize (_ownership.size(), init_val);
std::fill (begin(), end(), init_val);
}
template <class T, class A>
void
disarray_rep<T,sequential,A>::resize (size_type loc_size1, const T& init_val)
{
// note: also called by disarray_rep<T,distributed,A>, so should works in distributed mode
_ownership.resize (distributor::decide, _ownership.comm(), loc_size1);
std::vector<T,A>::resize (_ownership.size(), init_val);
std::fill (begin(), end(), init_val);
}
template <class T, class A>
template <class GetFunction>
idiststream&
disarray_rep<T,sequential,A>::get_values (idiststream& ips, GetFunction get_element) {
std::istream& is = ips.is();
if (!load_chunk (is, begin(), end(), get_element))
error_macro("read failed on input stream.");
return ips;
}
template <class T, class A>
idiststream&
disarray_rep<T,sequential,A>::get_values (idiststream& ips)
{
return get_values (ips, _disarray_get_element_type<T>());
}
template <class T, class A>
template <class PutFunction>
odiststream&
disarray_rep<T,sequential,A>::put_values (odiststream& ops, PutFunction put_element) const
{
std::ostream& os = ops.os();
for (size_type i = 0; i < size(); i++) {
put_element (os, operator[](i));
os << std::endl;
}
return ops;
}
template <class T, class A>
odiststream&
disarray_rep<T,sequential,A>::put_values (odiststream& ops) const
{
return put_values (ops, _disarray_put_element_type<T>());
}
template <class T, class A>
odiststream&
disarray_rep<T,sequential,A>::put_matlab (odiststream& ops) const
{
ops << "[";
put_values (ops, _disarray_put_matlab_type<T>());
return ops << "];";
}
template <class T, class A>
void
disarray_rep<T,sequential,A>::dump (std::string name) const {
std::ofstream os (name.c_str());
std::cerr << "! file \"" << name << "\" created." << std::endl;
odiststream ops(os);
put_values(ops);
}
template <class T, class A>
template<class A2>
void
disarray_rep<T,sequential,A>::reverse_permutation ( // old_ownership for *this=iold2inew
disarray_rep<size_type,sequential,A2>& inew2iold) const // new_ownership
{
check_macro (inew2iold.size() == size(), "reverse permutation[0:"<<inew2iold.size()
<<"[ has incompatible dis_range with oriinal permutation[0:"<<size()<<"[");
for (size_type iold = 0, nold = size(); iold < nold; iold++) {
size_type inew = operator[] (iold);
inew2iold [inew] = iold;
}
}
//=======================================
} // namespace rheolef
|