I've never heard of a comprehensive port of matlab functionality to C++. That being said, almost everything matlab does exists within a C/C++ library somewhere, some off the top of my head:
LAPACK, BLAS, you already mentioned these, and there are a few good implementations, the most notable (free) one being ATLAS.
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
Beyond the good suggestions already given, you may also be able to lift the code you need from the source code of Octave or Scilab. Both of these have GPL-style licenses, though, which may not suit your needs.
Read your Matlab documentation very carefully and have a poke around the DLLs and other components it installs on your hard disks. I think you'll find that Matlab uses a version of BLAS for what BLAS does, possibly also LAPACK and others.
发布评论
评论(5)
我从未听说过将 matlab 功能全面移植到 C++。话虽这么说,几乎 matlab 所做的一切都存在于某个 C/C++ 库中,其中一些是我突然想到的:
之后,我们弄清楚你需要什么,很可能有人已经用 C/C++ 实现了它。
I've never heard of a comprehensive port of matlab functionality to C++. That being said, almost everything matlab does exists within a C/C++ library somewhere, some off the top of my head:
After that, well figure out what you need and there is a good chance someone has implemented it in C/C++.
我也喜欢
除此之外,您最初的问题对于更好的指针来说还不够具体。
I also like
Beyond that, your original question isn't really specific enough for better pointers.
抱歉,我又提出了一个老问题,但我目前正在开发一个开源 C++ 库,它可以准确回答这个问题:
KeyCpp 是一个开源 C++ 库,它为多种有用的数值方法以及一些绘图功能提供类似 MATLAB/Octave 的语法。目前有
eig
、ode45
、fft
、linsolve
、svd
、interp1
、plot
以及许多其他常见的 MATLAB 函数。虽然还有其他(非常好的)库提供了许多此类函数(例如 Armadillo、Eigen 等),但大多数都不是完整的数值库,并且它们的大多数语法与 MATLAB 的语法不同。虽然 KeyCpp 还不是一个完整的数值库(但一直在改进!),但其语法在 C++ 语言允许的范围内尽可能接近 MATLAB。
在 KeyCpp 中,要绘制向量
t
和y
,我们使用以下语法:(Go 此处了解更广泛的示例)功能KeyCpp 库的功能利用了 LAPACK、Gnuplot 和 odeint(来自 Boost)。以下开源项目已合并到该库中:Kiss FFT、Gnuplot-cpp。
大多数功能的 Doxygen 文档位于此处
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
andy
we use the following syntax: (Go here for a more extensive example)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
除了已经给出的好的建议之外,您还可以从 的源代码中提取所需的代码Octave 或 Scilab。不过,这两者都有 GPL 风格的许可证,这可能不适合您的需求。
Beyond the good suggestions already given, you may also be able to lift the code you need from the source code of Octave or Scilab. Both of these have GPL-style licenses, though, which may not suit your needs.
仔细阅读 Matlab 文档,并浏览一下它安装在硬盘上的 DLL 和其他组件。我想你会发现 Matlab 使用 BLAS 的一个版本来完成 BLAS 的工作,可能还有 LAPACK 和其他版本。
Read your Matlab documentation very carefully and have a poke around the DLLs and other components it installs on your hard disks. I think you'll find that Matlab uses a version of BLAS for what BLAS does, possibly also LAPACK and others.