136 if (tt==
TT_2D)
return "TT_2D";
137 if (tt==
TT_FULL)
return "TT_FULL";
138 return "unknown tensor type";
140 template <
typename Archive>
158 template <
typename T>
159 class GenTensor :
public Tensor<T> {
175 Tensor<Q> result = Tensor<Q>(this->
_ndim,this->
_dim,
false);
218 typedef typename std::list<GenTensor<T> >::iterator iterT;
220 for (iterT it=++addends.begin(); it!=addends.end(); ++it) {
231 return madness::outer(
static_cast<Tensor<T>
>(left),
static_cast<Tensor<T>
>(right));
245 template <
class Archive,
typename T>
248 if (t.iscontiguous()) {
249 s & t.size() & t.id();
260 template <
class Archive,
typename T>
263 long sz = 0l,
id =0l;
265 if (
id != t.id())
throw "type mismatch deserializing a tensor";
269 t = Tensor<T>(_ndim, _dim,
false);
270 if (sz != t.size())
throw "size mismatch deserializing a tensor";
271 s &
wrap(t.ptr(), t.size());
300 friend class SliceGenTensor<
T>;
302 typedef SRConf<T> configT;
304 typedef GenTensor<T> gentensorT;
311 static double machinePrecision() {
return 1.e-14;}
314 static double facReduce() {
return 1.e-3;}
324 GenTensor(
const GenTensor<T>& rhs) : _ptr() {
325 if (rhs.has_data()) _ptr=rhs._ptr;
332 const long ndim=dim.size();
333 const long maxk=dim[0];
334 for (
long idim=0; idim<
ndim; idim++) {
335 MADNESS_ASSERT(maxk==dim[0]);
338 _ptr=sr_ptr(
new configT(dim.size(),dim[0],tt));
343 GenTensor(
const std::vector<long>& dim,
const TensorArgs& targs) : _ptr() {
346 const long ndim=dim.size();
347 const long maxk=dim[0];
348 for (
long idim=0; idim<
ndim; idim++) {
349 MADNESS_ASSERT(maxk==dim[0]);
352 _ptr=sr_ptr(
new configT(dim.size(),dim[0],targs.tt));
358 _ptr=sr_ptr(
new configT(dim,k,tt));
362 GenTensor(
const Tensor<T>& rhs,
const TensorArgs& targs) {
365 if (not rhs.has_data()) {
370 MADNESS_ASSERT(rhs.ndim()>0);
371 for (
long idim=0; idim<rhs.ndim(); idim++) {
372 MADNESS_ASSERT(rhs.dim(0)==rhs.dim(idim));
375 _ptr=sr_ptr(
new configT(rhs.ndim(),rhs.dim(0),targs.tt));
383 Tensor< typename Tensor<T>::scalar_type > s;
387 if (rhs.dim(0)%2==0) {
388 std::vector<long>
dims(rhs.ndim()*2);
389 for (
int i=0; i<rhs.ndim(); ++i) {
394 TensorTrain<T> tt(rhs,targs.thresh*facReduce(),
dims);
396 for (
int i=0; i<rhs.ndim(); ++i) tt.fusedim(i);
398 tt.two_mode_representation(U,VT,s);
401 TensorTrain<T> tt(rhs,targs.thresh*facReduce());
402 tt.two_mode_representation(U,VT,s);
405 const long r=VT.dim(0);
406 const long nd=VT.ndim();
408 _ptr=sr_ptr(
new configT(
dim(),get_k(),ttype));
410 MADNESS_ASSERT(U.dim(nd-1)==r);
411 Tensor<T> UU=U.reshape(U.size()/r,r);
412 _ptr=sr_ptr(
new configT(s,
copy(
transpose(UU)), VT.reshape(r,VT.size()/r),
418 MADNESS_ASSERT(rhs.iscontiguous());
419 std::vector<long> d(_ptr->dim_eff(),_ptr->kVec());
420 Tensor<T> values_eff=rhs.reshape(d);
422 this->computeSVD(targs.thresh,values_eff);
425 _ptr.reset(
new configT(
copy(rhs)));
433 *
this=gentensorT(rhs,TensorArgs(thresh,tt));
437 GenTensor(
const SliceGenTensor<T>& rhs) : _ptr() {
447 gentensorT& operator=(
const gentensorT& rhs) {
448 if (
this != &rhs) _ptr=rhs._ptr;
453 GenTensor& operator=(
const SliceGenTensor<T>& rhs) {
454 *
this=rhs._refGT.copy_slice(rhs._s);
459 friend gentensorT
copy(
const gentensorT& rhs) {
460 if (rhs._ptr)
return gentensorT(
copy(*rhs._ptr));
466 template <
class Q>
operator GenTensor<Q>()
const {
479 SliceGenTensor<T> operator()(
const std::vector<Slice>& s) {
480 return SliceGenTensor<T>(*
this,s);
484 const SliceGenTensor<T> operator()(
const std::vector<Slice>& s)
const {
485 return SliceGenTensor<T>(*
this,s);
496 print(
"in wrong constructor");
501 explicit GenTensor(
const SRConf<T>&
config) : _ptr(new configT(config)) {
506 gentensorT copy_slice(
const std::vector<Slice>& s)
const {
510 int k_new=s[0].end-s[0].start+1;
515 MADNESS_ASSERT(s.size()==this->
dim());
516 MADNESS_ASSERT(s[0].step==1);
521 return gentensorT(configT(a));
524 MADNESS_ASSERT(_ptr->has_structure());
529 const int merged_dim=this->_ptr->dim_per_vector();
530 const int dim_eff=this->_ptr->dim_eff();
532 int k_new=s[0].end-s[0].start+1;
533 if (s[0].end<0) k_new+=this->get_k();
537 const gentensorT& sr=*
this;
539 std::vector<Tensor<T> > vectors(dim_eff,Tensor<T>());
541 for (
int idim=0; idim<dim_eff; idim++) {
546 vectors[idim]=
copy(sr._ptr->ref_vector(idim)(Slice(0,rank-1),s[idim]));
548 vectors[idim]=Tensor<T>(0,s[idim].end-s[idim].start+1);
550 }
else if (merged_dim==2) {
552 vectors[idim]=
copy(sr._ptr->ref_vector(idim)(Slice(0,rank-1),s[2*idim],s[2*idim+1]));
554 vectors[idim]=
tensorT(0,s[2*idim].end-s[2*idim].start+1,
555 s[2*idim+1].end-s[2*idim+1].start+1);
557 }
else if (merged_dim==3) {
559 vectors[idim]=
copy(sr._ptr->ref_vector(idim)(Slice(0,rank-1),
560 s[3*idim],s[3*idim+1],s[3*idim+2]));
562 vectors[idim]=
tensorT(0,s[3*idim].end-s[3*idim].start+1,
563 s[3*idim+1].end-s[3*idim+1].start+1,
564 s[3*idim+2].end-s[3*idim+2].start+1);
567 }
else MADNESS_EXCEPTION(
"unknown number of dimensions in GenTensor::copy_slice()",0);
571 Tensor<double> weights;
573 weights=
copy(this->_ptr->weights_(Slice(0,rank-1)));
575 weights=Tensor<double>(int(0));
577 const configT conf(weights,vectors,this->
dim(),k_new,tt);
579 return gentensorT(conf);
588 return _ptr->ref_vector(0);
594 return _ptr->ref_vector(0);
598 gentensorT& operator+=(
const gentensorT& rhs) {
600 if (rhs.has_no_data())
return *
this;
605 this->
gaxpy(1.0,rhs,1.0);
610 gentensorT& operator-=(
const gentensorT& rhs) {
612 if (rhs.has_no_data())
return *
this;
617 this->
gaxpy(1.0,rhs,-1.0);
622 gentensorT& operator+=(
const SliceGenTensor<T>& rhs) {
623 const std::vector<Slice> s(this->
ndim(),Slice(0,get_k()-1,1));
624 this->_ptr->inplace_add(*rhs._refGT._ptr,s,rhs._s,1.0,1.0);
629 gentensorT& operator-=(
const SliceGenTensor<T>& rhs) {
630 const std::vector<Slice> s(this->
ndim(),Slice(0,get_k()-1,1));
631 this->_ptr->inplace_add(*rhs._refGT._ptr,s,rhs._s,1.0,-1.0);
637 GenTensor<TENSOR_RESULT_TYPE(T,Q)>
operator*(
const Q& x)
const {
638 GenTensor<TENSOR_RESULT_TYPE(T,Q)> result(
copy(*
this));
644 gentensorT&
gaxpy(
const T alpha,
const gentensorT& rhs,
const T beta) {
645 MADNESS_ASSERT(this->
tensor_type()==rhs.tensor_type());
651 if (not (alpha==1.0)) this->
scale(alpha);
652 rhs.append(*
this,beta);
658 GenTensor<TENSOR_RESULT_TYPE(T,Q)>&
scale(
const Q& dfac) {
659 if (!_ptr)
return *
this;
673 void fillrandom(
const int r=1) {
675 else _ptr->fillWithRandom(r);
680 if (_ptr)
return true;
689 if (_ptr)
return _ptr->rank();
694 unsigned int dim()
const {
return _ptr->dim();};
697 long dim(
const int& i)
const {
return _ptr->get_k();};
701 if (_ptr)
return _ptr->dim();
706 unsigned int get_k()
const {
return _ptr->get_k();};
710 if (_ptr)
return _ptr->type();
718 size_t size()
const {
719 if (_ptr)
return _ptr->nCoeff();
725 if (_ptr)
return _ptr->real_size()+
sizeof(*this);
730 double normf()
const {
743 T trace(
const GenTensor<T>& rhs)
const {
744 return this->trace_conj(rhs);
750 if (TensorTypeData<T>::iscomplex)
MADNESS_EXCEPTION(
"no complex trace in GenTensor, sorry",1);
751 if (TensorTypeData<Q>::iscomplex)
MADNESS_EXCEPTION(
"no complex trace in GenTensor, sorry",1);
755 if ((this->rank()==0) or (rhs.rank()==0)) return resultT(0.0);
757 MADNESS_ASSERT(compatible(*this,rhs));
760 return overlap(*(this->_ptr),*rhs._ptr);
766 if (TensorTypeData<T>::iscomplex)
MADNESS_EXCEPTION(
"no complex trace in GenTensor, sorry",1);
767 if (TensorTypeData<Q>::iscomplex)
MADNESS_EXCEPTION(
"no complex trace in GenTensor, sorry",1);
771 if ((this->rank()==0)) return resultT(0.0);
783 print(
"no GenTensor<T>::emul yet");
790 if (tt==
TT_NONE)
return Tensor<T>();
803 if (
rank()==0)
return;
809 config().divide_and_conquer_reduce(eps*facReduce());
813 MADNESS_ASSERT(this->_ptr->has_structure() or this->
rank()==0);
818 print(
"printing SepRep",title);
819 print(_ptr->weights_);
820 for (
unsigned int idim=0; idim<this->_ptr->dim_eff(); idim++) {
821 print(
"coefficients for dimension",idim);
822 print(_ptr->vector_[idim]);
838 const unsigned int conf_dim=this->_ptr->dim_eff();
839 const unsigned int conf_k=this->_ptr->kVec();
840 const long rank=this->
rank();
846 const long k=this->get_k();
847 const long dim=this->
dim();
848 for (
long i=0; i<
dim; i++) d[i] = k;
850 return Tensor<T> (
dim,d,
true);
855 for (
long i=0; i<conf_dim; i++) d[i] = conf_k;
856 tensorT s(conf_dim,d,
true);
863 Tensor<T> scr1(rank);
864 Tensor<T> scr2(rank);
868 for (
unsigned int i0=0; i0<conf_k; i0++) {
869 scr=sr._ptr->weights_;
875 }
else if (conf_dim==2) {
885 tensorT sscr=
copy(sr._ptr->flat_vector(0));
886 for (
unsigned int r=0; r<
rank; r++) {
887 const double w=_ptr->weights(r);
888 for (
unsigned int k=0; k<conf_k; k++) {
895 }
else if (conf_dim==3) {
898 for (
unsigned int i0=0; i0<conf_k; i0++) {
899 scr=
copy(sr._ptr->weights_(Slice(0,sr.rank()-1)));
900 scr.emul(sr._ptr->ref_vector(0)(Slice(0,rank-1),i0));
901 for (
unsigned int i1=0; i1<conf_k; i1++) {
903 scr1.emul(sr._ptr->ref_vector(1)(Slice(0,rank-1),i1));
904 for (
unsigned int i2=0; i2<conf_k; i2++) {
906 scr2.emul(sr._ptr->ref_vector(2)(Slice(0,rank-1),i2));
907 s(i0,i1,i2)=scr2.sum();
912 print(
"only config_dim=1,2,3 in GenTensor::reconstructTensor");
918 const long k=this->get_k();
919 const long dim=this->
dim();
920 for (
long i=0; i<
dim; i++) d[i] = k;
922 Tensor<T> s2=s.reshape(dim,d);
927 void append(gentensorT& rhs,
const T fac=1.0)
const {
928 rhs.config().append(*this->_ptr,fac);
932 void add_SVD(
const gentensorT& rhs,
const double& thresh) {
933 if (rhs.has_no_data())
return;
942 config().add_SVD(rhs.config(),thresh*facReduce());
946 friend bool compatible(
const gentensorT& rhs,
const gentensorT& lhs) {
947 return ((rhs.tensor_type()==lhs.tensor_type()) and (rhs.get_k()==lhs.get_k())
948 and (rhs.dim()==lhs.dim()));
952 gentensorT
transform(
const Tensor<T>
c)
const {
955 MADNESS_ASSERT(_ptr->has_structure());
956 return gentensorT (this->_ptr->transform(c));
964 MADNESS_ASSERT(_ptr->has_structure());
969 gentensorT
transform_dir(
const Tensor<T>& c,
const int& axis)
const {
971 MADNESS_ASSERT(_ptr->has_structure());
972 return GenTensor<T>(this->_ptr->transform_dir(c,axis));
976 const SRConf<T>&
config()
const {
return *_ptr;}
979 SRConf<T>&
config() {
return *_ptr;}
982 static double fac_reduce() {
return facReduce();};
987 void clear() {_ptr.reset();};
990 void inplace_add(
const gentensorT& rhs,
const std::vector<Slice>& lhs_s,
991 const std::vector<Slice>& rhs_s,
const double alpha,
const double beta) {
994 if (rhs.has_no_data() or rhs.rank()==0)
return;
1011 MADNESS_ASSERT(_ptr->has_structure());
1012 MADNESS_ASSERT(rhs._ptr->has_structure());
1013 this->_ptr->inplace_add(*rhs._ptr,lhs_s,rhs_s, alpha, beta);
1018 void computeSVD(
const double& eps,
const Tensor<T>& values_eff) {
1021 MADNESS_ASSERT(values_eff.ndim()==2);
1025 if (values_eff.normf()<eps*facReduce()) {
1026 _ptr=sr_ptr(
new configT(_ptr->dim(),_ptr->get_k(),
tensor_type()));
1033 Tensor< typename Tensor<T>::scalar_type > s;
1035 svd(values_eff,U,s,VT);
1039 const double thresh=eps*facReduce();
1046 copy(VT(Slice(0,i),_)),
dim(), get_k()));
1047 MADNESS_ASSERT(this->_ptr->get_k()==this->_ptr->vector_[0].dim(1));
1048 MADNESS_ASSERT(this->_ptr->rank()==this->_ptr->vector_[0].dim(0));
1049 MADNESS_ASSERT(this->_ptr->rank()==this->_ptr->weights_.dim(0));
1060 template <
typename T>
1061 class SliceGenTensor {
1066 GenTensor<T>& _refGT;
1067 std::vector<Slice> _s;
1072 SliceGenTensor<T> () {}
1075 SliceGenTensor<T> (
const GenTensor<T>& gt,
const std::vector<Slice>& s)
1076 : _refGT(
const_cast<GenTensor<T>&
>(gt))
1082 SliceGenTensor<T>& operator=(
const GenTensor<T>& rhs) {
1083 print(
"You don't want to assign to a SliceGenTensor; use operator+= instead");
1089 SliceGenTensor<T>& operator=(
const SliceGenTensor<T>& rhs) {
1090 print(
"You don't want to assign to a SliceGenTensor; use operator+= instead");
1096 SliceGenTensor<T>& operator+=(
const GenTensor<T>& rhs) {
1097 std::vector<Slice> s(this->_refGT.ndim(),Slice(_));
1098 _refGT.inplace_add(rhs,this->_s,s,1.0,1.0);
1103 SliceGenTensor<T>& operator-=(
const GenTensor<T>& rhs) {
1104 std::vector<Slice> s(this->_refGT.ndim(),Slice(_));
1105 _refGT.inplace_add(rhs,this->_s,s,1.0,-1.0);
1110 SliceGenTensor<T>& operator+=(
const SliceGenTensor<T>& rhs) {
1111 _refGT.inplace_add(GenTensor<T>(*rhs._refGT._ptr),this->_s,rhs._s,1.0,1.0);
1116 SliceGenTensor<T>& operator=(
const T& number) {
1117 MADNESS_ASSERT(number==
T(0.0));
1118 if (this->_refGT.tensor_type()==
TT_FULL) {
1119 _refGT.full_tensor()(_s)=0.0;
1121 const GenTensor<T>& tmp=(this->_refGT);
1122 _refGT.inplace_add(tmp,_s,_s,1.0,-1.0);
1128 friend GenTensor<T>
copy(
const SliceGenTensor<T>& rhs) {
1129 if (rhs._refGT.has_data())
return GenTensor<T>(rhs);
1130 return GenTensor<T>();
1141 template <
class T,
class Q>
1142 GenTensor< TENSOR_RESULT_TYPE(T,Q) >
transform(
const GenTensor<Q>& t,
const Tensor<T>& c) {
1143 return t.transform(c);
1147 struct RankReduceWrapper {
1149 RankReduceWrapper(
const double& e) : eps(e) {}
1151 template<
typename T>
1152 void operator()(GenTensor<T>&
g)
const {
1158 template<
typename T>
1159 bool compare_rank(
const GenTensor<T>& g1,
const GenTensor<T>& g2) {
1160 return g1.rank()<g2.rank();
1172 template<
typename T>
1173 GenTensor<T>
reduce(std::list<GenTensor<T> >& addends,
double eps,
bool are_optimal=
false) {
1176 if (addends.size()==0)
return GenTensor<T>();
1178 typedef typename std::list<GenTensor<T> >::iterator iterT;
1181 eps=eps/addends.size();
1184 if (not are_optimal) {
1185 RankReduceWrapper
f(eps);
1186 std::for_each(addends.begin(),addends.end(),
f);
1190 addends.remove_if(has_zero_rank<T>);
1191 if (addends.size()==0)
return GenTensor<T>();
1192 addends.sort(compare_rank<T>);
1195 GenTensor<T> result=
copy(addends.front());
1196 for (iterT it=++addends.begin(); it!=addends.end(); ++it) {
1197 GenTensor<T>& rhs=*it;
1198 MADNESS_ASSERT(&rhs!=&result);
1199 result.add_SVD(rhs,eps);
1216 template <
class T,
class Q>
1217 GenTensor<TENSOR_RESULT_TYPE(T,Q)>
transform_dir(
const GenTensor<Q>& t,
const Tensor<T>& c,
1220 return t.transform_dir(c,axis);
1223 template<
typename T>
1225 std::ostream& operator<<(std::ostream& s, const GenTensor<T>&
g) {
1227 if (
g.has_no_data()) {
1231 str=
"GenTensor has data";
1232 s << str.c_str() <<
g.config();
1239 template <
class Archive,
typename T>
1240 struct ArchiveStoreImpl< Archive,
GenTensor<T> > {
1244 static void store(
const Archive& ar,
const GenTensor<T>& t) {
1245 bool exist=t.has_data();
1247 if (exist) ar & t.config();
1253 template <
class Archive,
typename T>
1254 struct ArchiveLoadImpl< Archive,
GenTensor<T> > {
1258 static void load(
const Archive& ar, GenTensor<T>& t) {
1266 t=GenTensor<T>(conf);
1273 template <
class T,
class Q>
1274 GenTensor<TENSOR_RESULT_TYPE(T,Q)>
outer(
const GenTensor<T>& lhs2,
const GenTensor<Q>& rhs2) {
1279 template <
class T,
class Q>
1280 GenTensor<TENSOR_RESULT_TYPE(T,Q)>
outer_low_rank(
const Tensor<T>& lhs2,
const Tensor<Q>& rhs2) {
1285 const Tensor<T> lhs=
copy(lhs2);
1286 const Tensor<Q> rhs=
copy(rhs2);
1288 const
long k=lhs.dim(0);
1289 const
long dim=lhs.ndim()+rhs.ndim();
1291 for (
int i=0; i<lhs.ndim(); ++i) size*=k;
1292 MADNESS_ASSERT(size==lhs.size());
1293 MADNESS_ASSERT(size==rhs.size());
1294 MADNESS_ASSERT(lhs.size()==rhs.size());
1296 Tensor<
double> weights(1);
1299 SRConf<resultT> srconf(weights,lhs.reshape(1,lhs.size()),rhs.reshape(1,rhs.size()),dim,k);
1308 template<
typename T>
1312 const TensorType current_type=t.tensor_type();
1313 if (current_type==targs.
tt)
return;
1314 if (t.has_no_data())
return;
1318 MADNESS_ASSERT(current_type==
TT_FULL or current_type==
TT_2D);
1324 MADNESS_ASSERT(current_type==
TT_FULL);
1341 template <
class T,
class Q>
1343 return t.general_transform(c);
1348 return t.general_transform(c);
1352 template <
typename T,
typename Q>
1353 typename IsSupported < TensorTypeData<Q>, GenTensor<T> >::type
SRConf< T > config() const
Definition: gentensor.h:201
Definition: shared_ptr_bits.h:38
SRConf< T > get_configs(const int &start, const int &end) const
Definition: gentensor.h:202
NDIM const Function< R, NDIM > & g
Definition: mra.h:2179
GenTensor< T > full_tensor_copy() const
Definition: gentensor.h:184
void gaxpy(World &world, Q alpha, std::vector< Function< T, NDIM > > &a, Q beta, const std::vector< Function< R, NDIM > > &b, bool fence=true)
Generalized A*X+Y for vectors of functions -— a[i] = alpha*a[i] + beta*b[i].
Definition: vmra.h:680
TensorType
low rank representations of tensors (see gentensor.h)
Definition: tensor.h:275
long ndim() const
Returns the number of dimensions in the tensor.
Definition: basetensor.h:144
void inner_result(const Tensor< T > &left, const Tensor< Q > &right, long k0, long k1, Tensor< TENSOR_RESULT_TYPE(T, Q) > &result)
Accumulate inner product into user provided, contiguous, correctly sized result tensor.
Definition: tensor.h:2204
IsSupported< TensorTypeData< Q >, GenTensor< T > >::type operator*(const Q &x, const GenTensor< T > &t)
The class defines tensor op scalar ... here define scalar op tensor.
Definition: gentensor.h:1354
static void load(const Archive &s, GenTensor< T > &t)
Definition: gentensor.h:262
bool has_no_data() const
Definition: gentensor.h:188
archive_array< T > wrap(const T *, unsigned int)
Factory function to wrap dynamically allocated pointer as typed archive_array.
Definition: archive.h:820
GenTensor< T > outer(const GenTensor< T > &left, const GenTensor< T > &right)
Outer product ... result(i,j,...,p,q,...) = left(i,k,...)*right(p,q,...)
Definition: gentensor.h:230
double svd_normf() const
Definition: gentensor.h:190
TensorArgs()
Definition: gentensor.h:130
::std::string string
Definition: gtest-port.h:872
void load(World &world, real_function_6d &f, std::string filename)
Definition: helium_exact.cc:367
std::string what_am_i() const
Definition: gentensor.h:196
#define BINARY_OPTIMIZED_ITERATOR(X, x, Y, y, exp)
Definition: tensor_macros.h:701
NDIM & f
Definition: mra.h:2179
long dim(int i) const
Returns the size of dmension i.
Definition: basetensor.h:147
bool has_data() const
Definition: gentensor.h:187
void serialize(const Archive &ar)
Definition: gentensor.h:141
void add_SVD(const GenTensor< T > &rhs, const double &eps)
Definition: gentensor.h:199
const long * dims() const
Returns the array of tensor dimensions.
Definition: basetensor.h:153
Default store of a thingy via serialize(ar,t)
Definition: archive.h:708
const double beta
Definition: gygi_soltion.cc:63
Defines and implements most of Tensor.
#define TENSOR_RESULT_TYPE(L, R)
This macro simplifies access to TensorResultType.
Definition: type_data.h:209
static int max_sigma(const double &thresh, const int &rank, const Tensor< double > &w)
Definition: srconf.h:125
GenTensor< T > general_transform(const Tensor< Q > c[]) const
Definition: gentensor.h:205
static double fac_reduce()
return the additional safety for rank reduction
Definition: gentensor.h:212
double thresh
Definition: gentensor.h:128
GenTensor< T > reduce(std::list< GenTensor< T > > &addends, double eps, bool are_optimal=false)
Definition: gentensor.h:217
GenTensor< T > full_tensor_copy()
Definition: gentensor.h:185
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
void scale(World &world, std::vector< Function< T, NDIM > > &v, const std::vector< Q > &factors, bool fence=true)
Scales inplace a vector of functions by distinct values.
Definition: vmra.h:290
void change_tensor_type(GenTensor< T > &t, const TensorArgs &targs)
change representation to targ.tt
Definition: gentensor.h:1309
static void store(const Archive &s, const GenTensor< T > &t)
Definition: gentensor.h:247
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence. ...
Definition: mra.h:1835
long _ndim
Number of dimensions (-1=invalid; 0=scalar; >0=tensor)
Definition: basetensor.h:94
Tensor< TENSOR_RESULT_TYPE(T, Q)> transform_dir(const Tensor< T > &t, const Tensor< Q > &c, int axis)
Transforms one dimension of the tensor t by the matrix c, returns new contiguous tensor.
Definition: tensor.h:1929
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
#define TENSOR_MAXDIM
Definition: tensor_macros.h:194
TensorArgs(const double &thresh1, const TensorType &tt1)
Definition: gentensor.h:131
void reduce_rank(const double &eps)
Definition: gentensor.h:193
Default load of a thingy via serialize(ar,t)
Definition: archive.h:718
Tensor< double > tensorT
Definition: chem/distpm.cc:13
TensorArgs holds the arguments for creating a LowRankTensor.
Definition: gentensor.h:127
void svd(const Tensor< T > &a, Tensor< T > &U, Tensor< typename Tensor< T >::scalar_type > &s, Tensor< T > &VT)
Compute the singluar value decomposition of an n-by-m matrix using *gesvd.
Definition: lapack.cc:273
TensorType tensor_type() const
Definition: gentensor.h:197
GenTensor()
Definition: gentensor.h:163
GenTensor< T > full_tensor() const
Definition: gentensor.h:182
GenTensor< T > outer_low_rank(const Tensor< T > &left, const Tensor< T > &right)
Outer product ... result(i,j,...,p,q,...) = left(i,k,...)*right(p,q,...)
Definition: gentensor.h:238
GenTensor< TENSOR_RESULT_TYPE(T, Q)> general_transform(const GenTensor< T > &t, const Tensor< Q > c[])
Transform all dimensions of the tensor t by distinct matrices c.
Definition: gentensor.h:1342
long size() const
Returns the number of elements in the tensor.
Definition: basetensor.h:138
Definition: gentensor.h:122
void normalize()
Definition: gentensor.h:194
bool has_zero_rank(const GenTensor< T > &g)
true if GenTensor has zero rank or no data
Definition: gentensor.h:151
GenTensor< T > & full_tensor()
Definition: gentensor.h:183
long _dim[TENSOR_MAXDIM]
Size of each dimension.
Definition: basetensor.h:96
size_t real_size() const
Definition: gentensor.h:191
Tensor< T > transpose(const Tensor< T > &t)
Returns a new deep copy of the transpose of the input tensor.
Definition: tensor.h:1945
void print(const A &a)
Print a single item to std::cout terminating with new line.
Definition: print.h:122
TensorType tt
Definition: gentensor.h:129
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
double tt1
Definition: lapack.cc:66
Definition: gentensor.h:123
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
const double c
Definition: gfit.cc:200
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const DistributedMatrix< R > &c, bool fence=true)
Definition: chem/SCF.cc:86
handles the low-level details of a separated representation tensor
static std::string what_am_i(const TensorType &tt)
Definition: gentensor.h:135
Defines and implements the tensor train decomposition as described in I.V. Oseledets, Siam J. Sci. Comput. 33, 2295 (2011).
GenTensor< T > reconstruct_tensor() const
Definition: gentensor.h:181
long rank() const
Definition: gentensor.h:189