mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-08-30 16:23:41 +02:00
Reduced memory in fci
This commit is contained in:
parent
5540db632c
commit
59a51737e7
43
CI/CI.ml
43
CI/CI.ml
@ -86,14 +86,7 @@ let create_matrix_spin f det_space =
|
||||
in
|
||||
let n_alfa = Array.length a in
|
||||
let n_beta = Array.length b in
|
||||
let result = Array.init ndet (fun _ -> []) in
|
||||
|
||||
(** Update function when ki and kj are connected *)
|
||||
let update i j ki kj =
|
||||
let x = f ki kj in
|
||||
if abs_float x > Constants.epsilon then
|
||||
result.(i) <- (j, x) :: result.(i) ;
|
||||
in
|
||||
|
||||
(** Array of (list of singles, list of doubles) in the beta spin *)
|
||||
let degree_bb =
|
||||
@ -123,9 +116,14 @@ let create_matrix_spin f det_space =
|
||||
let a = Array.to_list a
|
||||
and b = Array.to_list b
|
||||
in
|
||||
let i = ref 0 in
|
||||
List.iteri (fun ia i_alfa ->
|
||||
Printf.eprintf "%8d / %8d\r%!" ia n_alfa;
|
||||
let task i_alfa =
|
||||
let result = Array.init n_beta (fun _ -> []) in
|
||||
(** Update function when ki and kj are connected *)
|
||||
let update i j ki kj =
|
||||
let x = f ki kj in
|
||||
if abs_float x > Constants.epsilon then
|
||||
result.(i) <- (j, x) :: result.(i) ;
|
||||
in
|
||||
let j = ref 1 in
|
||||
let deg_a = Spindeterminant.degree i_alfa in
|
||||
List.iter (fun j_alfa ->
|
||||
@ -133,7 +131,7 @@ let create_matrix_spin f det_space =
|
||||
begin
|
||||
match degree_a with
|
||||
| 2 ->
|
||||
let i' = ref !i in
|
||||
let i' = ref 0 in
|
||||
List.iteri (fun ib i_beta ->
|
||||
let ki = Determinant.of_spindeterminants i_alfa i_beta in
|
||||
let kj = Determinant.of_spindeterminants j_alfa i_beta in
|
||||
@ -141,7 +139,7 @@ let create_matrix_spin f det_space =
|
||||
incr i';
|
||||
) b;
|
||||
| 1 ->
|
||||
let i' = ref !i in
|
||||
let i' = ref 0 in
|
||||
List.iteri (fun ib i_beta ->
|
||||
let ki = Determinant.of_spindeterminants i_alfa i_beta in
|
||||
let singles, _ = degree_bb.(ib) in
|
||||
@ -152,7 +150,7 @@ let create_matrix_spin f det_space =
|
||||
incr i';
|
||||
) b;
|
||||
| 0 ->
|
||||
let i' = ref !i in
|
||||
let i' = ref 0 in
|
||||
List.iteri (fun ib i_beta ->
|
||||
let ki = Determinant.of_spindeterminants i_alfa i_beta in
|
||||
let _singles, doubles = degree_bb.(ib) in
|
||||
@ -166,13 +164,22 @@ let create_matrix_spin f det_space =
|
||||
end;
|
||||
j := !j + n_beta
|
||||
) a;
|
||||
Array.map (fun l ->
|
||||
List.rev l
|
||||
|> Vector.sparse_of_assoc_list ndet
|
||||
) result
|
||||
in
|
||||
let result =
|
||||
Array.init ndet (fun _ -> Vector.sparse_of_assoc_list 0 [])
|
||||
in
|
||||
let i = ref 0 in
|
||||
List.iteri (fun ia i_alfa ->
|
||||
task i_alfa
|
||||
|> Array.iteri (fun j x -> result.(!i+j) <- x);
|
||||
Printf.eprintf "%8d / %8d\r%!" (ia+1) n_alfa;
|
||||
i := !i + n_beta
|
||||
) a;
|
||||
|
||||
Array.map (fun l ->
|
||||
List.rev l
|
||||
|> Vector.sparse_of_assoc_list ndet ) result
|
||||
|> Matrix.sparse_of_vector_array
|
||||
Matrix.sparse_of_vector_array result
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user