NAME

PDL::Graphics::Asymptote - PDL interface to the Asymptote interpreter

VERSION

This documentation refers to PDL::Graphics::Asymptote version 0.0.2.

SYNOPSIS

use PDL::Graphics::Asymptote;
use PDL;

# Start a new interpreter
my $asy = PDL::Graphics::Asymptote->new;

# Generate some data
my $x = sequence(100) / 10;
my $y = sin($x);

# Send the data to the interpreter
$asy->send_pdl(x => $x, y => $y);

# Tell the interpreter what to do with it:
$asy->send( q{
    import graph;

    picture sine_pic;
    size(sine_pic, 3inches, keepAspect=false);
    draw(sine_pic, graph(x, y));
    yaxis(sine_pic, L = "$sin\left(x\right)$", ticks = Ticks);
    xaxis(sine_pic, L = "$x$", ticks = Ticks);
    shipout(prefix = "mySineGraph", sine_pic);
});

DESCRIPTION

PDL::Graphics::Asymptote extends Graphics::Asymptote, adding a function to help you shuttle data from PDL to Asymptote. This allows you to do your serious number crunching in PDL and then quickly and easily move the final to-be-plotted data to Asymptote to polish it off.

This documentation will discuss the only major addition: send_pdl. For general usage of the Asymptote wrapper that underlies this class, see Graphics::Asymptote.

SUBROUTINE/METHOD

send_pdl(asy_name1 => $pdl1, asy_name2 => $pdl2, ...)

Sends the data contained in the given piddles to the asymptote interpreter. The routine queries the piddles for their dimensions and datatypes and properly constructs the resulting arrays in Asymptote for you.

DIAGNOSTICS

You can make a few mistakes while trying to use this module. The sorts of messages you might get include these:

You gave <number> arguments to send_pdl, I expected an even number.

When you call the send_pdl command, you must send pairs as asy_var => $piddle. It's likely you forgot to give the Asymptote variable name as the key to this pair.

I was expecting a piddle but I got something else.

You'll get this if you try to send something down the pipe that's not a piddle. To set a normal value in Asymptote, such as a string, simply interpolate the value into the commnd you send, like so:

$asy->send( qq{
    int number_of_triangles = $pre_computed_number;
    // more Asymptote code here, if you like.
});

DEPENDENCIES

This module depends on having a working version of asy, the Asymptote interpreter.

BUGS AND LIMITATIONS

There are no known bugs in this module.

While send_pdl allows you to send potentially voluminous quantities of data from PDL to Asymptote, it appears to have a huge impact on the memory consumption of both processes. This is likely due to the fact that any piddle sent to Asymptote is sent in one shot, rather than one entry at a time. As such, the object on PDL's side constructs a huge string, and the interpreter on Asymptote's side must absorb and process a huge string. It may be more efficient to work in interactive mode and send the piddle a single element at a time, keeping the size of each pipe write/read to only a few bytes. However, this is pure speculation and may not ever be implemented...

Please report any bugs or feature requests to bug-graphics-asymptote@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR

David Mertens <dcmertens.perl+Asymptote@gmail.com>

LICENCE AND COPYRIGHT

Copyright (c) 2009, David Mertens <dcmertens.perl+Asymptote@gmail.com>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

SEE ALSO

Graphics::Asymptote, PDL, http://asymptote.sourceforge.net/