summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Matrix.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index 77906dc..605a6f3 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -48,12 +48,14 @@ import Data.List(transpose)
48- we could carry both the matrix and its (lazily computed) transpose. 48- we could carry both the matrix and its (lazily computed) transpose.
49 This may save some transpositions, but it is necessary to keep track of the 49 This may save some transpositions, but it is necessary to keep track of the
50 data which is actually computed to be used by functions like the matrix product 50 data which is actually computed to be used by functions like the matrix product
51 which admit both orders. Therefore, maybe it is better to have something like 51 which admit both orders.
52 viewC and viewF, which may actually perform a transpose if required.
53 52
54- but if we need the transposed data and it is not in the structure, we must make 53- but if we need the transposed data and it is not in the structure, we must make
55 sure that we touch the same foreignptr that is used in the computation. Access 54 sure that we touch the same foreignptr that is used in the computation.
56 to such pointer cannot be made by creating a new vector. 55
56- a reasonable solution is using two constructors for a matrix. Transposition just
57 "flips" the constructor. Actual data transposition is not done if followed by a
58 matrix product or another transpose.
57 59
58-} 60-}
59 61
@@ -66,7 +68,7 @@ data Matrix t = MC { rows :: Int, cols :: Int, cdat :: Vector t, fdat :: Vector
66-- MC: preferred by C, fdat may require a transposition 68-- MC: preferred by C, fdat may require a transposition
67-- MF: preferred by LAPACK, cdat may require a transposition 69-- MF: preferred by LAPACK, cdat may require a transposition
68 70
69-- | matrix transpose 71-- | Matrix transpose.
70trans :: Matrix t -> Matrix t 72trans :: Matrix t -> Matrix t
71trans MC {rows = r, cols = c, cdat = d, fdat = dt } = MF {rows = c, cols = r, fdat = d, cdat = dt } 73trans MC {rows = r, cols = c, cdat = d, fdat = dt } = MF {rows = c, cols = r, fdat = d, cdat = dt }
72trans MF {rows = r, cols = c, fdat = d, cdat = dt } = MC {rows = c, cols = r, cdat = d, fdat = dt } 74trans MF {rows = r, cols = c, fdat = d, cdat = dt } = MC {rows = c, cols = r, cdat = d, fdat = dt }