mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-09-01 17:23:41 +02:00
Commented non-inplace
This commit is contained in:
parent
fe7cd2c550
commit
6d37fe69bd
@ -177,7 +177,7 @@ let to_file ~filename kinetic =
|
|||||||
Matrix.dim1 kinetic
|
Matrix.dim1 kinetic
|
||||||
in
|
in
|
||||||
|
|
||||||
let kinetic_x = Matrix.to_bigarray kinetic in
|
let kinetic_x = Matrix.to_bigarray_inplace kinetic in
|
||||||
for j=1 to n do
|
for j=1 to n do
|
||||||
for i=1 to j do
|
for i=1 to j do
|
||||||
if (abs_float kinetic_x.{i,j} > cutoff) then
|
if (abs_float kinetic_x.{i,j} > cutoff) then
|
||||||
|
@ -630,7 +630,7 @@ let contracted_class_shell_pairs ?operator ~zero_m ?schwartz_p ?schwartz_q shell
|
|||||||
let coef =
|
let coef =
|
||||||
Matrix.outer_product (Vector.of_array @@ cq) (Vector.of_array @@ cp)
|
Matrix.outer_product (Vector.of_array @@ cq) (Vector.of_array @@ cp)
|
||||||
in
|
in
|
||||||
let coefx = Matrix.to_bigarray coef in
|
let coefx = Matrix.to_bigarray_inplace coef in
|
||||||
|
|
||||||
let zm_array = Matrix.init_cols np nq (fun i j ->
|
let zm_array = Matrix.init_cols np nq (fun i j ->
|
||||||
try
|
try
|
||||||
|
@ -271,7 +271,7 @@ let get_chem_all_ij d ~k ~l =
|
|||||||
if k = l then
|
if k = l then
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
Matrix.col d.three_index k
|
Matrix.col_inplace d.three_index k
|
||||||
|> Vector.to_bigarray_inplace
|
|> Vector.to_bigarray_inplace
|
||||||
|> Bigarray.genarray_of_array1
|
|> Bigarray.genarray_of_array1
|
||||||
in
|
in
|
||||||
@ -284,7 +284,7 @@ let get_chem_all_ij d ~k ~l =
|
|||||||
| Dense a ->
|
| Dense a ->
|
||||||
let kl = sym_index k l in
|
let kl = sym_index k l in
|
||||||
let result =
|
let result =
|
||||||
Matrix.col a kl
|
Matrix.col_inplace a kl
|
||||||
|> Vector.to_bigarray_inplace
|
|> Vector.to_bigarray_inplace
|
||||||
|> Bigarray.genarray_of_array1
|
|> Bigarray.genarray_of_array1
|
||||||
in
|
in
|
||||||
|
@ -58,17 +58,24 @@ let reshape a m n =
|
|||||||
in
|
in
|
||||||
Bigarray.reshape_2 b m n
|
Bigarray.reshape_2 b m n
|
||||||
|
|
||||||
|
let col_inplace t j =
|
||||||
|
Mat.col t j
|
||||||
|
|> Vector.of_bigarray_inplace
|
||||||
|
|
||||||
|
(*
|
||||||
let col t j =
|
let col t j =
|
||||||
Mat.col t j
|
Mat.col t j
|
||||||
|> Vector.of_bigarray
|
|> Vector.of_bigarray
|
||||||
|
*)
|
||||||
|
|
||||||
|
|
||||||
let to_col_vecs t =
|
let to_col_vecs t =
|
||||||
Mat.to_col_vecs t
|
Mat.to_col_vecs t
|
||||||
|> Array.map Vector.of_bigarray
|
|> Array.map Vector.of_bigarray_inplace
|
||||||
|
|
||||||
let to_col_vecs_list t =
|
let to_col_vecs_list t =
|
||||||
Mat.to_col_vecs_list t
|
Mat.to_col_vecs_list t
|
||||||
|> List.rev_map Vector.of_bigarray
|
|> List.rev_map Vector.of_bigarray_inplace
|
||||||
|> List.rev
|
|> List.rev
|
||||||
|
|
||||||
let detri_inplace t =
|
let detri_inplace t =
|
||||||
@ -169,7 +176,7 @@ let diagonalize_symm m_H =
|
|||||||
let m_V = lacpy m_H in
|
let m_V = lacpy m_H in
|
||||||
let result =
|
let result =
|
||||||
syevd ~vectors:true m_V
|
syevd ~vectors:true m_V
|
||||||
|> Vector.of_bigarray
|
|> Vector.of_bigarray_inplace
|
||||||
in
|
in
|
||||||
m_V, result
|
m_V, result
|
||||||
|
|
||||||
@ -214,7 +221,7 @@ let debug_matrix name a =
|
|||||||
Format.printf "@[%s =\n@[%a@]@]@." name pp a
|
Format.printf "@[%s =\n@[%a@]@]@." name pp a
|
||||||
|
|
||||||
let outer_product_inplace m ?(alpha=1.0) u v =
|
let outer_product_inplace m ?(alpha=1.0) u v =
|
||||||
ger ~alpha (Vector.to_bigarray u) (Vector.to_bigarray v) m
|
ger ~alpha (Vector.to_bigarray_inplace u) (Vector.to_bigarray_inplace v) m
|
||||||
|
|
||||||
let outer_product ?(alpha=1.0) u v =
|
let outer_product ?(alpha=1.0) u v =
|
||||||
let m = make0 (Vector.dim u) (Vector.dim v) in
|
let m = make0 (Vector.dim u) (Vector.dim v) in
|
||||||
@ -267,12 +274,12 @@ let copy_inplace ?m ?n ?br ?bc ~b ?ar ?ac a =
|
|||||||
ignore @@ lacpy ?m ?n ?br ?bc ~b ?ar ?ac a
|
ignore @@ lacpy ?m ?n ?br ?bc ~b ?ar ?ac a
|
||||||
|
|
||||||
let scale_cols_inplace a v =
|
let scale_cols_inplace a v =
|
||||||
Vector.to_bigarray v
|
Vector.to_bigarray_inplace v
|
||||||
|> Mat.scal_cols a
|
|> Mat.scal_cols a
|
||||||
|
|
||||||
let scale_cols a v =
|
let scale_cols a v =
|
||||||
let a' = copy a in
|
let a' = copy a in
|
||||||
Vector.to_bigarray v
|
Vector.to_bigarray_inplace v
|
||||||
|> Mat.scal_cols a' ;
|
|> Mat.scal_cols a' ;
|
||||||
a'
|
a'
|
||||||
|
|
||||||
@ -281,13 +288,13 @@ let svd a =
|
|||||||
let d, u, vt =
|
let d, u, vt =
|
||||||
gesvd (lacpy a)
|
gesvd (lacpy a)
|
||||||
in
|
in
|
||||||
u, (Vector.of_bigarray d), vt
|
u, (Vector.of_bigarray_inplace d), vt
|
||||||
|
|
||||||
let svd_t a =
|
let svd' a =
|
||||||
let d, u, vt =
|
let d, u, vt =
|
||||||
gesvd (lacpy a)
|
gesvd (lacpy a)
|
||||||
in
|
in
|
||||||
u, (Vector.of_bigarray d), vt
|
u, (Vector.of_bigarray_inplace d), vt
|
||||||
|
|
||||||
|
|
||||||
let qr a =
|
let qr a =
|
||||||
|
@ -68,13 +68,22 @@ val div_inplace : c:('a,'b) t -> ('a,'b) t -> ('a,'b) t -> unit
|
|||||||
val at : ('a,'b) t -> int -> int -> float
|
val at : ('a,'b) t -> int -> int -> float
|
||||||
(** [at i j] returns the element at i,j. *)
|
(** [at i j] returns the element at i,j. *)
|
||||||
|
|
||||||
|
(*
|
||||||
val to_bigarray : ('a,'b) t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t
|
val to_bigarray : ('a,'b) t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t
|
||||||
(** Converts the matrix into a Bigarray in Fortran layout *)
|
(** Converts the matrix into a Bigarray in Fortran layout *)
|
||||||
|
|
||||||
|
val of_bigarray : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t -> ('a,'b) t
|
||||||
|
(** Converts a [Bigarray.Array2] in Fortran layout into a matrix *)
|
||||||
|
|
||||||
|
*)
|
||||||
val to_bigarray_inplace :
|
val to_bigarray_inplace :
|
||||||
('a,'b) t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t
|
('a,'b) t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t
|
||||||
(** Converts the matrix into a Bigarray in Fortran layout in place*)
|
(** Converts the matrix into a Bigarray in Fortran layout in place*)
|
||||||
|
|
||||||
|
val of_bigarray_inplace :
|
||||||
|
(float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t -> ('a,'b) t
|
||||||
|
(** Converts a [Bigarray.Array2] in Fortran layout into a matrix in place*)
|
||||||
|
|
||||||
val to_col_vecs : ('a,'b) t -> 'a Vector.t array
|
val to_col_vecs : ('a,'b) t -> 'a Vector.t array
|
||||||
(** Converts the matrix into an array of vectors *)
|
(** Converts the matrix into an array of vectors *)
|
||||||
|
|
||||||
@ -87,21 +96,19 @@ val of_col_vecs : 'a Vector.t array -> ('a,'b) t
|
|||||||
val of_col_vecs_list : 'a Vector.t list -> ('a,'b) t
|
val of_col_vecs_list : 'a Vector.t list -> ('a,'b) t
|
||||||
(** Converts a list of vectors into a matrix *)
|
(** Converts a list of vectors into a matrix *)
|
||||||
|
|
||||||
val of_bigarray : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t -> ('a,'b) t
|
|
||||||
(** Converts a [Bigarray.Array2] in Fortran layout into a matrix *)
|
|
||||||
|
|
||||||
val of_bigarray_inplace :
|
|
||||||
(float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t -> ('a,'b) t
|
|
||||||
(** Converts a [Bigarray.Array2] in Fortran layout into a matrix in place*)
|
|
||||||
|
|
||||||
val copy: ?m:int -> ?n:int -> ?br:int -> ?bc:int -> ?ar:int -> ?ac:int -> ('a,'b) t -> ('a,'b) t
|
val copy: ?m:int -> ?n:int -> ?br:int -> ?bc:int -> ?ar:int -> ?ac:int -> ('a,'b) t -> ('a,'b) t
|
||||||
(** Copies all or part of a two-dimensional matrix A to a new matrix B *)
|
(** Copies all or part of a two-dimensional matrix A to a new matrix B *)
|
||||||
|
|
||||||
val copy_inplace: ?m:int -> ?n:int -> ?br:int -> ?bc:int -> b:('a,'b) t -> ?ar:int -> ?ac:int -> ('a,'b) t -> unit
|
val copy_inplace: ?m:int -> ?n:int -> ?br:int -> ?bc:int -> b:('a,'b) t -> ?ar:int -> ?ac:int -> ('a,'b) t -> unit
|
||||||
(** Copies all or part of a two-dimensional matrix A to an existing matrix B *)
|
(** Copies all or part of a two-dimensional matrix A to an existing matrix B *)
|
||||||
|
|
||||||
|
(*
|
||||||
val col: ('a,'b) t -> int -> 'a Vector.t
|
val col: ('a,'b) t -> int -> 'a Vector.t
|
||||||
(** Returns a column of the matrix as a vector *)
|
(** Returns a column of the matrix as a vector *)
|
||||||
|
*)
|
||||||
|
|
||||||
|
val col_inplace: ('a,'b) t -> int -> 'a Vector.t
|
||||||
|
(** Returns a column of the matrix as a vector *)
|
||||||
|
|
||||||
val detri: ('a,'b) t -> ('a,'b) t
|
val detri: ('a,'b) t -> ('a,'b) t
|
||||||
(** Takes an upper-triangular matrix, and makes it a symmetric matrix
|
(** Takes an upper-triangular matrix, and makes it a symmetric matrix
|
||||||
@ -218,7 +225,7 @@ val gemm_tt_trace: ('b,'a) t -> ('c,'b) t -> float
|
|||||||
val svd: ('a,'b) t -> ('a,'b) t * 'b Vector.t * ('b,'b) t
|
val svd: ('a,'b) t -> ('a,'b) t * 'b Vector.t * ('b,'b) t
|
||||||
(** Singular value decomposition of A(m,n) when m >= n. *)
|
(** Singular value decomposition of A(m,n) when m >= n. *)
|
||||||
|
|
||||||
val svd_t: ('a,'b) t -> ('a,'a) t * 'a Vector.t * ('a,'b) t
|
val svd': ('a,'b) t -> ('a,'a) t * 'a Vector.t * ('a,'b) t
|
||||||
(** Singular value decomposition of A(m,n) when m < n. *)
|
(** Singular value decomposition of A(m,n) when m < n. *)
|
||||||
|
|
||||||
val qr: ('a,'b) t -> ('a,'b) t * ('b,'b) t
|
val qr: ('a,'b) t -> ('a,'b) t * ('b,'b) t
|
||||||
|
@ -10,7 +10,7 @@ let canonical_ortho ?thresh:(thresh=1.e-6) ~overlap c =
|
|||||||
if x >= thresh then 1. /. x
|
if x >= thresh then 1. /. x
|
||||||
else 0. ) d_sqrt
|
else 0. ) d_sqrt
|
||||||
in
|
in
|
||||||
let dx = Vector.to_bigarray d in
|
let dx = Vector.to_bigarray_inplace d in
|
||||||
if n < Vector.dim d_sqrt then
|
if n < Vector.dim d_sqrt then
|
||||||
Printf.printf "Removed linear dependencies below %f\n" (1. /. dx.{n})
|
Printf.printf "Removed linear dependencies below %f\n" (1. /. dx.{n})
|
||||||
;
|
;
|
||||||
|
@ -42,9 +42,12 @@ let to_list t = Vec.to_list t
|
|||||||
|
|
||||||
let make n x = Vec.make n x
|
let make n x = Vec.make n x
|
||||||
|
|
||||||
let of_bigarray_inplace t = t
|
(*
|
||||||
let of_bigarray t = copy t
|
let of_bigarray t = copy t
|
||||||
let to_bigarray t = copy t
|
let to_bigarray t = copy t
|
||||||
|
*)
|
||||||
|
|
||||||
|
let of_bigarray_inplace t = t
|
||||||
let to_bigarray_inplace t = t
|
let to_bigarray_inplace t = t
|
||||||
|
|
||||||
let random ?rnd_state ?(from= -. 1.0) ?(range=2.0) n =
|
let random ?rnd_state ?(from= -. 1.0) ?(range=2.0) n =
|
||||||
|
@ -121,11 +121,13 @@ val random : ?rnd_state:Random.State.t -> ?from:float -> ?range:float -> int ->
|
|||||||
%} where [f] is [from] and [r] is [range].
|
%} where [f] is [from] and [r] is [range].
|
||||||
Default values: [from:-1.0] [range:2.0] *)
|
Default values: [from:-1.0] [range:2.0] *)
|
||||||
|
|
||||||
|
(*
|
||||||
val of_bigarray : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t -> 'a t
|
val of_bigarray : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t -> 'a t
|
||||||
(** Builds by converting from a Fortran bigarray *)
|
(** Builds by converting from a Fortran bigarray *)
|
||||||
|
|
||||||
val to_bigarray : 'a t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t
|
val to_bigarray : 'a t -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t
|
||||||
(** Converts the vector into a Fortran bigarray *)
|
(** Converts the vector into a Fortran bigarray *)
|
||||||
|
*)
|
||||||
|
|
||||||
val of_bigarray_inplace : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t -> 'a t
|
val of_bigarray_inplace : (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t -> 'a t
|
||||||
(** Builds by converting from a Fortran bigarray *)
|
(** Builds by converting from a Fortran bigarray *)
|
||||||
|
Loading…
Reference in New Issue
Block a user