30#ifndef _FULLY_DIST_SP_VEC_H_
31#define _FULLY_DIST_SP_VEC_H_
46template <
class IT,
class NT,
class DER>
52template <
class IU,
class NU>
55template <
class IU,
class NU>
56class SparseVectorLocalIterator;
72template <
class IT,
class NT>
81 template <
typename _UnaryOperation>
90 template <
typename _BinaryOperationIdx,
typename _BinaryOperationVal,
typename _BinaryOperationDuplicate>
92 template <
typename _BinaryOperationIdx,
typename _BinaryOperationVal>
96 template <
typename NT1,
typename _UnaryOperation>
98 template <
typename _UnaryOperation>
100 template <
typename NT1>
106 template <
typename NT1,
typename _UnaryOperation,
typename _BinaryOperation>
119#pragma omp parallel for
121 for(
size_t i=0; i < ind.size(); ++i)
133 template <
typename c,
typename t>
141 template <
typename c,
typename t>
142 void save(std::basic_ostream<c,t>&
os,
const NT& v,
IT index)
148 template <
class HANDLER>
153 template <
typename _BinaryOperation>
158 template <
class HANDLER>
162 template <
class HANDLER>
170 CVT.ind = std::vector<IT>(ind.begin(), ind.end());
171 CVT.num = std::vector<NNT>(num.begin(), num.end());
195#if __cplusplus > 199711L
196 template <
typename _BinaryOperation = minimum<NT> >
199 template <
typename _BinaryOperation >
204 template <
typename _UnaryOperation>
213 temp.ind.push_back(ind[i]);
214 temp.num.push_back(num[i]);
255 #pragma omp parallel for
261 template <
typename _Predicate>
264 template <
typename _UnaryOperation>
270#pragma omp parallel for
276 template <
typename _BinaryOperation>
282 #pragma omp parallel for
290 template <
typename _BinaryOperation>
293 template <
typename OUT,
typename _BinaryOperation,
typename _UnaryOperation>
297 std::shared_ptr<CommGrid>
getcommgrid()
const {
return commGrid; }
305 template <
typename _Predicate>
307 template <
typename _Predicate>
316 std::vector< IT > ind;
317 std::vector< NT > num;
321 template <
typename _BinaryOperation>
325#if __cplusplus > 199711L
326 template <
typename _BinaryOperation = minimum<NT> >
329 template <
typename _BinaryOperation >
334 template <
class IU,
class NU>
337 template <
class IU,
class NU>
340 template <
class IU,
class NU,
class UDER>
343 template <
class IU,
class NU>
346 template <
typename SR,
typename IU,
typename NUM,
typename NUV,
typename UDER>
350 template <
typename SR,
typename IU,
typename NUM,
typename UDER>
354 template <
typename VT,
typename IU,
typename UDER>
357 template <
typename SR,
typename IVT,
typename OVT,
typename IU,
typename NUM,
typename UDER>
360 template <
typename SR,
typename IVT,
typename OVT,
typename IU,
typename NUM,
typename UDER>
361 friend void SpMV (
const SpParMat<IU,NUM,UDER> &
A,
const FullyDistSpVec<IU,IVT> &
x,
FullyDistSpVec<IU,OVT> &
y,
bool indexisvalue,
OptBuf<int32_t, OVT > &
optbuf,
PreAllocatedSPA<OVT> &
SPA);
363 template <
typename IU,
typename NU1,
typename NU2>
367 template <
typename RET,
typename IU,
typename NU1,
typename NU2,
typename _BinaryOperation,
typename _BinaryPredicate>
371 template <
typename RET,
typename IU,
typename NU1,
typename NU2,
typename _BinaryOperation,
typename _BinaryPredicate>
376 template <
typename RET,
typename IU,
typename NU1,
typename NU2,
typename _BinaryOperation,
typename _BinaryPredicate>
378 EWiseApply (
const FullyDistSpVec<IU,NU1> &
V,
const FullyDistSpVec<IU,NU2> &
W ,
_BinaryOperation _binary_op,
_BinaryPredicate _doOp,
bool allowVNulls,
bool allowWNulls,
NU1 Vzero,
NU2 Wzero,
const bool allowIntersect,
const bool useExtendedBinOp);
380 template <
typename IU>
383 template <
typename IU>
391 template <
typename IU,
typename VT>
394 template<
typename IU,
typename NV>
397 template <
class IU,
class NU,
class DER,
typename _UnaryOperation>
NT read(std::basic_istream< c, t > &is, IT index)
void save(std::basic_ostream< c, t > &os, const NT &v, 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)
friend FullyDistSpVec< IU, VT > SpMV(const SpParMat< IU, bool, UDER > &A, const FullyDistSpVec< IU, VT > &x, OptBuf< int32_t, VT > &optbuf)
FullyDistSpVec< IT, NT > & operator=(const FullyDistSpVec< IT, NT > &rhs)
void Select(const FullyDistVec< IT, NT1 > &denseVec, _UnaryOperation unop)
FullyDistSpVec< IT, IT > sort()
sort the vector itself, return the permutation vector (0-based)
std::ifstream & ReadDistribute(std::ifstream &infile, int master, HANDLER handler)
Totally obsolete version that only accepts an ifstream object and ascii files.
FullyDistSpVec< IT, NT > & operator-=(const FullyDistSpVec< IT, NT > &rhs)
NT Reduce(_BinaryOperation __binary_op, NT init) const
FullyDistSpVec< IT, NT > Uniq(_BinaryOperation __binary_op, MPI_Op mympiop)
FullyDistSpVec< IT, NT > Prune(_UnaryOperation __unary_op, bool inPlace=true)
friend FullyDistSpVec< IU, typename promote_trait< NUM, NUV >::T_promote > SpMV(const SpParMat< IU, NUM, UDER > &A, const FullyDistSpVec< IU, NUV > &x)
std::vector< NT > GetLocalNum()
void Apply(_UnaryOperation __unary_op)
FullyDistVec< IT, NT > FindVals(_Predicate pred) const
friend void RandPerm(FullyDistSpVec< IU, IU > &V)
void nziota(NT first)
iota over existing nonzero entries
void ParallelWrite(const std::string &filename, bool onebased, HANDLER handler, bool includeindices=true, bool includeheader=false)
void FilterByVal(FullyDistSpVec< IT, IT > Selector, _UnaryOperation __unop, bool filterByIndex)
FullyDistSpVec< IT, NT > Invert(IT globallen)
std::shared_ptr< CommGrid > getcommgrid() const
void SelectApply(const FullyDistVec< IT, NT1 > &denseVec, _UnaryOperation __unop, _BinaryOperation __binop)
void ParallelWrite(const std::string &filename, bool onebased, bool includeindices=true)
IT Count(_Predicate pred) const
Return the number of elements for which pred is true.
FullyDistVec< IT, NT > operator()(const FullyDistVec< IT, IT > &ri) const
SpRef (expects ri to be 0-based)
void SaveGathered(std::ofstream &outfile, int master)
FullyDistSpVec< IT, NT > & operator=(NT fixedval)
void ParallelRead(const std::string &filename, bool onebased, _BinaryOperation BinOp)
friend class FullyDistSpVec
bool operator==(const FullyDistSpVec< IT, NT > &rhs) const
std::ifstream & ReadDistribute(std::ifstream &infile, int master)
friend void RenameVertices(DistEdgeList< IU > &DEL)
FullyDistVec< IT, IT > FindInds(_Predicate pred) const
void SaveGathered(std::ofstream &outfile, int master, HANDLER handler, bool printProcSplits=false)
friend FullyDistSpVec< IU, RET > EWiseApply(const FullyDistSpVec< IU, NU1 > &V, const FullyDistVec< IU, NU2 > &W, _BinaryOperation _binary_op, _BinaryPredicate _doOp, bool allowVNulls, NU1 Vzero, const bool useExtendedBinOp)
IT NnzUntil() const
Returns the number of nonzeros until this processor.
void BulkSet(IT inds[], int count)
friend void TransposeVector(MPI_Comm &World, const FullyDistSpVec< IU, NV > &x, int32_t &trxlocnz, IU &lenuntil, int32_t *&trxinds, NV *&trxnums, bool indexisvalue)
NT GetLocalElement(IT indx)
void ApplyInd(_BinaryOperation __binary_op)
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)
FullyDistSpVec< IT, NT > & operator+=(const FullyDistSpVec< IT, NT > &rhs)
std::vector< IT > GetLocalInd()
void PrintInfo(std::string vecname) const
void Setminus(const FullyDistSpVec< IT, NT1 > &other)
friend SpParMat< IU, bool, DER > PermMat1(const FullyDistSpVec< IU, NU > &ri, const IU ncol, _UnaryOperation __unop)
void iota(IT globalsize, NT first)
void SetElement(IT indx, NT numx)
Indexing is performed 0-based.
friend void MergeContributions(FullyDistSpVec< IU, VT > &y, int *&recvcnt, int *&rdispls, int32_t *&recvindbuf, VT *&recvnumbuf, int rowneighs)
Helper functions for sparse matrix X sparse vector.
void stealFrom(FullyDistSpVec< IT, NT > &victim)
FullyDistSpVec< IT, NT > InvertRMA(IT globallen, _BinaryOperationIdx __binopIdx, _BinaryOperationVal __binopVal)