30 #ifndef _FULLY_DIST_VEC_H_ 31 #define _FULLY_DIST_VEC_H_ 46 template <
class IT,
class NT>
49 template <
class IT,
class NT,
class DER>
55 template <
class IU,
class NU>
60 template <
class IT,
class NT>
61 class FullyDistVec:
public FullyDist<IT,NT, typename combblas::disable_if< combblas::is_boolean<NT>::value, NT >::type >
67 FullyDistVec ( std::shared_ptr<CommGrid> grid, IT globallen, NT initval);
69 FullyDistVec (
const std::vector<NT> & fillarr, std::shared_ptr<CommGrid> grid );
72 template <
class ITRHS,
class NTRHS>
78 NT
getNoNum(IT index) {
return static_cast<NT
>(1); }
80 template <
typename c,
typename t>
81 NT
read(std::basic_istream<c,t>& is, IT index)
88 template <
typename c,
typename t>
89 void save(std::basic_ostream<c,t>& os,
const NT& v, IT index)
95 template <
class HANDLER>
96 void ParallelWrite(
const std::string & filename,
bool onebased, HANDLER handler,
bool includeindices =
true)
99 tmpSpVec.
ParallelWrite(filename, onebased, handler, includeindices);
104 template <
typename _BinaryOperation>
105 void ParallelRead (
const std::string & filename,
bool onebased, _BinaryOperation BinOp)
112 template <
class HANDLER>
113 std::ifstream&
ReadDistribute (std::ifstream& infile,
int master, HANDLER handler);
116 template <
class HANDLER>
117 void SaveGathered(std::ofstream& outfile,
int master, HANDLER handler,
bool printProcSplits =
false);
121 template <
class ITRHS,
class NTRHS>
129 #pragma omp parallel for 131 for(IT i=0; i < arr.size(); ++i)
152 template <
class NT1,
typename _BinaryOperationIdx,
typename _BinaryOperationVal>
153 void GSet (
const FullyDistSpVec<IT,NT1> & spVec, _BinaryOperationIdx __binopIdx, _BinaryOperationVal __binopVal, MPI_Win win);
154 template <
class NT1,
typename _BinaryOperationIdx>
157 void iota(IT globalsize, NT first);
170 template <
typename _Predicate>
175 template <
typename _Predicate>
178 template <
typename _Predicate>
179 IT
Count(_Predicate pred)
const;
181 template <
typename _UnaryOperation>
182 void Apply(_UnaryOperation __unary_op)
184 std::transform(arr.begin(), arr.end(), arr.begin(), __unary_op);
187 template <
typename _BinaryOperation>
190 IT offset = LengthUntil();
192 #pragma omp parallel for 194 for(
size_t i=0; i < arr.size(); ++i)
195 arr[i] = __binary_op(arr[i], i + offset);
198 template <
typename _UnaryOperation,
typename IRRELEVANT_NT>
202 template <
typename _BinaryOperation,
typename _BinaryPredicate,
class NT2>
204 template <
typename _BinaryOperation,
typename _BinaryPredicate,
class NT2>
205 void EWiseApply(
const FullyDistSpVec<IT,NT2> & other, _BinaryOperation __binary_op, _BinaryPredicate _do_op,
bool applyNulls, NT2 nullValue,
const bool useExtendedBinOp);
208 template <
typename _BinaryOperation,
typename _BinaryPredicate,
class NT2>
216 template <
typename _BinaryOperation,
typename _BinaryPredicate,
class NT2>
222 applyNulls, nullValue,
true);
226 template <
typename T1,
typename T2>
235 template <
typename _BinaryOperation,
class NT2>
240 template <
typename _BinaryOperation,
class NT2>
248 std::ofstream output;
249 commGrid->OpenDebugFile(prefix, output);
250 std::copy(arr.begin(), arr.end(), std::ostream_iterator<NT> (output,
" "));
255 void PrintInfo(std::string vectorname)
const;
257 std::shared_ptr<CommGrid>
getcommgrid()
const {
return commGrid; }
262 template <
typename _BinaryOperation>
265 template <
typename OUT,
typename _BinaryOperation,
typename _UnaryOperation>
266 OUT
Reduce(_BinaryOperation __binary_op, OUT default_val, _UnaryOperation __unary_op)
const;
270 template <typename _BinaryOperation, typename OUT = typename std::result_of<_BinaryOperation&(NT,NT)>::type>
277 std::vector< NT > arr;
279 template <
typename _BinaryOperation>
282 template <
class IU,
class NU>
285 template <
class IU,
class NU,
class UDER>
288 template <
class IU,
class NU>
291 template <
class IU,
class NU>
294 template <
class IU,
class NU>
297 template <
typename SR,
typename IU,
typename NUM,
typename NUV,
typename UDER>
301 template <
typename IU,
typename NU1,
typename NU2>
305 template <
typename IU,
typename NU1,
typename NU2,
typename _BinaryOperation>
309 template <
typename RET,
typename IU,
typename NU1,
typename NU2,
typename _BinaryOperation,
typename _BinaryPredicate>
313 template <
typename RET,
typename IU,
typename NU1,
typename NU2,
typename _BinaryOperation,
typename _BinaryPredicate>
317 template <
typename IU>
320 template <
typename IU,
typename NU>
323 template <
typename IU,
typename NU>
326 template <
class IU,
class DER>
void EWiseOut(const FullyDistVec< IT, NT > &rhs, _BinaryOperation __binary_op, FullyDistVec< IT, OUT > &result)
friend FullyDistSpVec< IU, typename promote_trait< NU1, NU2 >::T_promote > EWiseMult(const FullyDistSpVec< IU, NU1 > &V, const FullyDistVec< IU, NU2 > &W, bool exclude, NU2 zero)
FullyDistVec< IT, NT > operator()(const FullyDistVec< IT, IT > &ri) const
void SetElement(IT indx, NT numx)
void EWiseApply(const FullyDistVec< IT, NT2 > &other, _BinaryOperation __binary_op)
NT read(std::basic_istream< c, t > &is, IT index)
friend FullyDistSpVec< IU, RET > EWiseApply_threaded(const FullyDistSpVec< IU, NU1 > &V, const FullyDistVec< IU, NU2 > &W, _BinaryOperation _binary_op, _BinaryPredicate _doOp, bool allowVNulls, NU1 Vzero, const bool useExtendedBinOp)
FullyDistVec< IT, NT > & operator=(const FullyDistVec< ITRHS, NTRHS > &rhs)
void EWiseApply(const FullyDistVec< IT, NT2 > &other, _BinaryOperation __binary_op, _BinaryPredicate _do_op)
void Set(const FullyDistSpVec< IT, NT > &rhs)
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
Return the indices where pred is true.
FullyDistSpVec< IT, NT > Find(_Predicate pred) const
Return the elements for which pred is true.
void SaveGathered(std::ofstream &outfile, int master, HANDLER handler, bool printProcSplits=false)
std::ifstream & ReadDistribute(std::ifstream &infile, int master)
std::shared_ptr< CommGrid > getcommgrid() const
friend void maximumMatching(SpParMat< int64_t, bool, SpDCCols< int64_t, bool > > &A, FullyDistVec< int64_t, int64_t > &mateRow2Col, FullyDistVec< int64_t, int64_t > &mateCol2Row)
void ParallelRead(const std::string &filename, bool onebased, _BinaryOperation BinOp)
void EWiseApply(const FullyDistVec< IT, NT2 > &other, _BinaryOperation __binary_op, _BinaryPredicate _do_op, const bool useExtendedBinOp)
void SetLocalElement(IT index, NT value)
FullyDistVec< IT, NT > & operator=(NT fixedval)
std::pair< IT, NT > MinElement() const
NT GetElement(IT indx) const
IT Count(_Predicate pred) const
Return the number of elements for which pred is true.
NT operator[](IT indx) const
void iota(IT globalsize, NT first)
void EWiseApply(const FullyDistSpVec< IT, NT2 > &other, _BinaryOperation __binary_op, _BinaryPredicate _do_op, bool applyNulls, NT2 nullValue)
friend void RenameVertices(DistEdgeList< IU > &DEL)
void SelectCandidates(double nver)
ABAB: Put concept check, NT should be integer for this to make sense.
void SaveGathered(std::ofstream &outfile, int master)
void GSet(const FullyDistSpVec< IT, NT1 > &spVec, _BinaryOperationIdx __binopIdx, _BinaryOperationVal __binopVal, MPI_Win win)
bool operator()(const T1 &x, const T2 &y)
void EWiseApply(const FullyDistSpVec< IT, NT2 > &other, _BinaryOperation __binary_op, bool applyNulls, NT2 nullValue)
friend FullyDistVec< IU, NU > Concatenate(std::vector< FullyDistVec< IU, NU > > &vecs)
void ParallelWrite(const std::string &filename, bool onebased, HANDLER handler, bool includeindices=true)
FullyDistVec< IT, IT > sort()
void PrintInfo(std::string vectorname) const
void Apply(_UnaryOperation __unary_op)
void ParallelWrite(const std::string &filename, bool onebased, HANDLER handler, bool includeindices=true, bool includeheader=false)
bool operator==(const FullyDistVec< IT, NT > &rhs) const
FullyDistSpVec< IT, NT > GGet(const FullyDistSpVec< IT, NT1 > &spVec, _BinaryOperationIdx __binopIdx, NT nullValue)
void ParallelWrite(const std::string &filename, bool onebased, bool includeindices=true)
friend FullyDistVec< IU, typename promote_trait< NUM, NUV >::T_promote > SpMV(const SpParMat< IU, NUM, UDER > &A, const FullyDistVec< IU, NUV > &x)
void ApplyInd(_BinaryOperation __binary_op)
void ParallelRead(const std::string &filename, bool onebased, _BinaryOperation BinOp)
FullyDistVec< IT, NT > & operator+=(const FullyDistSpVec< IT, NT > &rhs)
FullyDistVec< IT, NT > & operator-=(const FullyDistSpVec< IT, NT > &rhs)
friend void Augment(FullyDistVec< int64_t, int64_t > &mateRow2Col, FullyDistVec< int64_t, int64_t > &mateCol2Row, FullyDistVec< int64_t, int64_t > &parentsRow, FullyDistVec< int64_t, int64_t > &leaves)
NT Reduce(_BinaryOperation __binary_op, NT identity) const
friend SpParMat< IU, bool, DER > PermMat(const FullyDistVec< IU, IU > &ri, const IU ncol)
const NT * GetLocArr() const
std::ifstream & ReadDistribute(std::ifstream &infile, int master, HANDLER handler)
void PrintToFile(std::string prefix)
void save(std::basic_ostream< c, t > &os, const NT &v, IT index)