mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-22 20:33:36 +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
|
||||
|> Vector.of_bigarray_inplace
|
||||
|
||||
(*
|
||||
let col t j =
|
||||
Mat.col t j
|
||||
|> Vector.of_bigarray
|
||||
*)
|
||||
let transpose t =
|
||||
Mat.transpose_copy t
|
||||
|
||||
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 =
|
||||
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
|
||||
(** 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
|
||||
(** Takes an upper-triangular matrix, and makes it a symmetric matrix
|
||||
by mirroring the defined triangle along the diagonal. *)
|
||||
|
Loading…
Reference in New Issue
Block a user