Skip to content

Commit

Permalink
Create a function which makes a random matrix for CPD initial guess
Browse files Browse the repository at this point in the history
  • Loading branch information
kmp5VT committed Dec 18, 2024
1 parent 6433b71 commit 4cd2832
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions btas/generic/cp.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,17 @@ namespace btas {
virtual void build_random(ind_t rank, ConvClass &converge_test, bool direct, ind_t max_als, bool calculate_epsilon,
double &epsilon, bool &fast_pI) = 0;

/// 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;
}
/// Generates V by first Multiply A^T.A then Hadamard product V(i,j) *=
/// A^T.A(i,j);
/// \param[in] n The mode being optimized, all other modes held constant
Expand Down

0 comments on commit 4cd2832

Please sign in to comment.