diff --git a/btas/generic/cp.h b/btas/generic/cp.h index 8fd42077..f680a08b 100644 --- a/btas/generic/cp.h +++ b/btas/generic/cp.h @@ -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 + 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