mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-07 06:33:39 +01:00
30 lines
552 B
OCaml
30 lines
552 B
OCaml
|
open Util
|
||
|
open Lacaml.D
|
||
|
|
||
|
type t =
|
||
|
| Lowdin of Mat.t
|
||
|
| Canonical of Mat.t
|
||
|
| Svd of Mat.t
|
||
|
|
||
|
|
||
|
let make_lowdin ?(thresh=1.e-12) ~overlap =
|
||
|
|
||
|
let u_vec, u_val = diagonalize_symm overlap in
|
||
|
|
||
|
Vec.iter (fun x -> if x < thresh then
|
||
|
invalid_arg "Orthonormalization.make_lowdin") u_val;
|
||
|
|
||
|
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 = make_lowdin
|