Example shows function display with Gnuplot.
#include "shared-tests/fixture.hh"
#include <iostream>
using namespace roboptim;
using namespace roboptim::visualization;
{
explicit Square ()
{
}
void impl_compute (result_ref result,
const_argument_ref argument) const
{
result[0] = argument[0] * argument[0];
}
};
{
explicit Circle (double r = 1.)
:
Function (1, 2,
"{sin (x) * r; cos (x) * r}"),
r_ (r)
{
}
void impl_compute (result_ref result,
const_argument_ref argument) const
{
result[0] = sin (argument[0]) * r_;
result[1] = cos (argument[0]) * r_;
}
double r_;
};
{
explicit Poly ()
{
}
void impl_compute (result_ref result,
const_argument_ref argument) const
{
result[0] = argument[0] * argument[0] * argument[0];
result[1] = result[0] * argument[0];
}
};
BOOST_FIXTURE_TEST_SUITE (core, TestSuiteConfiguration)
BOOST_AUTO_TEST_CASE (visualization_gnuplot_function)
{
boost::shared_ptr<boost::test_tools::output_test_stream>
output = retrievePattern ("visualization-gnuplot-function");
using namespace roboptim::visualization::gnuplot;
Gnuplot gnuplot = Gnuplot::make_interactive_gnuplot ();
Square square;
Circle circle;
Poly poly;
(*output)
<< (gnuplot
<<
comment (
"Hello, world (complex)!")
<< set ("multiplot layout 3,1")
<<
plot (square, intervalS)
<<
plot (poly, intervalP)
);
std::cout << output->str () << std::endl;
BOOST_CHECK (output->match_pattern ());
}
BOOST_AUTO_TEST_SUITE_END ()