Skip to content

Commit

Permalink
Make random factor function
Browse files Browse the repository at this point in the history
  • Loading branch information
kmp5VT committed Jul 17, 2024
1 parent c74660b commit 6e2a3c6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions btas/generic/cp.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,18 @@ namespace btas {
return left_side_product;
}

/// Create a rank \c rank initial guess using
/// random numbers from a uniform distribution

template<typename Generator, typename Distribution>
Tensor make_random_factor(ind_t row, ind_t col, Generator gen, Distribution dist){
Tensor a(row, col);
for (auto iter = a.begin(); iter != a.end(); ++iter) {
*(iter) = dist(gen);
}
return a;
}

/// \param[in] factor Which factor matrix to normalize, returns
/// the \c factor factor matrix with all columns normalized.
/// \return The column norms of the \c factor factor matrix
Expand Down

0 comments on commit 6e2a3c6

Please sign in to comment.