David Mertens

# 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>