36 template <
class IT,
class NT,
class DER>
39 if( (!ci.empty()) && (ci.back() > getncol()))
41 std::cerr <<
"Col indices out of bounds" << std::endl;
44 if( (!ri.empty()) && (ri.back() > getnrow()))
46 std::cerr <<
"Row indices out of bounds" << std::endl;
50 return ((static_cast<DER>(*
this)) (ri, ci));
53 template <
class IT,
class NT,
class DER>
56 return ((static_cast<DER &>(*
this)) == (static_cast<DER &>(rhs)) );
59 template <
class IT,
class NT,
class DER>
62 static_cast< DER*
>(
this)->Split(static_cast< DER & >(partA),
static_cast< DER &
>(partB));
65 template <
class IT,
class NT,
class DER>
68 static_cast< DER*
>(
this)->Merge(static_cast< DER & >(partA),
static_cast< DER &
>(partB));
72 template <
class IT,
class NT,
class DER>
73 template <
typename SR>
77 IT A_m, A_n, B_m, B_n;
100 if(getnrow() == A_m && getncol() == B_n)
106 static_cast< DER*
>(
this)->
template PlusEq_AtXBt< SR >(static_cast< DER & >(A),
static_cast< DER &
>(
B));
108 else if(isAT && (!isBT))
110 static_cast< DER*
>(
this)->
template PlusEq_AtXBn< SR >(static_cast< DER & >(A),
static_cast< DER &
>(
B));
112 else if((!isAT) && isBT)
114 static_cast< DER*
>(
this)->
template PlusEq_AnXBt< SR >(static_cast< DER & >(A),
static_cast< DER &
>(
B));
118 static_cast< DER*
>(
this)->
template PlusEq_AnXBn< SR >(static_cast< DER & >(A),
static_cast< DER &
>(
B));
123 std::cerr <<
"Not multipliable: " << A_n <<
"!=" << B_m << std::endl;
128 std::cerr<<
"Not addable: "<< getnrow() <<
"!=" << A_m <<
" or " << getncol() <<
"!=" << B_n << std::endl;
133 template<
typename SR,
typename NUO,
typename IU,
typename NU1,
typename NU2,
typename DER1,
typename DER2>
137 bool isAT,
bool isBT,
138 bool clearA =
false,
bool clearB =
false)
164 return Tuples_AtXBt<SR, NUO>(
static_cast< const DER1 &
>(
A), static_cast< const DER2 & >(B), clearA, clearB);
166 else if(isAT && (!isBT))
168 return Tuples_AtXBn<SR, NUO>(
static_cast< const DER1 &
>(
A), static_cast< const DER2 & >(B), clearA, clearB);
170 else if((!isAT) && isBT)
172 return Tuples_AnXBt<SR, NUO>(
static_cast< const DER1 &
>(
A), static_cast< const DER2 & >(B), clearA, clearB);
176 return Tuples_AnXBn<SR, NUO>(
static_cast< const DER1 &
>(
A), static_cast< const DER2 & >(B), clearA, clearB);
181 std::cerr <<
"Not multipliable: " << A_n <<
"!=" << B_m << std::endl;
186 template <
class IT,
class NT,
class DER>
189 return static_cast<const DER*
>(
this)->put(outfile);
192 template <
class IT,
class NT,
class DER>
195 std::cout <<
"Getting... SpMat" << std::endl;
196 return static_cast<DER*
>(
this)->
get(infile);
200 template <
typename UIT,
typename UNT,
typename UDER >
201 std::ofstream& operator<<(std::ofstream& outfile, const SpMat< UIT,UNT,UDER > & s)
203 return s.put(outfile);
206 template <
typename UIT,
typename UNT,
typename UDER >
209 return s.
get(infile);
SpTuples< IU, NUO > * MultiplyReturnTuples(const SpMat< IU, NU1, DER1 > &A, const SpMat< IU, NU2, DER2 > &B, bool isAT, bool isBT, bool clearA=false, bool clearB=false)
std::ifstream & get(std::ifstream &infile)
bool operator==(const SpMat< IT, NT, DER > &rhs) const
void SpGEMM(SpMat< IT, NT, DER > &A, SpMat< IT, NT, DER > &B, bool isAT, bool isBT)
std::ofstream & put(std::ofstream &outfile) const
void Split(SpMat< IT, NT, DER > &partA, SpMat< IT, NT, DER > &partB)
void Merge(SpMat< IT, NT, DER > &partA, SpMat< IT, NT, DER > &partB)
std::ifstream & operator>>(std::ifstream &infile, SpMat< UIT, UNT, UDER > &s)
SpMat< IT, NT, DER > operator()(const std::vector< IT > &ri, const std::vector< IT > &ci) const