16template <
size_t m,
size_t d,
class T>
19 std::array<Index, d> shape{input.
shape()};
20 std::array<
Index, d - 1> cols_shape, vec_index_cols;
21 remove_element(std::begin(shape), std::end(shape), std::begin(cols_shape), m);
22 std::vector<Index> vec_index(d, 0);
25 assert(shape[m] == output.
shape()[1] &&
prod(cols_shape) == output.
shape()[0]);
27 for (
auto const& el : input) {
30 std::begin(vec_index_cols), m);
32 std::end(vec_index_cols),
33 std::begin(cols_shape));
50template <
size_t m,
size_t d,
class T>
53 std::array<Index, d> shape{output.
shape()};
54 std::array<
Index, d - 1> cols_shape, vec_index_cols;
55 remove_element(std::begin(shape), std::end(shape), std::begin(cols_shape), m);
56 std::vector<Index> vec_index(d, 0);
59 assert(shape[m] == input.
shape()[1] &&
prod(cols_shape) == input.
shape()[0]);
61 for (
auto& el : output) {
64 std::begin(vec_index_cols), m);
66 std::end(vec_index_cols),
67 std::begin(cols_shape));
86 const Index n_basisfunctions,
const T weight,
92 assert(n_basisfunctions <= cols);
94 std::default_random_engine generator(1234);
95 std::normal_distribution<double> distribution(0.0, 1.0);
97 for (
Index k = n_basisfunctions; k < cols; ++k) {
98 for (
Index i = 0; i < rows; ++i) {
99 input(i, k) = distribution(generator);
106 gs(input, R, weight);
108 for (
Index j = n_basisfunctions; j < cols; ++j) {
109 for (
Index i = 0; i < cols; ++i) {
Provides two-factor (i.e. matrix) low-rank types and their operations.
Index vec_index_to_comb_index(InputIt first, InputIt last, InputItInt first_int)
void incr_vec_index(InputIt first, OutputIt d_first, OutputIt d_last)
void tensorize(const multi_array< T, 2 > &input, multi_array< T, d > &output)
void matricize(const multi_array< T, d > &input, multi_array< T, 2 > &output)
void tensorize< 2, 3, double >(const multi_array< double, 2 > &input, multi_array< double, 3 > &output)
void matricize< 2, 3, double >(const multi_array< double, 3 > &input, multi_array< double, 2 > &output)
void tensorize< 1, 3, double >(const multi_array< double, 2 > &input, multi_array< double, 3 > &output)
void matricize< 1, 3, double >(const multi_array< double, 3 > &input, multi_array< double, 2 > &output)
void matricize< 0, 3, double >(const multi_array< double, 3 > &input, multi_array< double, 2 > &output)
void tensorize< 0, 3, double >(const multi_array< double, 2 > &input, multi_array< double, 3 > &output)
Core namespace for Ensign's numerical algorithms and data structures.
void remove_element(InputIt first, InputIt last, OutputIt d_first, const Index idx)
Provides matrix and vector operations with optional GPU execution.
Dense d-dimensional array stored contiguously in column-major order (i.e.
array< Index, d > shape() const
Orthogonalizes Q and returns the corresponding upper triangular matrix R.