21 #ifndef SELDON_FILE_MATRIX_SYMPACKED_INLINE_CXX
23 #include "Matrix_SymPacked.hxx"
38 template <
class T,
class Prop,
class Storage,
class Allocator>
51 template <
class T,
class Prop,
class Storage,
class Allocator>
67 template <
class T,
class Prop,
class Storage,
class Allocator>
70 return (
long(this->m_) *
long(this->m_ + 1)) / 2;
75 template <
class T,
class Prop,
class Storage,
class Allocator>
78 size_t taille =
sizeof(*this) + size_t(GetDataSize())*
sizeof(T);
95 template <
class T,
class Prop,
class Storage,
class Allocator>
96 inline typename Matrix_SymPacked<T, Prop, Storage, Allocator>::reference
100 #ifdef SELDON_CHECK_BOUNDS
101 CheckBounds(i, j, this->m_, this->n_,
"Matrix_SymPacked");
104 return this->data_[j > i
105 ? Storage::GetFirst(i *
long(this->n_)
106 - (i *
long(i + 1)) / 2 + j,
107 (j*
long(j+1)) / 2 + i)
108 : Storage::GetFirst(j *
long(this->m_)
109 - (j *
long(j + 1)) / 2 + i,
110 (i *
long(i + 1)) / 2 + j)];
121 template <
class T,
class Prop,
class Storage,
class Allocator>
128 #ifdef SELDON_CHECK_BOUNDS
129 CheckBounds(i, j, this->m_, this->n_,
"Matrix_SymPacked");
132 return this->data_[j > i
133 ? Storage::GetFirst(i *
long(this->n_)
134 - (i *
long(i + 1)) / 2 + j,
135 (j *
long(j + 1)) / 2 + i)
136 : Storage::GetFirst(j *
long(this->m_)
137 - (j *
long(j + 1)) / 2 + i,
138 (i *
long(i + 1)) / 2 + j)];
150 template <
class T,
class Prop,
class Storage,
class Allocator>
151 inline typename Matrix_SymPacked<T, Prop, Storage, Allocator>::reference
155 #ifdef SELDON_CHECK_BOUNDS
156 CheckBounds(i, j, this->m_, this->n_,
"Matrix_SymPacked");
159 return this->data_[j > i
160 ? Storage::GetFirst(i *
long(this->n_)
161 - (i *
long(i + 1)) / 2 + j,
162 (j *
long(j + 1)) / 2 + i)
163 : Storage::GetFirst(j *
long(this->m_)
164 - (j *
long(j + 1)) / 2 + i,
165 (i *
long(i + 1)) / 2 + j)];
177 template <
class T,
class Prop,
class Storage,
class Allocator>
183 #ifdef SELDON_CHECK_BOUNDS
184 CheckBounds(i, j, this->m_, this->n_,
"Matrix_SymPacked");
187 return this->data_[j > i
188 ? Storage::GetFirst(i *
long(this->n_)
189 - (i *
long(i + 1)) / 2 + j,
190 (j *
long(j + 1)) / 2 + i)
191 : Storage::GetFirst(j *
long(this->m_)
192 - (j *
long(j + 1)) / 2 + i,
193 (i *
long(i + 1)) / 2 + j)];
204 template <
class T,
class Prop,
class Storage,
class Allocator>
209 return this->Val(i, j);
220 template <
class T,
class Prop,
class Storage,
class Allocator>
224 return this->Val(i, j);
234 template <
class T,
class Prop,
class Storage,
class Allocator>
235 inline typename Matrix_SymPacked<T, Prop, Storage, Allocator>::reference
239 #ifdef SELDON_CHECK_BOUNDS
240 CheckBounds(i, this->GetDataSize(),
"Matrix_SymPacked");
243 return this->data_[i];
253 template <
class T,
class Prop,
class Storage,
class Allocator>
259 #ifdef SELDON_CHECK_BOUNDS
260 CheckBounds(i, this->GetDataSize(),
"Matrix_SymPacked");
263 return this->data_[i];
273 template <
class T,
class Prop,
class Storage,
class Allocator>
290 template <
class T,
class Prop,
class Storage,
class Allocator>
304 template <
class T,
class Prop,
class Storage,
class Allocator>
308 this->Reallocate(A.
GetM(), A.
GetN());
310 Allocator::memorycpy(this->data_, A.
GetData(), this->GetDataSize());
314 #ifdef SELDON_WITH_VIRTUAL
315 template <
class T,
class Prop,
class Storage,
class Allocator>
321 this->Val(i, j) += val;
326 template <
class T,
class Prop,
class Storage,
class Allocator>
327 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
328 ::AddInteractionRow(
int i,
int n,
const Vector<int>& col,
329 const Vector<T>& val,
bool sorted)
331 for (
int k = 0; k < n; k++)
333 this->Val(i, col(k)) += val(k);
338 template <
class T,
class Prop,
class Storage,
class Allocator>
339 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
340 ::AddInteractionColumn(
int i,
int n,
const Vector<int>& row,
341 const Vector<T>& val,
bool sorted)
343 for (
int k = 0; k < n; k++)
345 this->Val(row(k), i) += val(k);
350 template <
class T,
class Prop,
class Storage,
class Allocator>
351 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
354 for (
int k = 0; k < this->n_; k++)
355 SetComplexZero(this->Val(i, k));
359 template <
class T,
class Prop,
class Storage,
class Allocator>
360 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
361 ::ApplySor(
const SeldonTranspose& trans, Vector<Treal>& x,
const Vector<Treal>& r,
362 const typename ClassComplexType<T>::Treal& omega,
363 int nb_iter,
int stage_ssor)
const
365 SOR(trans,
static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this),
366 x, r, omega, nb_iter, stage_ssor);
369 template <
class T,
class Prop,
class Storage,
class Allocator>
370 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
371 ::ApplySor(
const SeldonTranspose& trans, Vector<Tcplx>& x,
const Vector<Tcplx>& r,
372 const typename ClassComplexType<T>::Treal& omega,
373 int nb_iter,
int stage_ssor)
const
376 static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this),
377 x, r, omega, nb_iter, stage_ssor);
380 template <
class T,
class Prop,
class Storage,
class Allocator>
381 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
382 ::MltAddVector(
const Treal& alpha,
const Vector<Treal>& x,
383 const Treal& beta, Vector<Treal>& y)
const
386 static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this),
390 template <
class T,
class Prop,
class Storage,
class Allocator>
391 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
392 ::MltAddVector(
const Tcplx& alpha,
const Vector<Tcplx>& x,
393 const Tcplx& beta, Vector<Tcplx>& y)
const
396 static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this),
400 template <
class T,
class Prop,
class Storage,
class Allocator>
401 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
402 ::MltAddVector(
const Treal& alpha,
const SeldonTranspose& trans,
403 const Vector<Treal>& x,
404 const Treal& beta, Vector<Treal>& y)
const
407 static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this),
411 template <
class T,
class Prop,
class Storage,
class Allocator>
412 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
413 ::MltAddVector(
const Tcplx& alpha,
const SeldonTranspose& trans,
414 const Vector<Tcplx>& x,
415 const Tcplx& beta, Vector<Tcplx>& y)
const
418 static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this),
422 template <
class T,
class Prop,
class Storage,
class Allocator>
423 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
424 ::MltVector(
const Vector<Treal>& x, Vector<Treal>& y)
const
426 Mlt(
static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this), x, y);
429 template <
class T,
class Prop,
class Storage,
class Allocator>
430 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
431 ::MltVector(
const Vector<Tcplx>& x, Vector<Tcplx>& y)
const
433 Mlt(
static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this), x, y);
436 template <
class T,
class Prop,
class Storage,
class Allocator>
437 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
438 ::MltVector(
const SeldonTranspose& trans,
439 const Vector<Treal>& x, Vector<Treal>& y)
const
442 static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this), x, y);
445 template <
class T,
class Prop,
class Storage,
class Allocator>
446 inline void Matrix_SymPacked<T, Prop, Storage, Allocator>
447 ::MltVector(
const SeldonTranspose& trans,
448 const Vector<Tcplx>& x, Vector<Tcplx>& y)
const
451 static_cast<const Matrix<T, Prop, Storage, Allocator>&
>(*
this), x, y);
454 template <
class T,
class Prop,
class Storage,
class Allocator>
455 inline bool Matrix_SymPacked<T, Prop, Storage, Allocator>
456 ::IsSymmetric()
const
476 template <
class T,
class Prop,
class Allocator>
489 template <
class T,
class Prop,
class Allocator>
505 template <
class T,
class Prop,
class Allocator>
521 template <
class T,
class Prop,
class Allocator>
536 template <
class T,
class Prop,
class Allocator>
541 long size = this->GetDataSize();
542 for (
long i = 0; i < size;i++)
563 template <
class T,
class Prop,
class Allocator>
576 template <
class T,
class Prop,
class Allocator>
592 template <
class T,
class Prop,
class Allocator>
608 template <
class T,
class Prop,
class Allocator>
623 template <
class T,
class Prop,
class Allocator>
628 long size = this->GetDataSize();
629 for (
long i = 0; i < size;i++)
638 #define SELDON_FILE_MATRIX_SYMPACKED_INLINE_CXX