newarp_GenEigsSolver_meat.hpp (armadillo-10.8.2.tar.xz) | : | newarp_GenEigsSolver_meat.hpp (armadillo-11.0.0.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 24 | skipping to change at line 24 | |||
// See the License for the specific language governing permissions and | // See the License for the specific language governing permissions and | |||
// limitations under the License. | // limitations under the License. | |||
// ------------------------------------------------------------------------ | // ------------------------------------------------------------------------ | |||
namespace newarp | namespace newarp | |||
{ | { | |||
template<typename eT, int SelectionRule, typename OpType> | template<typename eT, int SelectionRule, typename OpType> | |||
inline | inline | |||
void | void | |||
GenEigsSolver<eT, SelectionRule, OpType>::fill_rand(eT* dest, const uword N, con | ||||
st uword seed_val) | ||||
{ | ||||
arma_extra_debug_sigprint(); | ||||
typedef typename std::mt19937_64::result_type seed_type; | ||||
local_rng.seed( seed_type(seed_val) ); | ||||
std::uniform_real_distribution<double> dist(-1.0, +1.0); | ||||
for(uword i=0; i < N; ++i) { dest[i] = eT(dist(local_rng)); } | ||||
} | ||||
template<typename eT, int SelectionRule, typename OpType> | ||||
inline | ||||
void | ||||
GenEigsSolver<eT, SelectionRule, OpType>::factorise_from(uword from_k, uword to_ m, const Col<eT>& fk) | GenEigsSolver<eT, SelectionRule, OpType>::factorise_from(uword from_k, uword to_ m, const Col<eT>& fk) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
if(to_m <= from_k) { return; } | if(to_m <= from_k) { return; } | |||
fac_f = fk; | fac_f = fk; | |||
Col<eT> w(dim_n, arma_zeros_indicator()); | Col<eT> w(dim_n, arma_zeros_indicator()); | |||
eT beta = norm(fac_f); | eT beta = norm(fac_f); | |||
skipping to change at line 45 | skipping to change at line 61 | |||
fac_H.tail_cols(ncv - from_k).zeros(); | fac_H.tail_cols(ncv - from_k).zeros(); | |||
fac_H.submat(span(from_k, ncv - 1), span(0, from_k - 1)).zeros(); | fac_H.submat(span(from_k, ncv - 1), span(0, from_k - 1)).zeros(); | |||
for(uword i = from_k; i <= to_m - 1; i++) | for(uword i = from_k; i <= to_m - 1; i++) | |||
{ | { | |||
bool restart = false; | bool restart = false; | |||
// If beta = 0, then the next V is not full rank | // If beta = 0, then the next V is not full rank | |||
// We need to generate a new residual vector that is orthogonal | // We need to generate a new residual vector that is orthogonal | |||
// to the current V, which we call a restart | // to the current V, which we call a restart | |||
if(beta < eps) | if(beta < eps) | |||
{ | { | |||
// // Generate new random vector for fac_f | ||||
// blas_int idist = 2; | ||||
// blas_int iseed[4] = {1, 3, 5, 7}; | ||||
// iseed[0] = (i + 100) % 4095; | ||||
// blas_int n = dim_n; | ||||
// lapack::larnv(&idist, &iseed[0], &n, fac_f.memptr()); | ||||
// Generate new random vector for fac_f | // Generate new random vector for fac_f | |||
blas_int idist = 2; | fill_rand(fac_f.memptr(), dim_n, i+1); | |||
blas_int iseed[4] = {1, 3, 5, 7}; | ||||
iseed[0] = (i + 100) % 4095; | ||||
blas_int n = dim_n; | ||||
lapack::larnv(&idist, &iseed[0], &n, fac_f.memptr()); | ||||
// f <- f - V * V' * f, so that f is orthogonal to V | // f <- f - V * V' * f, so that f is orthogonal to V | |||
Mat<eT> Vs(fac_V.memptr(), dim_n, i, false); // First i columns | Mat<eT> Vs(fac_V.memptr(), dim_n, i, false); // First i columns | |||
Col<eT> Vf = Vs.t() * fac_f; | Col<eT> Vf = Vs.t() * fac_f; | |||
fac_f -= Vs * Vf; | fac_f -= Vs * Vf; | |||
// beta <- ||f|| | // beta <- ||f|| | |||
beta = norm(fac_f); | beta = norm(fac_f); | |||
restart = true; | restart = true; | |||
} | } | |||
skipping to change at line 347 | skipping to change at line 367 | |||
fac_f = w - v * fac_H(0, 0); | fac_f = w - v * fac_H(0, 0); | |||
} | } | |||
template<typename eT, int SelectionRule, typename OpType> | template<typename eT, int SelectionRule, typename OpType> | |||
inline | inline | |||
void | void | |||
GenEigsSolver<eT, SelectionRule, OpType>::init() | GenEigsSolver<eT, SelectionRule, OpType>::init() | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
// podarray<eT> init_resid(dim_n); | ||||
// blas_int idist = 2; // Uniform(-1, 1) | ||||
// blas_int iseed[4] = {1, 3, 5, 7}; // Fixed random seed | ||||
// blas_int n = dim_n; | ||||
// lapack::larnv(&idist, &iseed[0], &n, init_resid.memptr()); | ||||
// init(init_resid.memptr()); | ||||
podarray<eT> init_resid(dim_n); | podarray<eT> init_resid(dim_n); | |||
blas_int idist = 2; // Uniform(-1, 1) | ||||
blas_int iseed[4] = {1, 3, 5, 7}; // Fixed random seed | fill_rand(init_resid.memptr(), dim_n, 0); | |||
blas_int n = dim_n; | ||||
lapack::larnv(&idist, &iseed[0], &n, init_resid.memptr()); | ||||
init(init_resid.memptr()); | init(init_resid.memptr()); | |||
} | } | |||
template<typename eT, int SelectionRule, typename OpType> | template<typename eT, int SelectionRule, typename OpType> | |||
inline | inline | |||
uword | uword | |||
GenEigsSolver<eT, SelectionRule, OpType>::compute(uword maxit, eT tol) | GenEigsSolver<eT, SelectionRule, OpType>::compute(uword maxit, eT tol) | |||
{ | { | |||
arma_extra_debug_sigprint(); | arma_extra_debug_sigprint(); | |||
End of changes. 5 change blocks. | ||||
9 lines changed or deleted | 36 lines changed or added |