Skip to content

Commit

Permalink
update converge_class
Browse files Browse the repository at this point in the history
  • Loading branch information
kmp5VT committed Aug 17, 2024
1 parent 6e2a3c6 commit 163d8b6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions btas/generic/converge_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace btas {
}

double normFactors = norm(btas_factors, V);
double normResidual = sqrt(abs(normT_ * normT_ + normFactors * normFactors - 2 * abs(iprod)));
double normResidual = sqrt(abs(normT_ * normT_ + normFactors - 2 * abs(iprod)));
double fit = 1. - (normResidual / normT_);

double fitChange = abs(fitOld_ - fit);
Expand Down Expand Up @@ -232,7 +232,7 @@ namespace btas {
for (auto &i : coeffMat) {
nrm += i;
}
return sqrt(abs(nrm));
return nrm;
}
};

Expand Down Expand Up @@ -515,7 +515,8 @@ namespace btas {

auto fit = 0.0;
if(iter_ == 0) {
fit_prev_ = norm(btas_factors, btas_factors, rank_);
fit_prev_ = sqrt(norm(btas_factors, btas_factors, rank_));
norm_prev_ = fit_prev_;
prev_factors = btas_factors;
// diff = reconstruct(btas_factors, orders);
if (verbose_) {
Expand All @@ -526,10 +527,11 @@ namespace btas {
}

auto curr_norm = norm(btas_factors, btas_factors, rank_);
fit = sqrt(fit_prev_ - 2 * norm(prev_factors, btas_factors, rank_) + curr_norm);
fit = sqrt(fit_prev_ - 2 * norm(prev_factors, btas_factors, rank_) + curr_norm) / norm_prev_;
// fit = norm(diff);
// diff = tnew;
fit_prev_ = curr_norm;
norm_prev_ = curr_norm;
prev_factors = btas_factors;

if (verbose_) {
Expand All @@ -552,7 +554,7 @@ namespace btas {
private:
double tol_;
bool verbose_ = false;
double fit_prev_;
double fit_prev_, norm_prev_;
std::vector<size_t> orders;
std::vector<Tensor> prev_factors;
// Tensor diff;
Expand Down

0 comments on commit 163d8b6

Please sign in to comment.