### RFC: Getting Started with PDL (the Perl Data Language)

by lin0 (Curate)
 on Feb 02, 2007 at 20:06 UTC ( #598007=perlmeditation: print w/ replies, xml ) Need Help??

```perldl>? inv
```
```Module  PDL::MatrixOps
inv
...
are singular, they receive NaN entries.
```
```perldl>?? inverse
```
```perldl> ?? inverse
PDL::Transform::unmap ...
...
(2-D/3-D; with inverse)
t_spherical     Convert Cartesian to spherical coordinates.
(3-D; with inverse)
```
```perldl>?? invert
```
```inv             Invert a square matrix.
invert          Apply an inverse transformation to some
input coordinates.
```
```perldl>demo
```
```perldl>demo PDL
```
```----

...
in the demos by just retyping them at the perldl
command prompt.
---- (press enter)
```
```perldl> \$scalar_piddle = pdl 42
perldl> \$one_dimensional_piddle = pdl(1,2,3)
perldl> \$two_dimensional_piddle = pdl([1,2,3],[4,5,6])
```
```perldl> ? vars
```
```PDL variables in package main::

...
\$scalar_piddle Double D []                   P            0.01Kb
\$one_dimensional_piddle Double D [3]         P            0.02Kb
\$two_dimensional_piddle Double D [3,2]       P            0.05Kb
```
```perldl> \$pdl_of_zeroes = zeroes(10,2)
perldl> p \$pdl_of_zeroes
...
[0 0 1 0]
[0 0 0 1]
]
```
```perldl>\$new_pdl_of_zeroes  = zeroes(byte, 10, 2)
```
```perldl> ? vars
PDL variables in package main::
...
\$pdl_of_zeroes Double D [10,2]               P            0.16Kb
\$new_pdl_of_zeroes   Byte D [10,2]           P            0.02Kb
```
```+    -    *    /    **    >    <
>=   <=   ==   !=   <<    >>   &
|    ^    +=   -=   *=    /=   %=
**=  >>=  <<=  &=   |=    ^=
<=>  !    %    ++   --
```
```abs  acos  acosh asin asinh
atan atan2 atanh cos  cosh
sin  sinh  tan   tanh sqrt
ceil floor rint  exp  log log1
```
```perldl>\$pdl_of_zeroes = null;
```
```perldl>\$n = nelem(\$new_pdl_of_zeroes);
```
```perldl>\$n = \$new_pdl_of_zeroes->nelem();
```
```perldl>@dims = dims(\$new_pdl_of_zeroes);
```
```perldl>@dims = \$new_pdl_of_zeroes->dims;
```
```perldl>\$info = \$new_pdl_of_zeroes->info;
```
```    T      Type</li>
D      Formatted Dimensions
...
C      Class of this piddle, i.e. "ref \$pdl"
A      Address of the piddle struct as a unique identifier
M      Calculated memory consumption of this piddle's data area
```
```perldl> p \$new_pdl_of_zeroes->info("Mem : %M");
```
```Mem :   0.02Kb
```
```perldl> p \$piddle = sequence(10,12);
```
```[
[  0   1   2   3   4   5   6   7   8   9]
...
[100 101 102 103 104 105 106 107 108 109]
[110 111 112 113 114 115 116 117 118 119]
]
```
```perldl> p at(\$piddle, 5,3);
```
```perldl> p \$piddle->at(5,3);
```
```perldl> p \$slice_1a = slice(\$piddle, "0:2,-1");
```
```[
[110 111 112]
]
```
```perldl> p \$slice_1b = \$piddle->slice("0:2,-1");
```
```[
[110 111 112]
]
```
```perldl> p \$slice_2a = slice(\$piddle,"-1:-2,:");
```
```[
[  9   8]
...
[109 108]
[119 118]
]
```
```perldl> p \$slice_2b = \$piddle->slice("-1:-2,:");
```
```[
[  9   8]
...
[109 108]
[119 118]
]
```
```perldl> p \$second_column = \$piddle(1,:);
```
```[
[  1]
...
[101]
[111]
]
```
```perldl> p \$second_row = \$piddle(:,1);
```
```[
[10 11 12 13 14 15 16 17 18 19]
]
```
```perldl> p \$first_to_third_columns = \$piddle(0:2,:);
```
```[
[  0   1   2]
...
[100 101 102]
[110 111 112]
]
```
```perldl> p \$even_columns = \$piddle(0:-1:2,:);
```
```[
[  0   2   4   6   8]
...
[100 102 104 106 108]
[110 112 114 116 118]
]
```
```perldl> p \$odd_columns = \$piddle(1:-1:2,:);
```
```[
[  1   3   5   7   9]
...
[101 103 105 107 109]
[111 113 115 117 119]
]
```
```perldl> p \$even_rows = \$piddle(:,0:-1:2);
```
```[
[  0   1   2   3   4   5   6   7   8   9]
...
[ 80  81  82  83  84  85  86  87  88  89]
[100 101 102 103 104 105 106 107 108 109]
]
```
```perldl> p \$odd_rows = \$piddle(:,1:-1:2);
```
```[
[ 10  11  12  13  14  15  16  17  18  19]
...
[ 90  91  92  93  94  95  96  97  98  99]
[110 111 112 113 114 115 116 117 118 119]
]
```
```perldl> p \$one_element_slice = \$piddle(5,5);
```
```[
[55]
]
```
```perldl> p \$dice1 = dice(\$piddle, [1,3],[0,7]);
```
```[
[ 1  3]
[71 73]
]
```
```perldl> p \$dice2 = \$piddle->dice(X,[0,1,8]);
```
```[
[ 0  1  2  3  4  5  6  7  8  9]
[10 11 12 13 14 15 16 17 18 19]
[80 81 82 83 84 85 86 87 88 89]
]
```
```perldl> p \$dice2 .= -99;
```
```[
[-99 -99 -99 -99 -99 -99 -99 -99 -99 -99]
[-99 -99 -99 -99 -99 -99 -99 -99 -99 -99]
[-99 -99 -99 -99 -99 -99 -99 -99 -99 -99]
]
```
```perldl> p \$piddle

...
[100 101 102 103 104 105 106 107 108 109]
[110 111 112 113 114 115 116 117 118 119]
]
```
```perldl> p \$indx = intersect( which(\$piddle>43), which(\$piddle<72) );
```
```[44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
67 68 69 70 71]
```
```p \$piddle->flat->index( \$indx ) .= 255; #assigning the new values
```
```[255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255]
```
```perldl> p \$piddle

...
[100 101 102 103 104 105 106 107 108 109]
[110 111 112 113 114 115 116 117 118 119]
]
```
```#!/usr/bin/perl
use warnings;
...

\$win2->close();
```

Create A New User
Node Status?
node history
Node Type: perlmeditation [id://598007]
Approved by liverpole
Front-paged by liverpole
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2016-05-03 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
What font do you use for programming?

Results (67 votes). Check out past polls.