Sorry for reviving an old question but I am currently working on an open source C++ library that exactly answers this question:
KeyCpp is an open source C++ library that provides MATLAB/Octave-like syntax to several useful numerical methods and also some plotting functionality. Currently there are functions for eig
, ode45
, fft
, linsolve
, svd
, interp1
, plot
, and many other common MATLAB functions.
While there are other (very good) libraries that provide many of these functions (such as Armadillo, Eigen, etc), most are not complete numerical libraries and most of their syntax is dissimilar to MATLAB's syntax. While KeyCpp is also not yet a complete numerical library (but is improving all the time!), the syntax is as close to MATLAB's as the C++ language allows.
In KeyCpp, to plot the vectors t
and y
we use the following syntax: (Go here for a more extensive example)
#include <iostream>
#include <keycpp/keycpp.h>
using namespace keycpp;
int main(int argc, char** argv)
{
// Lets create some data: y = sin(t)
std::vector<double> t = linspace(-pi,pi,100);
std::vector<double> y = sin(t);
Figure h;
h.plot(t,y,"-b");
h.grid_on();
h.legend({"Series 1"});
h.title("Example Plot");
h.xlabel("time");
h.ylabel("y");
return 0;
}
The functionality of the KeyCpp library takes advantage of LAPACK, Gnuplot, and odeint (from Boost). The following open source projects have been incorporated into this library: Kiss FFT, Gnuplot-cpp.
Doxygen documentation for most of the functions is located here