diff --git a/docs/annotated.html b/docs/annotated.html index ee4bb80..6cc7229 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -3,7 +3,7 @@ - + irlba: Class List @@ -31,7 +31,7 @@ - + +
10#include <random>
11#include <stdexcept>
12
+
22namespace irlba {
23
+
31class Irlba {
32public:
+
36 struct Defaults {
40 static constexpr int number = 5;
41
@@ -103,6 +111,7 @@
51
55 static constexpr uint64_t seed = std::mt19937_64::default_seed;
56 };
+
57private:
59
@@ -114,43 +123,58 @@
65 ConvergenceTest convtest;
66
67public:
+
77 number = n;
78 return *this;
79 }
+
80
+
90 maxit = m;
91 return *this;
92 }
+
93
+
102 seed = s;
103 return *this;
104 }
+
105
+
115 extra_work = w;
116 return *this;
117 }
+
118
+
126 Irlba& set_invariant_tolerance(double e = LanczosBidiagonalization::Defaults::epsilon) {
127 lp.set_epsilon(e);
128 return *this;
129 }
+
130
+
138 Irlba& set_convergence_tolerance(double t = ConvergenceTest::Defaults::tol) {
139 convtest.set_tol(t);
140 return *this;
141 }
+
142
+
150 Irlba& set_singular_value_ratio_tolerance(double t = ConvergenceTest::Defaults::svtol) {
151 convtest.set_svtol(t);
152 return *this;
153 }
+
154
155public:
187 template<class M, class Engine = std::mt19937_64>
+
188 std::pair<bool, int> run(
189 const M& mat,
190 bool center,
@@ -215,8 +239,10 @@
249 return run(mat, outU, outV, outD, eng, init);
250 }
251 }
+
252
282 template<class Matrix, class Engine = std::mt19937_64>
+
283 std::pair<bool, int> run(
284 const Matrix& mat,
285 Eigen::MatrixXd& outU,
@@ -232,6 +258,7 @@
295 return run_internal(mat, *eng, outU, outV, outD, init);
296 }
297 }
+
298
299private:
300 template<class M, class Engine>
@@ -406,6 +433,7 @@
469 }
470
471public:
+
475 struct Results {
481 Eigen::MatrixXd U;
482
@@ -417,8 +445,10 @@
500
505 };
+
506
524 template<class M, class Engine = std::mt19937_64>
+
525 Results run(const M& mat, bool center, bool scale, Engine* eng = null_rng(), Eigen::VectorXd* init = NULL) const {
526 Results output;
527 auto stats = run(mat, center, scale, output.U, output.V, output.D, eng, init);
@@ -426,8 +456,10 @@
529 output.iterations = stats.second;
530 return output;
531 }
+
532
548 template<class M, class Engine = std::mt19937_64>
+
549 Results run(const M& mat, Engine* eng = null_rng(), Eigen::VectorXd* init = NULL) const {
550 Results output;
551 auto stats = run(mat, output.U, output.V, output.D, eng, init);
@@ -435,9 +467,12 @@
553 output.iterations = stats.second;
554 return output;
555 }
+
556};
+
557
558}
+
559
560#endif
irlba::Irlba
Run IRLBA on an input matrix.
Definition irlba.hpp:31
@@ -481,7 +516,7 @@ diff --git a/docs/lanczos_8hpp.html b/docs/lanczos_8hpp.html index 4ef1c90..7ad19f7 100644 --- a/docs/lanczos_8hpp.html +++ b/docs/lanczos_8hpp.html @@ -3,7 +3,7 @@ - + irlba: irlba/lanczos.hpp File Reference @@ -31,7 +31,7 @@ - + +
9
16namespace irlba {
17
+
21class LanczosBidiagonalization {
22public:
23 struct Defaults {
27 static constexpr double epsilon = -1;
28 };
29public:
+
40 LanczosBidiagonalization& set_epsilon(double e = Defaults::epsilon) {
41 epsilon = e;
42 return *this;
43 }
+
44
45public:
51 template<class M>
+
+
56 Intermediates(const M& mat) :
57 F(mat.cols()),
58 W_next(mat.rows()),
@@ -110,10 +120,13 @@
60 work(wrapped_workspace(&mat)),
61 awork(wrapped_adjoint_workspace(&mat))
62 {}
+
63
+
69 const Eigen::VectorXd& residuals() const {
70 return F;
71 }
+
72
76 Eigen::VectorXd F;
77 Eigen::VectorXd W_next;
@@ -121,14 +134,18 @@
84 };
+
85
90 template<class M>
+
91 Intermediates<M> initialize(const M& mat) const {
92 return Intermediates(mat);
93 }
+
94
95public:
121 template<class M, class Engine>
+
122 void run(
123 const M& mat,
124 Eigen::MatrixXd& W,
@@ -211,10 +228,12 @@
201
202 return;
203 }
+
204
205private:
206 double epsilon = Defaults::epsilon;
207};
+
208
209}
210
@@ -240,7 +259,7 @@ diff --git a/docs/minus.svg b/docs/minus.svg new file mode 100644 index 0000000..f70d0c1 --- /dev/null +++ b/docs/minus.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/minusd.svg b/docs/minusd.svg new file mode 100644 index 0000000..5f8e879 --- /dev/null +++ b/docs/minusd.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/namespaceirlba.html b/docs/namespaceirlba.html index 99ea37f..a82de0e 100644 --- a/docs/namespaceirlba.html +++ b/docs/namespaceirlba.html @@ -3,7 +3,7 @@ - + irlba: irlba Namespace Reference @@ -31,7 +31,7 @@ - + +
44 class IndexArray = std::vector<int>,
45 class PointerArray = std::vector<size_t>
46>
+
47class ParallelSparseMatrix {
48public:
53 ParallelSparseMatrix() {}
54
+
69 ParallelSparseMatrix(size_t nr, size_t nc, std::vector<double> x, std::vector<int> i, std::vector<size_t> p, int nt) :
70 primary_dim(column_major ? nc : nr),
71 secondary_dim(column_major ? nr : nc),
@@ -109,7 +116,9 @@
78 fragment_threads();
79 }
80 }
+
81
+
85 auto rows() const {
86 if constexpr(column_major) {
87 return secondary_dim;
@@ -117,7 +126,9 @@
89 return primary_dim;
90 }
91 }
+
92
+
96 auto cols() const {
97 if constexpr(column_major) {
98 return primary_dim;
@@ -125,18 +136,25 @@
100 return secondary_dim;
101 }
102 }
+
103
+
108 const ValueArray& get_values() const {
109 return values;
110 }
+
111
+
116 const IndexArray& get_indices() const {
117 return indices;
118 }
+
119
+
123 const PointerArray& get_pointers() const {
124 return ptrs;
125 }
+
126
127private:
128 size_t primary_dim, secondary_dim;
@@ -148,19 +166,25 @@
134 typedef typename std::remove_const<typename std::remove_reference<decltype(indices[0])>::type>::type IndexType;
135
136public:
+
143 const std::vector<size_t>& get_primary_starts() const {
144 return primary_starts;
145 }
+
146
+
153 const std::vector<size_t>& get_primary_ends() const {
154 return primary_ends;
155 }
+
156
160 typedef typename std::remove_const<typename std::remove_reference<decltype(ptrs[0])>::type>::type PointerType;
161
+
170 const std::vector<std::vector<PointerType> >& get_secondary_nonzero_starts() const {
171 return secondary_nonzero_starts;
172 }
+
173
174private:
175 std::vector<size_t> primary_starts, primary_ends;
@@ -312,18 +336,23 @@
321public:
326 typedef bool Workspace;
327
+
331 bool workspace() const {
332 return false;
333 }
+
334
339 typedef bool AdjointWorkspace;
340
+
344 bool adjoint_workspace() const {
345 return false;
346 }
+
347
348public:
358 template<class Right>
+
359 void multiply(const Right& rhs, Workspace& work, Eigen::VectorXd& output) const {
360 if constexpr(column_major) {
361 indirect_multiply(rhs, output);
@@ -331,8 +360,10 @@
363 direct_multiply(rhs, output);
364 }
365 }
+
366
376 template<class Right>
+
377 void adjoint_multiply(const Right& rhs, AdjointWorkspace& work, Eigen::VectorXd& output) const {
378 if constexpr(column_major) {
379 direct_multiply(rhs, output);
@@ -340,8 +371,10 @@
381 indirect_multiply(rhs, output);
382 }
383 }
+
384
385public:
+
389 Eigen::MatrixXd realize() const {
390 Eigen::MatrixXd output(rows(), cols());
391 output.setZero();
@@ -364,8 +397,11 @@
408
409 return output;
410 }
+
411};
+
412
+
425class EigenThreadScope {
426public:
427#ifdef _OPENMP
@@ -393,6 +429,7 @@
464private:
465 int previous;
466};
+
467
468
469
@@ -426,7 +463,7 @@ diff --git a/docs/plus.svg b/docs/plus.svg new file mode 100644 index 0000000..0752016 --- /dev/null +++ b/docs/plus.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/docs/plusd.svg b/docs/plusd.svg new file mode 100644 index 0000000..0c65bfe --- /dev/null +++ b/docs/plusd.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/docs/search/all_0.js b/docs/search/all_0.js index 939ad67..ac2dd79 100644 --- a/docs/search/all_0.js +++ b/docs/search/all_0.js @@ -2,5 +2,5 @@ var searchData= [ ['adjoint_5fmultiply_0',['adjoint_multiply',['../classirlba_1_1ParallelSparseMatrix.html#ada2fd9d0ab3fa3acde0b15de3ac28163',1,'irlba::ParallelSparseMatrix::adjoint_multiply()'],['../structirlba_1_1Centered.html#a5aff4cb0fd5911af49db22ec71eacac7',1,'irlba::Centered::adjoint_multiply()']]], ['adjoint_5fworkspace_1',['adjoint_workspace',['../classirlba_1_1ParallelSparseMatrix.html#ae35f9d60c227dded2504eebe460d2404',1,'irlba::ParallelSparseMatrix::adjoint_workspace()'],['../structirlba_1_1Centered.html#ae9cf9e63720540cdbe1cc880663f8c41',1,'irlba::Centered::adjoint_workspace()']]], - ['adjointworkspace_2',['AdjointWorkspace',['../classirlba_1_1ParallelSparseMatrix.html#a3bb0c5f91e0839013a9b21e4c7f43c58',1,'irlba::ParallelSparseMatrix::AdjointWorkspace'],['../structirlba_1_1Centered.html#a13b2ec774d429f0f00baaea0c413d087',1,'irlba::Centered::AdjointWorkspace']]] + ['adjointworkspace_2',['adjointworkspace',['../classirlba_1_1ParallelSparseMatrix.html#a3bb0c5f91e0839013a9b21e4c7f43c58',1,'irlba::ParallelSparseMatrix::AdjointWorkspace'],['../structirlba_1_1Centered.html#a13b2ec774d429f0f00baaea0c413d087',1,'irlba::Centered::AdjointWorkspace']]] ]; diff --git a/docs/search/all_1.js b/docs/search/all_1.js index 71f47fe..0e9e4cc 100644 --- a/docs/search/all_1.js +++ b/docs/search/all_1.js @@ -1,7 +1,7 @@ var searchData= [ - ['c_2b_2b_20library_20for_20irlba_0',['C++ library for IRLBA',['../index.html',1,'']]], - ['centered_1',['Centered',['../structirlba_1_1Centered.html#a8e835ea0c77cc6eb75d5a257ae53eba8',1,'irlba::Centered::Centered()'],['../structirlba_1_1Centered.html',1,'irlba::Centered< Matrix >']]], + ['c_20library_20for_20irlba_0',['C++ library for IRLBA',['../index.html',1,'']]], + ['centered_1',['centered',['../structirlba_1_1Centered.html',1,'irlba::Centered< Matrix >'],['../structirlba_1_1Centered.html#a8e835ea0c77cc6eb75d5a257ae53eba8',1,'irlba::Centered::Centered()']]], ['cols_2',['cols',['../classirlba_1_1ParallelSparseMatrix.html#acbf711cbb3a9a83d69bfedea21bd9005',1,'irlba::ParallelSparseMatrix::cols()'],['../structirlba_1_1Centered.html#a25b700301187ffe9d12e5b6ba818f071',1,'irlba::Centered::cols()']]], ['converged_3',['converged',['../structirlba_1_1Irlba_1_1Results.html#a6bf7cdbdef24df8f02d7e309ee7c7dcc',1,'irlba::Irlba::Results']]], ['convergencetest_4',['ConvergenceTest',['../structirlba_1_1ConvergenceTest.html',1,'irlba']]] diff --git a/docs/search/all_10.js b/docs/search/all_10.js index 9991843..91c3850 100644 --- a/docs/search/all_10.js +++ b/docs/search/all_10.js @@ -1,13 +1,12 @@ var searchData= [ - ['workspace_0',['Workspace',['../classirlba_1_1ParallelSparseMatrix.html#ace0a9677ba2415af992719ef0ff88ef5',1,'irlba::ParallelSparseMatrix::Workspace'],['../structirlba_1_1Centered.html#aa86585b7bae6f19ae08d9a4baebc84fa',1,'irlba::Centered::Workspace']]], - ['workspace_1',['workspace',['../classirlba_1_1ParallelSparseMatrix.html#aede6b0baadeb52d351c25ab9f24da3dd',1,'irlba::ParallelSparseMatrix::workspace()'],['../structirlba_1_1Centered.html#a55b851d87fb995a2a04d3a07e69121ee',1,'irlba::Centered::workspace()']]], - ['wrapped_5fadjoint_5fmultiply_2',['wrapped_adjoint_multiply',['../namespaceirlba.html#adb3751dd2a2de0754fe92d25a658b45c',1,'irlba']]], - ['wrapped_5fadjoint_5fworkspace_3',['wrapped_adjoint_workspace',['../namespaceirlba.html#a2afbaa693ad02acc03ee74a3ea084630',1,'irlba']]], - ['wrapped_5fmultiply_4',['wrapped_multiply',['../namespaceirlba.html#a944729e08e958d309cce1d66761e88c6',1,'irlba']]], - ['wrapped_5frealize_5',['wrapped_realize',['../namespaceirlba.html#aa5b2aa0b925ead702a50c11eeb63cba5',1,'irlba']]], - ['wrapped_5fworkspace_6',['wrapped_workspace',['../namespaceirlba.html#afb93f4e9565318e79782c847fbebe16b',1,'irlba']]], - ['wrappedadjointworkspace_7',['WrappedAdjointWorkspace',['../namespaceirlba.html#abf539bafcd5bf49b8106fa00b7cf61a3',1,'irlba']]], - ['wrappedworkspace_8',['WrappedWorkspace',['../namespaceirlba.html#a06d0182fc36d37483e1c4731b966cf16',1,'irlba']]], - ['wrappers_2ehpp_9',['wrappers.hpp',['../wrappers_8hpp.html',1,'']]] + ['workspace_0',['workspace',['../classirlba_1_1ParallelSparseMatrix.html#ace0a9677ba2415af992719ef0ff88ef5',1,'irlba::ParallelSparseMatrix::Workspace'],['../structirlba_1_1Centered.html#aa86585b7bae6f19ae08d9a4baebc84fa',1,'irlba::Centered::Workspace'],['../classirlba_1_1ParallelSparseMatrix.html#aede6b0baadeb52d351c25ab9f24da3dd',1,'irlba::ParallelSparseMatrix::workspace()'],['../structirlba_1_1Centered.html#a55b851d87fb995a2a04d3a07e69121ee',1,'irlba::Centered::workspace()']]], + ['wrapped_5fadjoint_5fmultiply_1',['wrapped_adjoint_multiply',['../namespaceirlba.html#adb3751dd2a2de0754fe92d25a658b45c',1,'irlba']]], + ['wrapped_5fadjoint_5fworkspace_2',['wrapped_adjoint_workspace',['../namespaceirlba.html#a2afbaa693ad02acc03ee74a3ea084630',1,'irlba']]], + ['wrapped_5fmultiply_3',['wrapped_multiply',['../namespaceirlba.html#a944729e08e958d309cce1d66761e88c6',1,'irlba']]], + ['wrapped_5frealize_4',['wrapped_realize',['../namespaceirlba.html#aa5b2aa0b925ead702a50c11eeb63cba5',1,'irlba']]], + ['wrapped_5fworkspace_5',['wrapped_workspace',['../namespaceirlba.html#afb93f4e9565318e79782c847fbebe16b',1,'irlba']]], + ['wrappedadjointworkspace_6',['WrappedAdjointWorkspace',['../namespaceirlba.html#abf539bafcd5bf49b8106fa00b7cf61a3',1,'irlba']]], + ['wrappedworkspace_7',['WrappedWorkspace',['../namespaceirlba.html#a06d0182fc36d37483e1c4731b966cf16',1,'irlba']]], + ['wrappers_2ehpp_8',['wrappers.hpp',['../wrappers_8hpp.html',1,'']]] ]; diff --git a/docs/search/all_3.js b/docs/search/all_3.js index 001366f..c387bff 100644 --- a/docs/search/all_3.js +++ b/docs/search/all_3.js @@ -1,5 +1,5 @@ var searchData= [ - ['eigenthreadscope_0',['EigenThreadScope',['../classirlba_1_1EigenThreadScope.html#a8fdbc24d92c1e6610c8d5785bc575804',1,'irlba::EigenThreadScope::EigenThreadScope()'],['../classirlba_1_1EigenThreadScope.html',1,'irlba::EigenThreadScope']]], + ['eigenthreadscope_0',['eigenthreadscope',['../classirlba_1_1EigenThreadScope.html',1,'irlba::EigenThreadScope'],['../classirlba_1_1EigenThreadScope.html#a8fdbc24d92c1e6610c8d5785bc575804',1,'irlba::EigenThreadScope::EigenThreadScope()']]], ['extra_5fwork_1',['extra_work',['../structirlba_1_1Irlba_1_1Defaults.html#a5bcbb0f825ebb62a2626de2399cb6e6a',1,'irlba::Irlba::Defaults']]] ]; diff --git a/docs/search/all_4.js b/docs/search/all_4.js index ed11e1b..dfdf7b4 100644 --- a/docs/search/all_4.js +++ b/docs/search/all_4.js @@ -1,4 +1,5 @@ var searchData= [ - ['fill_5fwith_5frandom_5fnormals_0',['fill_with_random_normals',['../namespaceirlba.html#ac455bdeaab9538bd047eac59b457c995',1,'irlba::fill_with_random_normals(Vec &vec, Engine &eng)'],['../namespaceirlba.html#ae515cba62286a7e0bb2c9346b4d54cb5',1,'irlba::fill_with_random_normals(Matrix &mat, int column, Engine &eng)']]] + ['fill_5fwith_5frandom_5fnormals_0',['fill_with_random_normals',['../namespaceirlba.html#ac455bdeaab9538bd047eac59b457c995',1,'irlba::fill_with_random_normals(Vec &vec, Engine &eng)'],['../namespaceirlba.html#ae515cba62286a7e0bb2c9346b4d54cb5',1,'irlba::fill_with_random_normals(Matrix &mat, int column, Engine &eng)']]], + ['for_20irlba_1',['C++ library for IRLBA',['../index.html',1,'']]] ]; diff --git a/docs/search/all_6.js b/docs/search/all_6.js index 27a21a6..5d89ffb 100644 --- a/docs/search/all_6.js +++ b/docs/search/all_6.js @@ -1,9 +1,8 @@ var searchData= [ ['initialize_0',['initialize',['../classirlba_1_1LanczosBidiagonalization.html#af53e6725d54f09baad07deada8d46f74',1,'irlba::LanczosBidiagonalization']]], - ['intermediates_1',['Intermediates',['../structirlba_1_1LanczosBidiagonalization_1_1Intermediates.html#ad662926e9e48469758274bc757bf7491',1,'irlba::LanczosBidiagonalization::Intermediates::Intermediates()'],['../structirlba_1_1LanczosBidiagonalization_1_1Intermediates.html',1,'irlba::LanczosBidiagonalization::Intermediates< M >']]], - ['irlba_2',['irlba',['../namespaceirlba.html',1,'']]], - ['irlba_3',['Irlba',['../classirlba_1_1Irlba.html',1,'irlba']]], - ['irlba_2ehpp_4',['irlba.hpp',['../irlba_8hpp.html',1,'']]], - ['iterations_5',['iterations',['../structirlba_1_1Irlba_1_1Results.html#a01a33644ef84e921f611699d5656f255',1,'irlba::Irlba::Results']]] + ['intermediates_1',['intermediates',['../structirlba_1_1LanczosBidiagonalization_1_1Intermediates.html',1,'irlba::LanczosBidiagonalization::Intermediates< M >'],['../structirlba_1_1LanczosBidiagonalization_1_1Intermediates.html#ad662926e9e48469758274bc757bf7491',1,'irlba::LanczosBidiagonalization::Intermediates::Intermediates()']]], + ['irlba_2',['irlba',['../index.html',1,'C++ library for IRLBA'],['../classirlba_1_1Irlba.html',1,'irlba::Irlba'],['../namespaceirlba.html',1,'irlba']]], + ['irlba_2ehpp_3',['irlba.hpp',['../irlba_8hpp.html',1,'']]], + ['iterations_4',['iterations',['../structirlba_1_1Irlba_1_1Results.html#a01a33644ef84e921f611699d5656f255',1,'irlba::Irlba::Results']]] ]; diff --git a/docs/search/all_7.js b/docs/search/all_7.js index 16c8f24..7ef0bd2 100644 --- a/docs/search/all_7.js +++ b/docs/search/all_7.js @@ -1,5 +1,6 @@ var searchData= [ ['lanczos_2ehpp_0',['lanczos.hpp',['../lanczos_8hpp.html',1,'']]], - ['lanczosbidiagonalization_1',['LanczosBidiagonalization',['../classirlba_1_1LanczosBidiagonalization.html',1,'irlba']]] + ['lanczosbidiagonalization_1',['LanczosBidiagonalization',['../classirlba_1_1LanczosBidiagonalization.html',1,'irlba']]], + ['library_20for_20irlba_2',['C++ library for IRLBA',['../index.html',1,'']]] ]; diff --git a/docs/search/all_b.js b/docs/search/all_b.js index 98d75fe..d5b800c 100644 --- a/docs/search/all_b.js +++ b/docs/search/all_b.js @@ -1,6 +1,6 @@ var searchData= [ ['parallel_2ehpp_0',['parallel.hpp',['../parallel_8hpp.html',1,'']]], - ['parallelsparsematrix_1',['ParallelSparseMatrix',['../classirlba_1_1ParallelSparseMatrix.html',1,'irlba::ParallelSparseMatrix< column_major, ValueArray, IndexArray, PointerArray >'],['../classirlba_1_1ParallelSparseMatrix.html#a16bee0852ada7f1cecf5ebd71a34ddfd',1,'irlba::ParallelSparseMatrix::ParallelSparseMatrix()'],['../classirlba_1_1ParallelSparseMatrix.html#a3e74fcc7617d409787cc9808b088f2eb',1,'irlba::ParallelSparseMatrix::ParallelSparseMatrix(size_t nr, size_t nc, std::vector< double > x, std::vector< int > i, std::vector< size_t > p, int nt)']]], + ['parallelsparsematrix_1',['parallelsparsematrix',['../classirlba_1_1ParallelSparseMatrix.html',1,'irlba::ParallelSparseMatrix< column_major, ValueArray, IndexArray, PointerArray >'],['../classirlba_1_1ParallelSparseMatrix.html#a16bee0852ada7f1cecf5ebd71a34ddfd',1,'irlba::ParallelSparseMatrix::ParallelSparseMatrix()'],['../classirlba_1_1ParallelSparseMatrix.html#a3e74fcc7617d409787cc9808b088f2eb',1,'irlba::ParallelSparseMatrix::ParallelSparseMatrix(size_t nr, size_t nc, std::vector< double > x, std::vector< int > i, std::vector< size_t > p, int nt)']]], ['pointertype_2',['PointerType',['../classirlba_1_1ParallelSparseMatrix.html#ac54daf205fe2ed9ae391eb9920a59423',1,'irlba::ParallelSparseMatrix']]] ]; diff --git a/docs/search/all_d.js b/docs/search/all_d.js index 0f486e8..c0804fd 100644 --- a/docs/search/all_d.js +++ b/docs/search/all_d.js @@ -1,6 +1,6 @@ var searchData= [ - ['scaled_0',['Scaled',['../structirlba_1_1Scaled.html',1,'irlba::Scaled< Matrix_, column_, divide_ >'],['../structirlba_1_1Scaled.html#a1b2c01cf3f066d871702fec3948cfaa3',1,'irlba::Scaled::Scaled()']]], + ['scaled_0',['scaled',['../structirlba_1_1Scaled.html',1,'irlba::Scaled< Matrix_, column_, divide_ >'],['../structirlba_1_1Scaled.html#a1b2c01cf3f066d871702fec3948cfaa3',1,'irlba::Scaled::Scaled()']]], ['seed_1',['seed',['../structirlba_1_1Irlba_1_1Defaults.html#a4b02b059a1ccc5cd7439816e54ed4222',1,'irlba::Irlba::Defaults']]], ['set_5fconvergence_5ftolerance_2',['set_convergence_tolerance',['../classirlba_1_1Irlba.html#a9aa27d5a7891b6350b4d2da80b9b99d5',1,'irlba::Irlba']]], ['set_5fepsilon_3',['set_epsilon',['../classirlba_1_1LanczosBidiagonalization.html#af0ab346a06e95819dacb124d5827bebf',1,'irlba::LanczosBidiagonalization']]], diff --git a/docs/search/functions_9.js b/docs/search/functions_9.js index d4a948f..80e5790 100644 --- a/docs/search/functions_9.js +++ b/docs/search/functions_9.js @@ -1,4 +1,4 @@ var searchData= [ - ['parallelsparsematrix_0',['ParallelSparseMatrix',['../classirlba_1_1ParallelSparseMatrix.html#a16bee0852ada7f1cecf5ebd71a34ddfd',1,'irlba::ParallelSparseMatrix::ParallelSparseMatrix()'],['../classirlba_1_1ParallelSparseMatrix.html#a3e74fcc7617d409787cc9808b088f2eb',1,'irlba::ParallelSparseMatrix::ParallelSparseMatrix(size_t nr, size_t nc, std::vector< double > x, std::vector< int > i, std::vector< size_t > p, int nt)']]] + ['parallelsparsematrix_0',['parallelsparsematrix',['../classirlba_1_1ParallelSparseMatrix.html#a16bee0852ada7f1cecf5ebd71a34ddfd',1,'irlba::ParallelSparseMatrix::ParallelSparseMatrix()'],['../classirlba_1_1ParallelSparseMatrix.html#a3e74fcc7617d409787cc9808b088f2eb',1,'irlba::ParallelSparseMatrix::ParallelSparseMatrix(size_t nr, size_t nc, std::vector< double > x, std::vector< int > i, std::vector< size_t > p, int nt)']]] ]; diff --git a/docs/search/pages_0.js b/docs/search/pages_0.js index 971c639..4ebe35c 100644 --- a/docs/search/pages_0.js +++ b/docs/search/pages_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['c_2b_2b_20library_20for_20irlba_0',['C++ library for IRLBA',['../index.html',1,'']]] + ['c_20library_20for_20irlba_0',['C++ library for IRLBA',['../index.html',1,'']]] ]; diff --git a/docs/search/pages_1.js b/docs/search/pages_1.js new file mode 100644 index 0000000..e183107 --- /dev/null +++ b/docs/search/pages_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['for_20irlba_0',['C++ library for IRLBA',['../index.html',1,'']]] +]; diff --git a/docs/search/pages_2.js b/docs/search/pages_2.js new file mode 100644 index 0000000..e0cf256 --- /dev/null +++ b/docs/search/pages_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['irlba_0',['C++ library for IRLBA',['../index.html',1,'']]] +]; diff --git a/docs/search/pages_3.js b/docs/search/pages_3.js new file mode 100644 index 0000000..010e395 --- /dev/null +++ b/docs/search/pages_3.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['library_20for_20irlba_0',['C++ library for IRLBA',['../index.html',1,'']]] +]; diff --git a/docs/search/search.js b/docs/search/search.js index 9b7a52a..6fd40c6 100644 --- a/docs/search/search.js +++ b/docs/search/search.js @@ -195,6 +195,7 @@ function SearchBox(name, resultsPath, extension) } else if (e.keyCode==27) // Escape out of the search field { + e.stopPropagation(); this.DOMSearchField().blur(); this.DOMPopupSearchResultsWindow().style.display = 'none'; this.DOMSearchClose().style.display = 'none'; @@ -289,6 +290,7 @@ function SearchBox(name, resultsPath, extension) } else if (e.keyCode==13 || e.keyCode==27) { + e.stopPropagation(); this.OnSelectItem(this.searchIndex); this.CloseSelectionWindow(); this.DOMSearchField().focus(); @@ -670,6 +672,7 @@ function SearchResults(name) } else if (this.lastKey==27) // Escape { + e.stopPropagation(); searchBox.CloseResultsWindow(); document.getElementById("MSearchField").focus(); } @@ -713,6 +716,7 @@ function SearchResults(name) } else if (this.lastKey==27) // Escape { + e.stopPropagation(); searchBox.CloseResultsWindow(); document.getElementById("MSearchField").focus(); } @@ -806,6 +810,7 @@ function createResults(resultsPath) function init_search() { var results = document.getElementById("MSearchSelectWindow"); + results.tabIndex=0; for (var key in indexSectionLabels) { var link = document.createElement('a'); @@ -816,5 +821,20 @@ function init_search() results.appendChild(link); } searchBox.OnSelectItem(0); + + var input = document.getElementById("MSearchSelect"); + var searchSelectWindow = document.getElementById("MSearchSelectWindow"); + input.tabIndex=0; + input.addEventListener("keydown", function(event) { + if (event.keyCode==13 || event.keyCode==40) { + event.preventDefault(); + if (searchSelectWindow.style.display == 'block') { + searchBox.CloseSelectionWindow(); + } else { + searchBox.OnSearchSelectShow(); + searchBox.DOMSearchSelectWindow().focus(); + } + } + }); } /* @license-end */ diff --git a/docs/search/searchdata.js b/docs/search/searchdata.js index 72c9205..a5be3f4 100644 --- a/docs/search/searchdata.js +++ b/docs/search/searchdata.js @@ -7,7 +7,7 @@ var indexSectionsWithContent = 4: "acefgimnoprsw", 5: "cdeimnsuv", 6: "apw", - 7: "c" + 7: "cfil" }; var indexSectionNames = diff --git a/docs/search/typedefs_0.js b/docs/search/typedefs_0.js index df29f60..b369be8 100644 --- a/docs/search/typedefs_0.js +++ b/docs/search/typedefs_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['adjointworkspace_0',['AdjointWorkspace',['../classirlba_1_1ParallelSparseMatrix.html#a3bb0c5f91e0839013a9b21e4c7f43c58',1,'irlba::ParallelSparseMatrix::AdjointWorkspace'],['../structirlba_1_1Centered.html#a13b2ec774d429f0f00baaea0c413d087',1,'irlba::Centered::AdjointWorkspace']]] + ['adjointworkspace_0',['adjointworkspace',['../classirlba_1_1ParallelSparseMatrix.html#a3bb0c5f91e0839013a9b21e4c7f43c58',1,'irlba::ParallelSparseMatrix::AdjointWorkspace'],['../structirlba_1_1Centered.html#a13b2ec774d429f0f00baaea0c413d087',1,'irlba::Centered::AdjointWorkspace']]] ]; diff --git a/docs/search/typedefs_2.js b/docs/search/typedefs_2.js index 8aba93f..889eace 100644 --- a/docs/search/typedefs_2.js +++ b/docs/search/typedefs_2.js @@ -1,6 +1,6 @@ var searchData= [ - ['workspace_0',['Workspace',['../classirlba_1_1ParallelSparseMatrix.html#ace0a9677ba2415af992719ef0ff88ef5',1,'irlba::ParallelSparseMatrix::Workspace'],['../structirlba_1_1Centered.html#aa86585b7bae6f19ae08d9a4baebc84fa',1,'irlba::Centered::Workspace']]], + ['workspace_0',['workspace',['../classirlba_1_1ParallelSparseMatrix.html#ace0a9677ba2415af992719ef0ff88ef5',1,'irlba::ParallelSparseMatrix::Workspace'],['../structirlba_1_1Centered.html#aa86585b7bae6f19ae08d9a4baebc84fa',1,'irlba::Centered::Workspace']]], ['wrappedadjointworkspace_1',['WrappedAdjointWorkspace',['../namespaceirlba.html#abf539bafcd5bf49b8106fa00b7cf61a3',1,'irlba']]], ['wrappedworkspace_2',['WrappedWorkspace',['../namespaceirlba.html#a06d0182fc36d37483e1c4731b966cf16',1,'irlba']]] ]; diff --git a/docs/structirlba_1_1Centered-members.html b/docs/structirlba_1_1Centered-members.html index 8f6c398..a9207a4 100644 --- a/docs/structirlba_1_1Centered-members.html +++ b/docs/structirlba_1_1Centered-members.html @@ -3,7 +3,7 @@ - + irlba: Member List @@ -31,7 +31,7 @@ - + +
8
15namespace irlba {
16
+
27inline void orthogonalize_vector(const Eigen::MatrixXd& mat, Eigen::VectorXd& vec, size_t ncols, Eigen::VectorXd& tmp) {
28 tmp.head(ncols).noalias() = mat.leftCols(ncols).adjoint() * vec;
29 vec.noalias() -= mat.leftCols(ncols) * tmp.head(ncols);
30 return;
31}
+
32
43template<class Vec, class Engine>
+
44void fill_with_random_normals(Vec& vec, Engine& eng) {
45 Eigen::Index i = 0;
46 while (i < vec.size() - 1) {
@@ -110,6 +118,7 @@
56 }
57 return;
58}
+
59
63template<class M>
64struct ColumnVectorProxy {
@@ -120,12 +129,15 @@
69 int col;
70};
86template<class Matrix, class Engine>
+
87void fill_with_random_normals(Matrix& mat, int column, Engine& eng) {
88 ColumnVectorProxy proxy(mat, column);
89 fill_with_random_normals(proxy, eng);
90 return;
91}
+
92
+
96struct ConvergenceTest {
97public:
98 struct Defaults {
@@ -139,17 +151,22 @@
112 double svtol = Defaults::svtol;
113
114public:
+
122 ConvergenceTest& set_tol(double t = Defaults::tol) {
123 tol = t;
124 return *this;
125 }
+
126
+
135 ConvergenceTest& set_svtol(double s = Defaults::svtol) {
136 svtol = s;
137 return *this;
138 }
+
139
140public:
+
150 int run(const Eigen::VectorXd& sv, const Eigen::VectorXd& residuals, const Eigen::VectorXd& last) const {
151 int counter = 0;
152 double Smax = *std::max_element(sv.begin(), sv.end());
@@ -165,7 +182,9 @@
162
163 return counter;
164 }
+
165};
+
166
173constexpr std::mt19937_64* null_rng() { return NULL; }
174
@@ -212,7 +231,7 @@ diff --git a/docs/wrappers_8hpp.html b/docs/wrappers_8hpp.html index 2409f58..f12bf80 100644 --- a/docs/wrappers_8hpp.html +++ b/docs/wrappers_8hpp.html @@ -3,7 +3,7 @@ - + irlba: irlba/wrappers.hpp File Reference @@ -31,7 +31,7 @@ - + +
82using WrappedAdjointWorkspace = typename WrappedAdjointWorkspaceInternal<Matrix>::type;
83
89template<class Matrix>
+
90WrappedWorkspace<Matrix> wrapped_workspace(const Matrix* mat) {
91 if constexpr(has_multiply_method<Matrix>::value) { // using this as a proxy for whether it's an Eigen matrix or not.
92 return false;
@@ -119,8 +125,10 @@
94 return mat->workspace();
95 }
96}
+
97
103template<class Matrix>
+
104WrappedAdjointWorkspace<Matrix> wrapped_adjoint_workspace(const Matrix* mat) {
105 if constexpr(has_adjoint_multiply_method<Matrix>::value) {
106 return false;
@@ -128,8 +136,10 @@
108 return mat->adjoint_workspace();
109 }
110}
+
111
122template<class Matrix, class Right>
+
123void wrapped_multiply(const Matrix* mat, const Right& rhs, WrappedWorkspace<Matrix>& work, Eigen::VectorXd& out) {
124 if constexpr(has_multiply_method<Matrix>::value) {
125 out.noalias() = *mat * rhs;
@@ -137,8 +147,10 @@
127 mat->multiply(rhs, work, out);
128 }
129}
+
130
141template<class Matrix, class Right>
+
142void wrapped_adjoint_multiply(const Matrix* mat, const Right& rhs, WrappedAdjointWorkspace<Matrix>& work, Eigen::VectorXd& out) {
143 if constexpr(has_adjoint_multiply_method<Matrix>::value) {
144 out.noalias() = mat->adjoint() * rhs;
@@ -146,8 +158,10 @@
146 mat->adjoint_multiply(rhs, work, out);
147 }
148}
+
149
155template<class Matrix>
+
156Eigen::MatrixXd wrapped_realize(const Matrix* mat) {
157 if constexpr(has_realize_method<Matrix>::value) {
158 return mat->realize();
@@ -155,8 +169,10 @@
160 return Eigen::MatrixXd(*mat);
161 }
162}
+
163
172template<class Matrix>
+
173struct Centered {
179 Centered(const Matrix* m, const Eigen::VectorXd* c) : mat(m), center(c) {}
180
@@ -167,18 +183,23 @@
191public:
196 typedef WrappedWorkspace<Matrix> Workspace;
197
+
202 return wrapped_workspace(mat);
203 }
+
204
209 typedef WrappedAdjointWorkspace<Matrix> AdjointWorkspace;
210
+
215 return wrapped_adjoint_workspace(mat);
216 }
+
217
218public:
228 template<class Right>
+
229 void multiply(const Right& rhs, Workspace& work, Eigen::VectorXd& out) const {
230 wrapped_multiply(mat, rhs, work, out);
231 double beta = rhs.dot(*center);
@@ -187,15 +208,19 @@
234 }
235 return;
236 }
+
237
247 template<class Right>
+
248 void adjoint_multiply(const Right& rhs, AdjointWorkspace& work, Eigen::VectorXd& out) const {
249 wrapped_adjoint_multiply(mat, rhs, work, out);
250 double beta = rhs.sum();
251 out -= beta * (*center);
252 return;
253 }
+
254
+
259 Eigen::MatrixXd realize() const {
260 Eigen::MatrixXd output = wrapped_realize(mat);
261 for (Eigen::Index c = 0; c < output.cols(); ++c) {
@@ -205,13 +230,16 @@
265 }
266 return output;
267 }
+
268
269private:
270 const Matrix* mat;
271 const Eigen::VectorXd* center;
272};
+
273
286template<class Matrix_, bool column_ = true, bool divide_ = true>
+
287struct Scaled {
293 Scaled(const Matrix_* m, const Eigen::VectorXd* s) : mat(m), scale(s) {}
294
@@ -226,97 +254,98 @@
313 Wrapper_<Matrix_> child;
314 };
315
-
316 typedef typename std::conditional<column_, BufferedWorkspace<WrappedWorkspace>, WrappedWorkspace<Matrix_> >::type Workspace;
+
316 typedef typename std::conditional<column_, BufferedWorkspace<WrappedWorkspace>, WrappedWorkspace<Matrix_> >::type Workspace;
317
318 Workspace workspace() const {
-
319 if constexpr(column_) {
-
320 return BufferedWorkspace<WrappedWorkspace>(mat->cols(), wrapped_workspace(mat));
+
319 if constexpr(column_) {
+
320 return BufferedWorkspace<WrappedWorkspace>(mat->cols(), wrapped_workspace(mat));
321 } else {
322 return wrapped_workspace(mat);
323 }
324 }
325
-
326 typedef typename std::conditional<column_, WrappedAdjointWorkspace<Matrix_>, BufferedWorkspace<WrappedAdjointWorkspace> >::type AdjointWorkspace;
+
326 typedef typename std::conditional<column_, WrappedAdjointWorkspace<Matrix_>, BufferedWorkspace<WrappedAdjointWorkspace> >::type AdjointWorkspace;
327
328 AdjointWorkspace adjoint_workspace() const {
-
329 if constexpr(column_) {
+
329 if constexpr(column_) {
330 return wrapped_adjoint_workspace(mat);
331 } else {
-
332 return BufferedWorkspace<WrappedAdjointWorkspace>(mat->rows(), wrapped_adjoint_workspace(mat));
+
332 return BufferedWorkspace<WrappedAdjointWorkspace>(mat->rows(), wrapped_adjoint_workspace(mat));
333 }
334 }
339public:
343 template<class Right_>
-
344 void multiply(const Right_& rhs, Workspace& work, Eigen::VectorXd& out) const {
-
345 if constexpr(column_) {
-
346 if constexpr(divide_) {
+
344 void multiply(const Right_& rhs, Workspace& work, Eigen::VectorXd& out) const {
+
345 if constexpr(column_) {
+
346 if constexpr(divide_) {
347 // We store the result here, because the underlying matrix's multiply()
348 // might need to access rhs/scale multiple times, especially if it's
349 // parallelized. Better to pay the cost of accessing a separate memory
350 // space than computing the quotient repeatedly.
-
351 work.buffer = rhs.cwiseQuotient(*scale);
+
351 work.buffer = rhs.cwiseQuotient(*scale);
352 } else {
-
353 work.buffer = rhs.cwiseProduct(*scale);
+
353 work.buffer = rhs.cwiseProduct(*scale);
354 }
-
355 wrapped_multiply(mat, work.buffer, work.child, out);
+
355 wrapped_multiply(mat, work.buffer, work.child, out);
356
357 } else {
-
358 wrapped_multiply(mat, rhs, work, out);
-
359 if constexpr(divide_) {
-
360 out.array() /= scale->array();
+
358 wrapped_multiply(mat, rhs, work, out);
+
359 if constexpr(divide_) {
+
360 out.array() /= scale->array();
361 } else {
-
362 out.array() *= scale->array();
+
362 out.array() *= scale->array();
363 }
364 }
365 }
366
367 template<class Right_>
-
368 void adjoint_multiply(const Right_& rhs, AdjointWorkspace& work, Eigen::VectorXd& out) const {
-
369 if constexpr(column_) {
-
370 wrapped_adjoint_multiply(mat, rhs, work, out);
-
371 if constexpr(divide_) {
-
372 out.array() /= scale->array();
+
368 void adjoint_multiply(const Right_& rhs, AdjointWorkspace& work, Eigen::VectorXd& out) const {
+
369 if constexpr(column_) {
+
370 wrapped_adjoint_multiply(mat, rhs, work, out);
+
371 if constexpr(divide_) {
+
372 out.array() /= scale->array();
373 } else {
-
374 out.array() *= scale->array();
+
374 out.array() *= scale->array();
375 }
376
377 } else {
-
378 if constexpr(divide_) {
-
379 work.buffer = rhs.cwiseQuotient(*scale);
+
378 if constexpr(divide_) {
+
379 work.buffer = rhs.cwiseQuotient(*scale);
380 } else {
-
381 work.buffer = rhs.cwiseProduct(*scale);
+
381 work.buffer = rhs.cwiseProduct(*scale);
382 }
-
383 wrapped_adjoint_multiply(mat, work.buffer, work.child, out);
+
383 wrapped_adjoint_multiply(mat, work.buffer, work.child, out);
384 }
385 }
386
387 Eigen::MatrixXd realize() const {
-
388 Eigen::MatrixXd output = wrapped_realize(mat);
+
388 Eigen::MatrixXd output = wrapped_realize(mat);
389
-
390 for (Eigen::Index c = 0; c < output.cols(); ++c) {
-
391 for (Eigen::Index r = 0; r < output.rows(); ++r) {
-
392 if constexpr(column_) {
-
393 if constexpr(divide_) {
-
394 output(r, c) /= (*scale)[c];
+
390 for (Eigen::Index c = 0; c < output.cols(); ++c) {
+
391 for (Eigen::Index r = 0; r < output.rows(); ++r) {
+
392 if constexpr(column_) {
+
393 if constexpr(divide_) {
+
394 output(r, c) /= (*scale)[c];
395 } else {
-
396 output(r, c) *= (*scale)[c];
+
396 output(r, c) *= (*scale)[c];
397 }
398 } else {
-
399 if constexpr(divide_) {
-
400 output(r, c) /= (*scale)[r];
+
399 if constexpr(divide_) {
+
400 output(r, c) /= (*scale)[r];
401 } else {
-
402 output(r, c) *= (*scale)[r];
+
402 output(r, c) *= (*scale)[r];
403 }
404 }
405 }
406 }
407
-
408 return output;
+
408 return output;
409 }
414private:
-
415 const Matrix_* mat;
+
415 const Matrix_* mat;
416 const Eigen::VectorXd* scale;
417};
+
418
419}
420
@@ -346,7 +375,7 @@