62 void New (
int ldim,
int nbuf = 0);
66 void Allocate (
int nbuf);
74 void Initialise (
int nz,
int *idx);
88 int from = 0,
int to = -1);
92 int LDim()
const {
return base->lsize; }
95 int PDim()
const {
return base->psize; }
100 void Put (
int i, VT val);
102 void Add (
int i, VT val);
107 inline int PIndex (
int i)
const;
116 void SparseOutput (ostream &os)
const;
120 VT &operator[] (
int i)
const;
122 int LIndex (
int i)
const;
125 void SetIndex (
int pi,
int li);
130 VT &operator[] (
int i)
const {
return data[i]; }
132 int LIndex (
int i)
const {
return index[i]; }
134 void SetIndex (
int pi,
int li) { index[pi] = li; }
142 friend ostream &operator<< (ostream &os, const TSparseVector<VT> &vec);
173 base->bufsize = base->psize = base->lsize = 0;
183 base->bufsize = base->psize = 0;
201 if (--base->nref == 0) {
204 delete []base->index;
213 for (
int j = 0; j < base->psize; j++)
214 if (index[j] == i)
return j;
223 int i, ps = base->psize;
225 for (i = 0; i < ps; i++)
226 sum += data[i] * vec[index[i]];
229 #endif // !MATH_DEBUG
234 #ifdef NEED_FRIEND_PT
238 int from = 0,
int to = -1);
242 int from = 0,
int to = -1);
246 int from = 0,
int to = -1);
252 ostream &operator<< (ostream &os, const TSparseVector<VT> &vec);
265 #endif // !__SPVECTOR_H
Templated vector class.
Definition: vector.h:39
Definition: spvector.h:37
Definition: spvector.h:25
Definition: spmatrix.h:26