mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-07 22:53:41 +01: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
|
in
|
||||||
let n_alfa = Array.length a in
|
let n_alfa = Array.length a in
|
||||||
let n_beta = Array.length b 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 *)
|
(** Array of (list of singles, list of doubles) in the beta spin *)
|
||||||
let degree_bb =
|
let degree_bb =
|
||||||
@ -123,9 +116,14 @@ let create_matrix_spin f det_space =
|
|||||||
let a = Array.to_list a
|
let a = Array.to_list a
|
||||||
and b = Array.to_list b
|
and b = Array.to_list b
|
||||||
in
|
in
|
||||||
let i = ref 0 in
|
let task i_alfa =
|
||||||
List.iteri (fun ia i_alfa ->
|
let result = Array.init n_beta (fun _ -> []) in
|
||||||
Printf.eprintf "%8d / %8d\r%!" ia n_alfa;
|
(** 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 j = ref 1 in
|
||||||
let deg_a = Spindeterminant.degree i_alfa in
|
let deg_a = Spindeterminant.degree i_alfa in
|
||||||
List.iter (fun j_alfa ->
|
List.iter (fun j_alfa ->
|
||||||
@ -133,7 +131,7 @@ let create_matrix_spin f det_space =
|
|||||||
begin
|
begin
|
||||||
match degree_a with
|
match degree_a with
|
||||||
| 2 ->
|
| 2 ->
|
||||||
let i' = ref !i in
|
let i' = ref 0 in
|
||||||
List.iteri (fun ib i_beta ->
|
List.iteri (fun ib i_beta ->
|
||||||
let ki = Determinant.of_spindeterminants i_alfa i_beta in
|
let ki = Determinant.of_spindeterminants i_alfa i_beta in
|
||||||
let kj = Determinant.of_spindeterminants j_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';
|
incr i';
|
||||||
) b;
|
) b;
|
||||||
| 1 ->
|
| 1 ->
|
||||||
let i' = ref !i in
|
let i' = ref 0 in
|
||||||
List.iteri (fun ib i_beta ->
|
List.iteri (fun ib i_beta ->
|
||||||
let ki = Determinant.of_spindeterminants i_alfa i_beta in
|
let ki = Determinant.of_spindeterminants i_alfa i_beta in
|
||||||
let singles, _ = degree_bb.(ib) in
|
let singles, _ = degree_bb.(ib) in
|
||||||
@ -152,7 +150,7 @@ let create_matrix_spin f det_space =
|
|||||||
incr i';
|
incr i';
|
||||||
) b;
|
) b;
|
||||||
| 0 ->
|
| 0 ->
|
||||||
let i' = ref !i in
|
let i' = ref 0 in
|
||||||
List.iteri (fun ib i_beta ->
|
List.iteri (fun ib i_beta ->
|
||||||
let ki = Determinant.of_spindeterminants i_alfa i_beta in
|
let ki = Determinant.of_spindeterminants i_alfa i_beta in
|
||||||
let _singles, doubles = degree_bb.(ib) in
|
let _singles, doubles = degree_bb.(ib) in
|
||||||
@ -166,13 +164,22 @@ let create_matrix_spin f det_space =
|
|||||||
end;
|
end;
|
||||||
j := !j + n_beta
|
j := !j + n_beta
|
||||||
) a;
|
) 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
|
i := !i + n_beta
|
||||||
) a;
|
) a;
|
||||||
|
Matrix.sparse_of_vector_array result
|
||||||
Array.map (fun l ->
|
|
||||||
List.rev l
|
|
||||||
|> Vector.sparse_of_assoc_list ndet ) result
|
|
||||||
|> Matrix.sparse_of_vector_array
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user