From 86ad2012fd3e9443c9799b5b46e585224253beae Mon Sep 17 00:00:00 2001
From: Oren Ben-Kiki
Date: Sat, 1 Jun 2024 18:33:21 +0300
Subject: [PATCH] Factor out transpose!.
---
docs/v0.1.0/.documenter-siteinfo.json | 2 +-
docs/v0.1.0/index.html | 18 ++-
docs/v0.1.0/matrix_layouts.html | 99 +++++++++++++++-
docs/v0.1.0/objects.inv | Bin 4164 -> 4194 bytes
docs/v0.1.0/read_only.html | 64 -----------
docs/v0.1.0/search_index.js | 2 +-
src/matrix_layouts.jl | 158 +++++++++++++++++++++-----
src/matrix_layouts.md | 2 +
src/operations.jl | 2 +-
src/queries.jl | 1 +
src/read_only.jl | 83 +-------------
src/read_only.md | 1 -
test/matrix_layouts.jl | 20 ++++
13 files changed, 267 insertions(+), 185 deletions(-)
diff --git a/docs/v0.1.0/.documenter-siteinfo.json b/docs/v0.1.0/.documenter-siteinfo.json
index 00ffee0..7a47f83 100644
--- a/docs/v0.1.0/.documenter-siteinfo.json
+++ b/docs/v0.1.0/.documenter-siteinfo.json
@@ -1 +1 @@
-{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-06-01T14:35:03","documenter_version":"1.4.1"}}
\ No newline at end of file
+{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-06-01T18:28:22","documenter_version":"1.4.1"}}
\ No newline at end of file
diff --git a/docs/v0.1.0/index.html b/docs/v0.1.0/index.html
index 5ba150b..d8cd432 100644
--- a/docs/v0.1.0/index.html
+++ b/docs/v0.1.0/index.html
@@ -1712,6 +1712,12 @@
+
+Daf.MatrixLayouts.copy_array
+
+
+
+
Daf.MatrixLayouts.depict
@@ -1868,12 +1874,6 @@
-
-Daf.ReadOnly.copy_array
-
-
-
-
Daf.ReadOnly.is_read_only_array
@@ -2162,6 +2162,12 @@
+
+LinearAlgebra.transpose!
+
+
+
+
Daf.Computations.@computation
diff --git a/docs/v0.1.0/matrix_layouts.html b/docs/v0.1.0/matrix_layouts.html
index 290dd3b..a132f0b 100644
--- a/docs/v0.1.0/matrix_layouts.html
+++ b/docs/v0.1.0/matrix_layouts.html
@@ -576,8 +576,10 @@
, summing the UMIs of a gene is fast, and summing the UMIs of a cell is slow.
In contrast,
+
transpose!
-
(with a
+
+ (with a
!
) is slow; it creates a rearranged copy of the data, also returning a matrix whose rows are genes and columns are cells, but this time, in column-major layout. Therefore, in this case summing the UMIs of a gene will be slow, and summing the UMIs of a cell will be fast.
@@ -650,6 +652,89 @@
+
+
+
+
+
+transpose!(matrix::AbstractMatrix)::AbstractMatrix
+transpose!(matrix::NamedMatrix)::NamedMatrix
+
+
+
This is a shorthand for
+LinearAlgebra.transpose!(similar(transpose(m)), m)
+
. That is, this will return a transpose of a matrix, but instead of simply using a zero-copy wrapper, it actually rearranges the data. See
+
+relayout!
+
+.
+
+
+
+
+
+
+
+
+
+copy_array(array::AbstractArray)::AbstractArray
+
+
+
Create a mutable copy of an array. This differs from
+Base.copy
+
in the following:
+
+
+- Copying a read-only array is a mutable array. In contrast, both
+
Base.copy
+
and
+Base.deepcopy
+
of a read-only array will return a read-only array, which is technically correct, but is rather pointless for
+Base.copy
+
.
+
+- Copying will preserve the layout of the data; for example, copying a
+
Transpose
+
array is still a
+Transpose
+
array. In contrast, while
+Base.deepcopy
+
will preserve the layout,
+Base.copy
+
will silently
+
+relayout!
+
+ the matrix, which is both expensive and confusing.
+
+- Copying a sparse vector or matrix gives the same type of sparse array or matrix. Copying anything else gives a simple dense array regardless of the original type. This is done because a
+
deepcopy
+
of
+PyArray
+
will still share the underlying buffer. Sigh.
+
+
+
+
+
+
+Daf.MatrixLayouts.copy_array
+
+
+
+
Daf.MatrixLayouts.inefficient_action_handler
@@ -830,6 +921,12 @@
+
+
+LinearAlgebra.transpose!
+
+
+