16#ifndef TRUSTTab_included
17#define TRUSTTab_included
19#include <MD_Vector_base.h>
29template<
typename _TYPE_,
typename _SIZE_>
48 assert(verifie_LINE_SIZE());
50 Process::exit(
"Error in TRUSTTab::printOn: try to print a parallel vector");
52 assert(dimensions_[0] == dimension_tot_0_);
60 if (sz > 0) os.
put(
data, sz, l_size);
73 Process::exit(
"Error in TRUSTTab::readOn: vector has a parallel structure");
78 Cerr <<
"Error in TRUSTTab::readOn: wrong this->nb_dim_ = " << this->nb_dim_ << finl;
81 is.
get(dimensions_, this->nb_dim_);
82 if (dimensions_[0] < 0)
84 Cerr <<
"Error in TRUSTTab::readOn: wrong dimension(0) = " << dimensions_[0] << finl;
88 for (
int i = 1; i < this->nb_dim_; i++)
90 if (dimensions_[i] < 0)
92 Cerr <<
"Error in TRUSTTab::readOn: wrong dimension(" << i <<
") = " << dimensions_[i] << finl;
95 l_size *= (int)dimensions_[i];
97 dimension_tot_0_ = dimensions_[0];
105 assert(verifie_LINE_SIZE());
112 template<
typename _TYPE2_,
typename _SIZE2_>
friend class TRUSTTab;
117 init_dimensions(dimensions_);
124 for (
int i = 0; i < MAXDIM_TAB; i++) dimensions_[i] = dbt.dimensions_[i];
130 init_dimensions(dimensions_);
137 assert(n1 >= 0 && n2 >= 0);
138 if (std::is_same<_TYPE_,int>::value && (
long)n1*(
long)n2 > (
long)std::numeric_limits<int>::max())
140 Cerr <<
"n1*n2 > 2^31. Error! Contact TRUST support, integer 32 bits limit exceeded with n1=" << n1 <<
" and n2=" << n2 << finl;
143 init_dimensions(dimensions_);
153 assert(n1 >= 0 && n2 >= 0 && n3 >= 0);
154 if (std::is_same<_TYPE_,int>::value && (
long)n1*(
long)n2*(
long)n3 > (
long)std::numeric_limits<int>::max())
156 Cerr <<
"n1*n2*n3 > 2^31. Error! Contact TRUST support, integer 32 bits limit exceeded with n1=" << n1 <<
" and n2=" << n2 <<
" and n3=" << n3 << finl;
159 init_dimensions(dimensions_);
166 TRUSTTab(_SIZE_ n1,
int n2,
int n3,
int n4) :
TRUSTVect<_TYPE_,_SIZE_>(n1*n2*n3*n4), dimension_tot_0_(n1)
169 assert(n1 >= 0 && n2 >= 0 && n3 >= 0 && n4 >= 0);
170 if (std::is_same<_TYPE_,int>::value && (
long)n1*(
long)n2*(
long)n3*(
long)n4 > (
long)std::numeric_limits<int>::max())
172 Cerr <<
"n1*n2*n3*n4 > 2^31. Error! Contact TRUST support, integer 32 bits limit exceeded with n1=" << n1 <<
" and n2=" << n2 <<
" and n3=" << n3 <<
" and n3=" << n3 << finl;
175 init_dimensions(dimensions_);
183 inline void resize_dim0(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT);
184 inline void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT);
185 inline void resize(_SIZE_ n1,
int n2, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT);
186 inline void resize(_SIZE_ n1,
int n2,
int n3, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT);
187 inline void resize(_SIZE_ n1,
int n2,
int n3,
int n4, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT);
189 inline void copy(
const TRUSTTab&, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT);
218 inline const _TYPE_&
operator()(_SIZE_ i1,
int i2,
int i3)
const ;
219 inline _TYPE_&
operator()(_SIZE_ i1,
int i2,
int i3,
int i4);
220 inline const _TYPE_&
operator()(_SIZE_ i1,
int i2,
int i3,
int i4)
const ;
241 inline void lit(
Entree&,
bool resize_and_read=
true)
override;
247 inline void resize_tab(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
override;
250 inline void reshape(_SIZE_ n1,
int n2,
int n3);
251 inline void reshape(_SIZE_ n1,
int n2,
int n3,
int n4);
259 template <
int _SHAPE_ = 2,
typename EXEC_SPACE = Kokkos::DefaultExecutionSpace>
260 inline std::enable_if_t<is_default_exec_space<EXEC_SPACE>, ConstView<_TYPE_, _SHAPE_>>
266 template <
int _SHAPE_ = 2,
typename EXEC_SPACE = Kokkos::DefaultExecutionSpace>
267 inline std::enable_if_t<gpu_enabled_is_host_exec_space<EXEC_SPACE>, ConstHostView<_TYPE_, _SHAPE_>>
274 template <
int _SHAPE_ = 2,
typename EXEC_SPACE = Kokkos::DefaultExecutionSpace>
275 inline std::enable_if_t<is_default_exec_space<EXEC_SPACE>, View<_TYPE_, _SHAPE_>>
281 template <
int _SHAPE_ = 2,
typename EXEC_SPACE = Kokkos::DefaultExecutionSpace>
282 inline std::enable_if_t<gpu_enabled_is_host_exec_space<EXEC_SPACE>, HostView<_TYPE_, _SHAPE_>>
289 template <
int _SHAPE_ = 2,
typename EXEC_SPACE = Kokkos::DefaultExecutionSpace>
290 inline std::enable_if_t<is_default_exec_space<EXEC_SPACE>, View<_TYPE_, _SHAPE_>>
296 template <
int _SHAPE_ = 2,
typename EXEC_SPACE = Kokkos::DefaultExecutionSpace>
297 inline std::enable_if_t<gpu_enabled_is_host_exec_space<EXEC_SPACE>, HostView<_TYPE_, _SHAPE_>>
305 static constexpr int MAXDIM_TAB = 4;
309 _SIZE_ dimensions_[MAXDIM_TAB];
313 _SIZE_ dimension_tot_0_;
315 inline void verifie_MAXDIM_TAB()
const
319 Cerr <<
"Update code for MAXDIM_TAB for CHECK_LINE_SIZE" << finl;
324 inline bool verifie_LINE_SIZE()
const
330 inline void init_dimensions(_SIZE_ * tab)
333 for (
int i = 0; i < MAXDIM_TAB; i++) tab[i] = -1;
343template <
typename _TYPE_>
346using BigDoubleTab = BigTRUSTTab<double>;
347using BigIntTab = BigTRUSTTab<int>;
348using BigTIDTab = BigTRUSTTab<trustIdType>;
354#include <TRUSTTab_tools.tpp>
360#include <TRUSTTab.tpp>
Class defining operators and methods for all reading operation in an input flow (file,...
virtual int get(int *ob, std::streamsize n)
: Cette classe est un OWN_PTR mais l'objet pointe est partage entre plusieurs
int numero() const
Renvoie l'indice de l'objet dans Memoire::data.
static int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Classe de base des flux de sortie.
virtual int put(const unsigned *ob, std::streamsize n, std::streamsize nb_colonnes=1)
Represents a an array of int/int64/double/... values.
_SIZE_ size_array() const
: Tableau a n entrees pour n<= 4.
_TYPE_ & operator()(_SIZE_ i1, int i2)
void reshape(_SIZE_ n1, int n2, int n3)
void jump(Entree &) override
void ref_as_big(TRUSTTab< _TYPE_, trustIdType > &out) const
virtual void ref(const TRUSTTab &)
TRUSTTab & operator=(const TRUSTVect< _TYPE_, _SIZE_ > &)
TRUSTTab & operator=(_TYPE_ d)
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_wo()
void set_md_vector(const MD_Vector &) override
void resoud_LU(_SIZE_, TRUSTArray< int, _SIZE_ > &, const TRUSTArray< _T_, _SIZE_ > &, TRUSTArray< _T_, _SIZE_ > &)
void append_line(_TYPE_, _TYPE_, _TYPE_)
int dimension_int(int d) const
const _TYPE_ & operator()(_SIZE_ i1, int i2, int i3, int i4) const
int inverse_LU(const TRUSTArray< int, _SIZE_ > &, TRUSTArray< int, _SIZE_ > &)=delete
void append_line(_TYPE_, _TYPE_, _TYPE_, _TYPE_)
const _TYPE_ & operator()(_SIZE_ i1, int i2, int i3) const
void ref_array(TRUSTArray< _TYPE_, _SIZE_ > &, _SIZE_ start=0, _SIZE_ sz=-1) override
void ref_data(_TYPE_ *ptr, _SIZE_ size) override
void promote_scalar_to_dim2()
_TYPE_ operator()(const TRUSTArray< _SIZE_, int > &indice) const
void lit(Entree &, bool resize_and_read=true) override
void reshape(_SIZE_ n1, int n2, int n3, int n4)
void ref_as_small(TRUSTTab< _TYPE_, int > &out) const
void resize(_SIZE_ n1, int n2, int n3, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
const _TYPE_ & operator()(_SIZE_ i) const
void reshape(_SIZE_ n1, int n2)
_TYPE_ & operator[](_SIZE_ i)
int max_du_u(const TRUSTTab< int, _SIZE_ > &)=delete
_TYPE_ & operator()(const TRUSTArray< _SIZE_, int > &indice)
void append_line(_TYPE_, _TYPE_)
_TYPE_ & operator()(_SIZE_ i)
int duplique() const override
std::enable_if_t< gpu_enabled_is_host_exec_space< EXEC_SPACE >, ConstHostView< _TYPE_, _SHAPE_ > > view_ro() const
Sortie & printOn(Sortie &os) const override
ecriture d'un tableau sequentiel (idem que TRUSTVect::printOn() on ne sait pas quoi faire de pertinen...
virtual void ref_tab(TRUSTTab &, _SIZE_ start_line=0, _SIZE_ nb_lines=-1)
Entree & readOn(Entree &is) override
lecture d'un tableau sequentiel
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void ecrit(Sortie &) const override
TRUSTTab(const TRUSTTab &dbt)
void ref(const TRUSTVect< _TYPE_, _SIZE_ > &) override
bool decomp_LU(_SIZE_, TRUSTArray< int, _SIZE_ > &, TRUSTTab< _T_, _SIZE_ > &)
void ajoute_produit_tensoriel(_T_ alpha, const TRUSTTab< _T_, _SIZE_ > &, const TRUSTTab< _T_, _SIZE_ > &)
void ajoute_produit_tensoriel(int alpha, const TRUSTTab< int, _SIZE_ > &, const TRUSTTab< int, _SIZE_ > &)=delete
std::enable_if_t< gpu_enabled_is_host_exec_space< EXEC_SPACE >, HostView< _TYPE_, _SHAPE_ > > view_rw()
TRUSTTab(_SIZE_ n1, int n2, int n3)
TRUSTTab(_SIZE_ n1, int n2)
_TYPE_ & operator()(_SIZE_ i1, int i2, int i3, int i4)
std::enable_if_t< gpu_enabled_is_host_exec_space< EXEC_SPACE >, HostView< _TYPE_, _SHAPE_ > > view_wo()
_SIZE_ dimension_tot(int) const override
const _TYPE_ & operator()(_SIZE_ i1, int i2) const
TRUSTTab(_SIZE_ n1, int n2, int n3, int n4)
_TYPE_ & operator()(_SIZE_ i1, int i2, int i3)
void resize_dim0(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void resize(_SIZE_ n1, int n2, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_T_ max_du_u(const TRUSTTab< _T_, _SIZE_ > &)
bool inverse_LU(const TRUSTArray< _T_, _SIZE_ > &, TRUSTArray< _T_, _SIZE_ > &)
void copy(const TRUSTTab &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void resize(_SIZE_ n1, int n2, int n3, int n4, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void from_tid_to_int(TRUSTTab< int, int > &out) const
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
void resize(const TRUSTArray< _SIZE_, int > &tailles, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, View< _TYPE_, _SHAPE_ > > view_rw()
void resize_tab(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) override
const _TYPE_ & operator[](_SIZE_ i) const
int decomp_LU(int, TRUSTArray< int, _SIZE_ > &, TRUSTTab< int, _SIZE_ > &)=delete
_SIZE_ dimension(int d) const
unsigned taille_memoire() const override
void resoud_LU(int, TRUSTArray< int, _SIZE_ > &, const TRUSTArray< int, _SIZE_ > &, TRUSTArray< int, _SIZE_ > &)=delete
TRUSTTab & operator=(const TRUSTTab &)
Entree & readOn(Entree &is) override
Lecture d'un vecteur sequentiel (comme un ArrOfDouble) Attention: appel invalide si le vecteur a un M...
void set_line_size_(int n)
virtual const MD_Vector & get_md_vector() const