18#ifndef _SYMM_BAND_MATRIX
19#define _SYMM_BAND_MATRIX
21#include "tbci/vector.h"
22#include "tbci/matrix_sig.h"
27#if !defined(NO_GD) && !defined(AUTO_DECL)
28# include "tbci/symm_bdmatrix_gd.h"
39#ifndef TBCI_DISABLE_EXCEPT
47 :
NumErr(
"Error in var conf Symm_BdMatrix class") {}
75 void construct (
const unsigned int N,
const T&,
T*&,
78 inline void create (
const T& val,
const unsigned int N);
79 inline void create (
const T& val,
const unsigned int N,
91 inline void resize (
const T&,
const unsigned int);
92 inline void resize (
const unsigned int newDim) {
resize (0, newDim); }
98 const char*
mat_info ()
const {
return (
"Symm_BdMatrix"); }
101 const T&
operator() (
const unsigned int i,
const unsigned int k)
const;
102 const T&
get (
const unsigned int i,
const unsigned int k)
const
103 {
return (*
this) (
i, k); }
105 T&
setval (
const unsigned int i,
const unsigned int k);
106 void setval (
const T& wert,
const unsigned int i,
const unsigned int k)
108 void autoinsert (
const T& wert,
const unsigned int i,
const unsigned int k)
143 create (val, N, Diagconf);
162 STD__ cerr <<
"void Symm_BdMatrix<T>::Symm_BdMatrix(const T&, const unsigned int)" <<
STD__ endl
163 <<
"Invalid constructor parameters: Matrix can not have dimension == 0" <<
STD__ endl;
189 STD__ cerr <<
"void Symm_BdMatrix<T>::Symm_BdMatrix(const T&, const unsigned int, const BVector<unsigned int>&)" <<
STD__ endl
190 <<
"Invalid constructor parameters: Matrix can not have dimension == 0" <<
STD__ endl;
191 if(configVector.
size()>=dim)
192 STD__ cerr <<
"void Symm_BdMatrix<T>::Symm_BdMatrix(const T&, const unsigned int, const BVector<unsigned int>&)" <<
STD__ endl
193 <<
"Invalid constructor parameters: Number of off-diagonals larger than matrix dimension" <<
STD__ endl;
194 for(
unsigned i=0;
i<configVector.
size();
i++)
195 if(configVector(
i)>=dim)
196 STD__ cerr <<
"void Symm_BdMatrix<T>::Symm_BdMatrix(const T&, const unsigned int, const BVector<unsigned int>&)" <<
STD__ endl
197 <<
"Invalid constructor parameters: Off-diagonal is out of range" <<
STD__ endl;
216 unsigned int i, j, length = dim;
217 for (
i=0;
i<ConfVector.
size();
i++)
218 length += dim - ConfVector.
get(
i);
221 elemPtr =
new T [length];
222 for (
i=0;
i<length;
i++)
226 if (ConfVector.
size()) {
227 unsigned int next = 0;
228 for (
i=0;
i<dim;
i++) {
229 rPtr.
set(
i) = &(elemPtr[next]);
230 next += ConfVector.
size()+1;
233 for (j = ConfVector.
size(); j >= 1; j--)
234 if(ConfVector.
get(j-1) +
i >=dim) next--;
239 for (
i=0;
i<dim;
i++) rPtr.
set(
i) = &(elemPtr[
i]);
244 for (
i=0;
i<dim;
i++)
247 for (
i=0;
i<ConfVector.
size();
i++)
248 rowOccup.
set(ConfVector.
get(
i)) =
i+1;
258 for (
unsigned i = 0;
i < m.
rows();
i++)
259 for (
unsigned j = 0; j < m.
columns(); j++)
261 this->setval(
i, j) = m (
i,j);
286 STD__ cerr <<
"T& Symm_BdMatrix<T>::setval (const unsigned int, const unsigned int)" <<
STD__ endl
287 <<
"Invalid Index: Index out of range" <<
STD__ endl;
317 for(g=j=0; j<
conf.size(); j++,g++) {
319 if(
conf.get(j) > (m-l)) {newConfVector.
set(g++)= m-l; found=j;
break;}
320 newConfVector.
set(g) =
conf.get(j);
323 for(; j<
conf.size(); j++,g++) {
324 newConfVector.
set(g) =
conf.get(j);
327 if(found == -1) {newConfVector.
set(
conf.size()) = m-l; found=
conf.size();}
343 while(newPtr != newrowPtr.
get(
h)) {
344 *(newPtr++) = *(oldPtr++);
345 if( ((
int)j == found)&& (
int(found+1) <
int(newrowPtr.
get(
h) - newrowPtr.
get(
h-1))) )
350 *(newPtr) = *(oldPtr);
358 conf.resize(newConfVector.
size()) = newConfVector;
386 if(m==l)
return *
rowPtr.get(l);
405 for(k=0; k< matrix.
dimension; k++) out << matrix(
i,k) <<
" ";
420 STD__ cerr <<
"TVector<T> Symm_BdMatrix<T>::operator* (const Vector<T>&)const" <<
STD__ endl
421 <<
"Matrix and Vector have different dimensions" <<
STD__ endl;
427 if (
conf.size() == 0) {
483 unsigned int j, diagonal, confsize;
484 confsize=
conf.size();
487 unsigned max_off=
conf.get(confsize-1);
488 for(
i=0;
i<max_off;
i++)
493 for(j=0; ((diagonal=
conf.get(j))<=
i) && (j<confsize); j++)
496 for(j=0; j<confsize; j++)
504 for(j=0; j<confsize; j++)
518 for(j=0; j<confsize; j++)
const Vector< T > const Vector< T > const Vector< T > int T h
#define EXPCHK(cond, exc, txt, ind, rtval)
provides basic Vector functionality but arithmetic operators (+=, - , *, /...).
unsigned long size() const HOT
tbci_traits< T >::const_refval_type get(const unsigned long idx) const HOT
T & set(const unsigned long idx) HOT
Common interface definition (signature) for all Matrices.
unsigned int rows() const
unsigned int columns() const
Matrix class with optimized Matrix-Vector multiplication for symmetrical Matrices.
Symm_BdMatrix(const unsigned int N)
void construct(const unsigned int N, const T &, T *&, const BVector< unsigned int > &, BVector< T * > &, BVector< unsigned int > &)
TVector< T > operator*(const Vector< T > &) const
const T & get(const unsigned int i, const unsigned int k) const
unsigned int columns() const
const char * mat_info() const
const T & operator()(const unsigned int i, const unsigned int k) const
void setval(const T &wert, const unsigned int i, const unsigned int k)
void autoinsert(const T &wert, const unsigned int i, const unsigned int k)
void resize(const T &, const unsigned int)
unsigned int rows() const
BVector< unsigned int > conf
Symm_BdMatrix(const T &val, const unsigned int N)
Symm_BdMatrix(const T &val, const unsigned int N, const BVector< unsigned int > &diagConf)
BVector< unsigned int > rowOccupation
void resize(const unsigned int newDim)
T aligned_value_type TALIGN(MIN_ALIGN2)
void create(const T &val, const unsigned int N)
T & setval(const unsigned int i, const unsigned int k)
virtual ~SymmBdMatrixErr()
SymmBdMatrixErr(const SymmBdMatrixErr &be)
SymmBdMatrixErr(const char *t, const long i=0)
Temporary Base Class Idiom: Class TVector is used for temporary variables.
tbci_traits< T >::const_refval_type get(const unsigned long i) const
unsigned long size() const
T & setval(const unsigned long i) const
double fabs(const TBCI__ cplx< T > &c)
STD__ ostream & operator<<(STD__ ostream &out, const Symm_BdMatrix< T > &matrix)