mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-18 20:12:26 +01:00
Added transpose
This commit is contained in:
parent
51b1d0d002
commit
b7add6b2b6
@ -68,12 +68,21 @@ let col_inplace t j =
|
|||||||
Mat.col t j
|
Mat.col t j
|
||||||
|> Vector.of_bigarray_inplace
|
|> Vector.of_bigarray_inplace
|
||||||
|
|
||||||
(*
|
let transpose t =
|
||||||
let col t j =
|
Mat.transpose_copy t
|
||||||
Mat.col t j
|
|
||||||
|> Vector.of_bigarray
|
|
||||||
*)
|
|
||||||
|
|
||||||
|
let transpose_inplace t =
|
||||||
|
let mat = to_bigarray_inplace t in
|
||||||
|
let d1 = dim1 t in
|
||||||
|
let d2 = dim2 t in
|
||||||
|
assert (d1 = d2);
|
||||||
|
for j=1 to d1 do
|
||||||
|
for i=1 to (j-1) do
|
||||||
|
let ij, ji = mat.{i,j}, mat.{j,i} in
|
||||||
|
mat.{i,j} <- ji;
|
||||||
|
mat.{j,i} <- ij
|
||||||
|
done;
|
||||||
|
done
|
||||||
|
|
||||||
let to_col_vecs t =
|
let to_col_vecs t =
|
||||||
Mat.to_col_vecs t
|
Mat.to_col_vecs t
|
||||||
|
@ -129,6 +129,12 @@ val col: ('a,'b) t -> int -> 'a Vector.t
|
|||||||
val col_inplace: ('a,'b) t -> int -> 'a Vector.t
|
val col_inplace: ('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 transpose: ('a,'b) t -> ('b,'a) t
|
||||||
|
(** Returns the transposed matrix *)
|
||||||
|
|
||||||
|
val transpose_inplace: ('a,'a) t -> unit
|
||||||
|
(** Transposes the matrix in place. *)
|
||||||
|
|
||||||
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
|
||||||
by mirroring the defined triangle along the diagonal. *)
|
by mirroring the defined triangle along the diagonal. *)
|
||||||
|
Loading…
Reference in New Issue
Block a user