10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-06-02 11:25:19 +02:00
QCaml/Basis/Orthonormalization.ml

49 lines
939 B
OCaml
Raw Normal View History

2018-02-23 18:44:31 +01:00
open Util
open Lacaml.D
type t =
| Lowdin of Mat.t
| Canonical of Mat.t
| Svd of Mat.t
let make_canonical ~cartesian ~thresh ~overlap =
let result =
if cartesian then
canonical_ortho ~thresh ~overlap (Mat.identity @@ Mat.dim1 overlap)
else
(* TODO *)
canonical_ortho ~thresh ~overlap (Mat.identity @@ Mat.dim1 overlap)
in
Canonical result
let make_lowdin ~thresh ~overlap =
2018-02-23 18:44:31 +01:00
let u_vec, u_val = diagonalize_symm overlap in
Vec.iter (fun x -> if x < thresh then
2018-02-25 00:53:09 +01:00
invalid_arg (__FILE__^": make_lowdin") ) u_val;
2018-02-23 18:44:31 +01:00
let u_val = Vec.reci (Vec.sqrt u_val) in
let u_vec' =
Mat.init_cols (Mat.dim1 u_vec) (Mat.dim2 u_vec) (fun i j -> u_vec.{i,j} *. u_val.{j})
in
let result =
gemm u_vec' ~transb:`T u_vec
in
Lowdin result
let make ~cartesian ?(thresh=1.e-12) overlap =
(*
make_lowdin ~thresh ~overlap
*)
make_canonical ~cartesian ~thresh ~overlap