1Matrix(3)             User Contributed Perl Documentation            Matrix(3)
2
3
4

NAME

6       PDL::Matrix -- a convenience matrix class for column-major access
7

VERSION

9       This document refers to version PDL::Matrix 0.5 of PDL::Matrix
10

SYNOPSIS

12         use PDL::Matrix;
13
14         $m = mpdl [[1,2,3],[4,5,6]];
15         $m = PDL::Matrix->pdl([[1,2,3],[4,5,6]]);
16         $m = msequence(4,3);
17         @dimsa = $x->mdims; # 'dims' is not overloaded
18
19         $v = vpdl [0,1,2,3]
20         $v = vzeroes(4);
21

DESCRIPTION

23   Overview
24       This package tries to help people who want to use PDL for 2D matrix
25       computation with lots of indexing involved. It provides a PDL subclass
26       so one- and two-dimensional ndarrays that are used as vectors resp and
27       matrices can be typed in using traditional matrix convention.
28
29       If you want to know more about matrix operation support in PDL, you
30       want to read PDL::MatrixOps or PDL::Slatec.
31
32       The original pdl class refers to the first index as the first row, the
33       second index as the first column of a matrix. Consider
34
35         print $B = sequence(3,2)
36         [
37          [0 1 2]
38          [3 4 5]
39         ]
40
41       which gives a 2x3 matrix in terms of the matrix convention, but the
42       constructor used (3,2). This might get more confusing when using slices
43       like sequence(3,2)->slice("1:2,(0)") : with traditional matrix
44       convention one would expect [2 4] instead of [1 2].
45
46       This subclass PDL::Matrix overloads the constructors and indexing
47       functions of pdls so that they are compatible with the usual matrix
48       convention, where the first dimension refers to the row of a matrix. So
49       now, the above example would be written as
50
51         print $B = PDL::Matrix->sequence(3,2) # or $B = msequence(3,2)
52         [
53          [0 1]
54          [2 3]
55          [4 5]
56         ]
57
58       Routines like eigens or inv can be used without any changes.
59
60       Furthermore one can construct and use vectors as n x 1 matrices without
61       mentioning the second index '1'.
62
63   Implementation
64       "PDL::Matrix" works by overloading a number of PDL constructors and
65       methods such that first and second args (corresponding to first and
66       second dims of corresponding matrices) are effectively swapped.  It is
67       not yet clear if PDL::Matrix achieves a consistent column-major look-
68       and-feel in this way.
69

NOTES

71       As of version 0.5 (rewrite by CED) the matrices are stored in the usual
72       way, just constructed and stringified differently.  That way indexing
73       and everything else works the way you think it should.
74

FUNCTIONS

76   mpdl, PDL::Matrix::pdl
77       constructs an object of class PDL::Matrix which is an ndarray child
78       class.
79
80           $m = mpdl [[1,2,3],[4,5,6]];
81           $m = PDL::Matrix->pdl([[1,2,3],[4,5,6]]);
82
83   mzeroes, mones, msequence
84       constructs a PDL::Matrix object similar to the ndarray constructors
85       zeroes, ones, sequence.
86
87   vpdl
88       constructs an object of class PDL::Matrix which is of matrix dimensions
89       (n x 1)
90
91           print $v = vpdl [0,1];
92           [
93            [0]
94            [1]
95           ]
96
97   vzeroes, vones, vsequence
98       constructs a PDL::Matrix object with matrix dimensions (n x 1),
99       therefore only the first scalar argument is used.
100
101           print $v = vsequence(2);
102           [
103            [0]
104            [1]
105           ]
106
107   kroneckerproduct
108       returns kroneckerproduct of two matrices. This is not efficiently
109       implemented.
110
111   det_general
112       returns a generalized determinant of a matrix. If the matrix is not
113       regular, one can specify the rank of the matrix and the corresponding
114       subdeterminant is returned. This is implemented using the "eigens"
115       function.
116
117   trace
118       returns the trace of a matrix (sum of diagonals)
119

BUGS AND PROBLEMS

121       Because we change the way ndarrays are constructed, not all pdl
122       operators may be applied to ndarray-matrices. The inner product is not
123       redefined. We might have missed some functions/methods. Internal
124       consistency of our approach needs yet to be established.
125
126       Because PDL::Matrix changes the way slicing behaves, it breaks many
127       operators, notably those in MatrixOps.
128

TODO

130       check all PDL functions, benchmarks, optimization, lots of other things
131       ...
132

AUTHOR(S)

134       Stephan Heuel (stephan@heuel.org), Christian Soeller
135       (c.soeller@auckland.ac.nz).
136
138       All rights reserved. There is no warranty. You are allowed to
139       redistribute this software / documentation under certain conditions.
140       For details, see the file COPYING in the PDL distribution. If this file
141       is separated from the PDL distribution, the copyright notice should be
142       included in the file.
143
144
145
146perl v5.36.0                      2022-07-22                         Matrix(3)
Impressum