/usr/include/roboptim/core/visualization/gnuplot.hh is in libroboptim-core-dev 2.0-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | // Copyright (C) 2009 by Thomas Moulard, AIST, CNRS, INRIA.
//
// This file is part of the roboptim.
//
// roboptim is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// roboptim is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with roboptim. If not, see <http://www.gnu.org/licenses/>.
#ifndef ROBOPTIM_CORE_VISUALIZATION_GNUPLOT_HH
# define ROBOPTIM_CORE_VISUALIZATION_GNUPLOT_HH
# include <roboptim/core/sys.hh>
# include <roboptim/core/debug.hh>
# include <roboptim/core/function.hh>
# include <vector>
# define EIGEN_YES_I_KNOW_SPARE_MODULE_IS_NOT_STABLE_YET
# include <Eigen/Core>
# include <Eigen/Sparse>
# include <roboptim/core/function.hh>
# include <roboptim/core/visualization/fwd.hh>
# include <roboptim/core/visualization/gnuplot-commands.hh>
namespace roboptim
{
namespace visualization
{
/// \addtogroup roboptim_visualization
/// @{
/// \brief Normalize floating point number output.
/// Normalization is done on all displayed floating
/// point numbers to get a consistent output.
double normalize (const double& x);
/// \brief Apply normalize to each element of a matrix.
Eigen::MatrixXd
normalize (const Eigen::MatrixXd& x);
/// \brief Apply normalize to each element of a container.
template <typename T>
T normalize (const T& x);
inline double
normalize (const double& x)
{
if (std::fabs (x) < 1e-8)
return 0.;
return x;
}
inline Eigen::MatrixXd
normalize (const Eigen::MatrixXd& x)
{
Eigen::MatrixXd res (x.rows (), x.cols ());
for (Function::size_type i = 0; i < x.rows (); ++i)
for (Function::size_type j = 0; j < x.cols (); ++j)
res (i, j) = normalize (x (i, j));
return res;
}
template <typename T>
T
normalize (const T& x)
{
T res (x.size ());
for (Function::size_type i = 0; i < x.size (); ++i)
res[i] = normalize (x[i]);
return res;
}
/// \brief Gnuplot script
///
/// This class gathers Gnuplot commands
/// to build a complete Gnuplot script.
/// Gnuplot commands can be inserted through
/// this object through the \c << operator
/// and this object can be put into an output stream
/// using the \c << operator.
class ROBOPTIM_DLLAPI Gnuplot
{
public:
~Gnuplot () throw ();
/// \brief Instanciate a Gnuplot without setting a term.
/// \return Gnuplot instance
static Gnuplot make_gnuplot () throw ()
{
return Gnuplot ();
}
/// \brief Instanciate a Gnuplot suitable for interactive use.
///
/// This initializes a persistent Gnuplot instance which are
/// suitable for user interaction.
/// \return Gnuplot instance
static Gnuplot make_interactive_gnuplot () throw ()
{
Gnuplot gp;
gp.push_command (gnuplot::set ("terminal", "wxt persist"));
return gp;
}
/// \brief Add a new Gnuplot command to the script.
/// \param cmd command that will be pushed
void push_command (gnuplot::Command cmd) throw ();
/// \brief Display the Gnuplot script on the specified output stream.
///
/// \param o output stream used for display
/// \return output stream
std::ostream& print (std::ostream&) const throw ();
Gnuplot& operator << (gnuplot::Command) throw ();
protected:
/// \brief Default constructor can not be called directly.
///
/// Use of the named constructor (see static methods) to
/// instantiate this class.
explicit Gnuplot () throw ();
private:
/// \brief Vector of commands.
std::vector<gnuplot::Command> commands_;
};
/// Example shows simple Gnuplot visualization.
/// \example visualization-gnuplot-simple.cc
/// Example shows function display with Gnuplot.
/// \example visualization-gnuplot-function.cc
/// \brief Override operator<< to handle Gnuplot command insertion.
///
/// \tparam Gnuplot command type
/// \param gp Gnuplot script that will receive the new command
/// \param t new Gnuplot command.
/// \return modified Gnuplot script
template <typename T>
Gnuplot& operator<< (Gnuplot& gp, T t)
{
gp.push_command (t ());
return gp;
}
/// @}
/// \brief Override operator<< to handle Gnuplot script display.
///
/// \param o output stream used for display
/// \param gp Gnuplot script to be displayed
/// \return output stream
ROBOPTIM_DLLAPI std::ostream& operator<< (std::ostream&, const Gnuplot& gp);
} // end of namespace visualization.
} // end of namespace roboptim.
#endif //! ROBOPTIM_CORE_VISUALIZATION_GNUPLOT_HH
|