diff --git a/tensor.cc b/tensor.cc index 81099e7..e4d938b 100644 --- a/tensor.cc +++ b/tensor.cc @@ -1091,6 +1091,9 @@ return r; } +//NOTE: Tucker of rank=2 is inherently inefficient - result is a diagonal tensor stored in full and 2 calls to SVD +//we could avoid the second SVD, but the wasteful storage and erconstruction would remain +// template NRVec > Tensor::Tucker(typename LA_traits::normtype thr, bool inverseorder) { @@ -1101,11 +1104,13 @@ copyonwrite(); if(r==1) //create an analogous output for the trivial case { + typename LA_traits::normtype N=data.norm(); + data*= (1/N); ret[0]=NRMat(data,data.size(),1); shape[0].range=1; data.resize(calcsize()); calcrank(); - data[0]=1; + data[0]=(T)N; return ret; } @@ -1123,7 +1128,11 @@ for(int i=0; i u(um.nrows(),mini),vt(mini,um.ncols()); NRVec::normtype> w(mini); + std::cout << "decomposing "<