10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-22 04:13:33 +01:00

Optimized Zkey

This commit is contained in:
Anthony Scemama 2018-01-20 12:10:32 +01:00
parent 1eadca79b3
commit e4786b7765
4 changed files with 57 additions and 42 deletions

View File

@ -57,7 +57,6 @@ let compute_norm_coef s =
result
) s.expo
let create ~indice ~expo ~coef ~center ~totAngMom =
assert (Array.length expo = Array.length coef);
assert (Array.length expo > 0);

View File

@ -206,7 +206,7 @@ let contracted_class ~zero_m shell_a shell_b shell_c shell_d : float Zmap.t =
shell_p.(ab).Shell_pair.coef *. shell_q.(cd).Shell_pair.coef
in
(** Screening on thr product of coefficients *)
if (abs_float coef_prod) > cutoff then
if (abs_float coef_prod) > 1.e-4*.cutoff then
begin
let expo_pq_inv =

View File

@ -4,7 +4,8 @@ INCLUDE_DIRS=Nuclei,Utils,Basis
LIBS=
PKGS=
OCAMLCFLAGS="-g -warn-error A"
OCAMLBUILD=ocamlbuild -j 0 -cflags $(OCAMLCFLAGS) -lflags $(OCAMLCFLAGS) -Is $(INCLUDE_DIRS)
OCAMLCFLAGS="-g"
OCAMLBUILD=ocamlbuild -j 0 -cflags $(OCAMLCFLAGS) -lflags $(OCAMLCFLAGS) -Is $(INCLUDE_DIRS) #-ocamlopt "opt -rounds 2"
MLLFILES=$(wildcard */*.mll) $(wildcard *.mll)
MLYFILES=$(wildcard */*.mly) $(wildcard *.mly)
MLFILES= $(wildcard */*.ml) $(wildcard *.ml)
@ -32,7 +33,7 @@ doc: qpackage.odocl
$(OCAMLBUILD) $*.byte -use-ocamlfind $(PKGS)
ln -s $*.byte $*
%.native: $(MLFILES) $(MLIFILES) $(MLLFILES) $(MLYFILES) %.byte
%.native: $(MLFILES) $(MLIFILES) $(MLLFILES) $(MLYFILES)
rm -f -- $*
$(OCAMLBUILD) $*.native -use-ocamlfind $(PKGS)
ln -s $*.native $*

View File

@ -1,6 +1,5 @@
(** Key for hastables that contain tuples of integers encoded in a Zarith integer *)
include Z
type kind_array =
| Kind_3
@ -89,46 +88,59 @@ let of_int_tuple a =
in a <| b
let mask10 = Int64.of_int 0x3ff
and mask16 = Int64.of_int 0xffff
(** Transform the Zkey into an int array *)
let to_int_array ~kind a =
let open Int64 in
match kind with
| Kind_3 -> [| Z.to_int @@ Z.extract a 20 10 ;
Z.to_int @@ Z.extract a 10 10 ;
Z.to_int @@ Z.extract a 0 10 |]
| Kind_6 -> [| Z.to_int @@ Z.extract a 50 10 ;
Z.to_int @@ Z.extract a 40 10 ;
Z.to_int @@ Z.extract a 30 10 ;
Z.to_int @@ Z.extract a 20 10 ;
Z.to_int @@ Z.extract a 10 10 ;
Z.to_int @@ Z.extract a 0 10 |]
| Kind_12 -> [| Z.to_int @@ Z.extract a 114 10 ;
Z.to_int @@ Z.extract a 104 10 ;
Z.to_int @@ Z.extract a 94 10 ;
Z.to_int @@ Z.extract a 84 10 ;
Z.to_int @@ Z.extract a 74 10 ;
Z.to_int @@ Z.extract a 64 10 ;
Z.to_int @@ Z.extract a 50 10 ;
Z.to_int @@ Z.extract a 40 10 ;
Z.to_int @@ Z.extract a 30 10 ;
Z.to_int @@ Z.extract a 20 10 ;
Z.to_int @@ Z.extract a 10 10 ;
Z.to_int @@ Z.extract a 0 10 |]
| Kind_9 -> [| Z.to_int @@ Z.extract a 84 10 ;
Z.to_int @@ Z.extract a 74 10 ;
Z.to_int @@ Z.extract a 64 10 ;
Z.to_int @@ Z.extract a 50 10 ;
Z.to_int @@ Z.extract a 40 10 ;
Z.to_int @@ Z.extract a 30 10 ;
Z.to_int @@ Z.extract a 20 10 ;
Z.to_int @@ Z.extract a 10 10 ;
Z.to_int @@ Z.extract a 0 10 |]
| Kind_4 -> [| Z.to_int @@ Z.extract a 48 16 ;
Z.to_int @@ Z.extract a 32 16 ;
Z.to_int @@ Z.extract a 16 16 ;
Z.to_int @@ Z.extract a 0 16 |]
| Kind_2 -> [| Z.to_int @@ Z.extract a 16 16 ;
Z.to_int @@ Z.extract a 0 16 |]
| Kind_1 -> [| Z.to_int a |]
| Kind_3 -> let x = Z.to_int64 a in
[| to_int ( logand mask10 (shift_right x 20)) ;
to_int ( logand mask10 (shift_right x 10)) ;
to_int ( logand mask10 x) |]
| Kind_6 -> let x = Z.to_int64 a in
[| to_int ( logand mask10 (shift_right x 50)) ;
to_int ( logand mask10 (shift_right x 40)) ;
to_int ( logand mask10 (shift_right x 30)) ;
to_int ( logand mask10 (shift_right x 20)) ;
to_int ( logand mask10 (shift_right x 10)) ;
to_int ( logand mask10 x) |]
| Kind_12 -> let x = Z.to_int64 @@ Z.extract a 0 60
and y = Z.to_int64 @@ Z.extract a 64 60
in
[| to_int ( logand mask10 (shift_right y 114)) ;
to_int ( logand mask10 (shift_right y 104)) ;
to_int ( logand mask10 (shift_right y 94)) ;
to_int ( logand mask10 (shift_right y 84)) ;
to_int ( logand mask10 (shift_right y 74)) ;
to_int ( logand mask10 (shift_right y 64)) ;
to_int ( logand mask10 (shift_right x 50)) ;
to_int ( logand mask10 (shift_right x 40)) ;
to_int ( logand mask10 (shift_right x 30)) ;
to_int ( logand mask10 (shift_right x 20)) ;
to_int ( logand mask10 (shift_right x 10)) ;
to_int ( logand mask10 x) |]
| Kind_9 -> let x = Z.to_int64 @@ Z.extract a 0 60
and y = Z.to_int64 @@ Z.extract a 64 60
in
[| to_int ( logand mask10 (shift_right y 84)) ;
to_int ( logand mask10 (shift_right y 74)) ;
to_int ( logand mask10 (shift_right y 64)) ;
to_int ( logand mask10 (shift_right x 50)) ;
to_int ( logand mask10 (shift_right x 40)) ;
to_int ( logand mask10 (shift_right x 30)) ;
to_int ( logand mask10 (shift_right x 20)) ;
to_int ( logand mask10 (shift_right x 10)) ;
to_int ( logand mask10 x) |]
| Kind_4 -> let x = Z.to_int64 a in
[| to_int ( logand mask16 (shift_right x 48)) ;
to_int ( logand mask16 (shift_right x 32)) ;
to_int ( logand mask16 (shift_right x 16)) ;
to_int ( logand mask16 x) |]
| Kind_2 -> let x = Z.to_int64 a in
[| to_int ( logand mask16 (shift_right x 16)) ;
to_int ( logand mask16 x) |]
| Kind_1 -> [| Z.to_int a |]
let to_string ~kind a =
@ -187,6 +199,9 @@ let to_int_tuple ~kind a =
| Kind_1 -> One ( Z.to_int a )
include Z
(*
let debug () =
let k2 = of_int_array Kind_2 [| 1 ; 2 |]