def create_lanczos_vectors(initial_wf): """Creates the three Lanczos vectors. The Lanczos vectors are created empty, but with the proper size and type. The first lanczos vector is set to have the same eleements as the `initial_wf`. Parameters ---------- initial_wf : a Wavefunction. The initial wavefunction serving as seed in the Lanczos algorithm. Returns ------- result : a tuple of 3 Wavefunctions. The three Lanczos vectors. They have the same shape and type as initial_wf. The first has the same elements (is a copy), and the last two are full of garbage. """ result = [ create_empty_like(initial_wf), create_empty_like(initial_wf), create_empty_like(initial_wf) ] result[0].as_matrix = np.copy(initial_wf.as_matrix) return result
def create_lanczos_vectors(initial_wf): """Creates the three Lanczos vectors. The Lanczos vectors are created empty, but with the proper size and type. The first lanczos vector is set to have the same eleements as the `initial_wf`. Parameters ---------- initial_wf : a Wavefunction. The initial wavefunction serving as seed in the Lanczos algorithm. Returns ------- result : a tuple of 3 Wavefunctions. The three Lanczos vectors. They have the same shape and type as initial_wf. The first has the same elements (is a copy), and the last two are full of garbage. """ result = [create_empty_like(initial_wf), create_empty_like(initial_wf), create_empty_like(initial_wf)] result[0].as_matrix = np.copy(initial_wf.as_matrix) return result
def cycle_lanczos_vectors(lv, saved_lanczos_vectors): """Cycles the Lanczos vectors to prepare them for the next iteration. You use this function to cycle the Lanczos vectors in this way: - lv[1] -> lv[0] - lv[2] -> lv[1] The first Lanczos vector before the cycle, `lv[0]` is not needed anymore and is appended to the `saved_lanczos_vectors` list. The last Lanczos vector after the cycle, `lv[2]` contains garbage. Parameters ---------- lv : the 3 tuple of Wavefunctions. With the three Lanczos vectors in use. saved_lanczos_vectors : a list of Wavefunctions. The Lanczos vectors that are saved. """ saved_lanczos_vectors.append(lv[0]) lv[0], lv[1], lv[2] = lv[1], lv[2], create_empty_like(lv[2])