Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Subject
- Posted on
- PDL: Printing Matrices
- 11-23-2004
- Greenleaf
November 23, 2004, 3:53 am
A problem with PDL printing:
I have two matrices, and I multiply and print them, say, in the
following way:
my $lmat = matmult ($s, transpose($v));
my $rmat = matmult ($v, $s);
print $lmat;
print $rmat;
Although after the multimplication $lmat should be the transpose of
$rmat, the following print statements look the same. Am I doing
anything wrong here? Or can anybody please point me to any
documentation that explains how print() works with piddles? I'm a
newbie to PDL.
Thanks for consideration.
--
Greenleaf
Re: PDL: Printing Matrices
use warnings;
use PDL;
my $s = pdl[[1,2], [4,5]];
my $v = pdl[[1,2], [4,3]];
> my $lmat = matmult ($s, transpose($v));
> my $rmat = matmult ($v, $s);
> print $lmat;
> print $rmat;
>
That seems to work ok for me.
Prints:
[
[ 5 10]
[14 31]
]
[
[ 9 12]
[16 23]
]
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
Re: PDL: Printing Matrices
>
> use warnings;
> use PDL;
> my $s = pdl[[1,2], [4,5]];
> my $v = pdl[[1,2], [4,3]];
> > my $lmat = matmult ($s, transpose($v));
> > my $rmat = matmult ($v, $s);
> > print $lmat;
> > print $rmat;
> >
>
> That seems to work ok for me.
>
> Prints:
> [
> [ 5 10]
> [14 31]
> ]
>
> [
> [ 9 12]
> [16 23]
> ]
>
> Cheers,
> Rob
Hi Rob,
Thanks for the answer.
I just realized that I could do with normal 2-d pdls. I was using
PDL::Matrix, and matrices in the example I gave were actually
PDL::Matrix. As i said, i was a newbie and thought i _should_ use
PDL::Matrix for matrices.
The issue ramains anyway for PDL::Matrix, although i got around the
problem.
Cheers,
Greenleaf
Re: PDL: Printing Matrices
Greenleaf wrote:
>
>>Greenleaf wrote:
>>
>> use warnings;
>> use PDL;
>> my $s = pdl[[1,2], [4,5]];
>> my $v = pdl[[1,2], [4,3]];
>>
>>> my $lmat = matmult ($s, transpose($v));
>>> my $rmat = matmult ($v, $s);
>>> print $lmat;
>>> print $rmat;
>>>
>>
>>That seems to work ok for me.
>>
>>Prints:
>>[
>> [ 5 10]
>> [14 31]
>>]
>>
>>[
>> [ 9 12]
>> [16 23]
>>]
>>
>>Cheers,
>>Rob
>
>
>
> Hi Rob,
>
> Thanks for the answer.
>
> I just realized that I could do with normal 2-d pdls.
You realise that PDL can accommodate matrices of larger dimensions, too
? (You probably do ... just checking :-)
> I was using
> PDL::Matrix, and matrices in the example I gave were actually
> PDL::Matrix. As i said, i was a newbie and thought i _should_ use
> PDL::Matrix for matrices.
I'm not all that familiar with PDL either - it looks to me that
PDL::Matrix supplies some additional functionality not provided by PDL.
And I guess that if you want to access those additional functions then
you 'use PDL::Matrix;'.
But for transpositions and multiplications there's nothing to be gained
from using PDL::Matrix.
>
> The issue ramains anyway for PDL::Matrix, although i got around the
> problem.
The following seems ok for me:
use warnings;
use PDL;
use PDL::Matrix;
my $s = PDL::Matrix->pdl([[1,2], [4,5]]);
my $v = PDL::Matrix->pdl([[1,2], [4,3]]);
my $lmat = matmult ($s, transpose($v));
my $rmat = matmult ($v, $s);
print $lmat;
print $rmat;
I haven't checked, but I assume that $s, $v, $lmat and $rmat can all now
be subjected to those "additional" PDL::Matrix functions.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
>
>>Greenleaf wrote:
>>
>> use warnings;
>> use PDL;
>> my $s = pdl[[1,2], [4,5]];
>> my $v = pdl[[1,2], [4,3]];
>>
>>> my $lmat = matmult ($s, transpose($v));
>>> my $rmat = matmult ($v, $s);
>>> print $lmat;
>>> print $rmat;
>>>
>>
>>That seems to work ok for me.
>>
>>Prints:
>>[
>> [ 5 10]
>> [14 31]
>>]
>>
>>[
>> [ 9 12]
>> [16 23]
>>]
>>
>>Cheers,
>>Rob
>
>
>
> Hi Rob,
>
> Thanks for the answer.
>
> I just realized that I could do with normal 2-d pdls.
You realise that PDL can accommodate matrices of larger dimensions, too
? (You probably do ... just checking :-)
> I was using
> PDL::Matrix, and matrices in the example I gave were actually
> PDL::Matrix. As i said, i was a newbie and thought i _should_ use
> PDL::Matrix for matrices.
I'm not all that familiar with PDL either - it looks to me that
PDL::Matrix supplies some additional functionality not provided by PDL.
And I guess that if you want to access those additional functions then
you 'use PDL::Matrix;'.
But for transpositions and multiplications there's nothing to be gained
from using PDL::Matrix.
>
> The issue ramains anyway for PDL::Matrix, although i got around the
> problem.
The following seems ok for me:
use warnings;
use PDL;
use PDL::Matrix;
my $s = PDL::Matrix->pdl([[1,2], [4,5]]);
my $v = PDL::Matrix->pdl([[1,2], [4,3]]);
my $lmat = matmult ($s, transpose($v));
my $rmat = matmult ($v, $s);
print $lmat;
print $rmat;
I haven't checked, but I assume that $s, $v, $lmat and $rmat can all now
be subjected to those "additional" PDL::Matrix functions.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
Site Timeline
- » use SOAP::Lite +autodispatch ???
- — Next thread in » PERL Modules Announcements
- » ANNOUNCE: Zoidberg 0.91
- — Previous thread in » PERL Modules Announcements
- » Updating the hash across the files
- — Newest thread in » PERL Modules Announcements
- » SSD partition alignment revisited
- — The site's Newest Thread. Posted in » Computer Hardware