Implementation of scipy.signla.filtfilt in c++? [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 10 months ago.
Improve this question
I am trying to implement scipy.signal.filtfilt function in c++ and I am wondering if there is already an implementation available of this?

I know its a long time. but maybe you find this repository useful:
FiltFilt in C++

filtfilt applies an IIR filter twice, once going forward, once going backward. The nontrivial part is how to initialize the IIR filter at the boundaries.
As a starting point, look at how scipy.signal.filtfilt does it. Here is the code:
https://github.com/scipy/scipy/blob/master/scipy/signal/signaltools.py#L3870
You might also find it useful to look at the source code for Octave's filtfilt (M code):
https://sourceforge.net/p/octave/signal/ci/default/tree/inst/filtfilt.m
To reproduce filtfilt in C++, you need a C++ implementation of IIR filtering to take the role of scipy's lfilter plus some boundary handling logic. I don't know about an existing C++ implementation of filtfilt, but at least for the default method='pad' logic, the core computation seems simple enough to consider porting directly.

Scipy's filtfilt is similar to Matlab's filtfilt.
A question for MATLAB's filtfilt was previously asked
An implementation for the same was previously shared on Stackoverflow by #darien-pardinas
Do note I say similar because as mentioned by #paco-wong
The difference is in the default padding length. In matlab's filtfilt, it is 3*(max(len(a), len(b)) - 1), and in scipy's filtfilt, it is 3*max(len(a), len(b)).
So you will have to account for that

Related

How to read MATHEMATICAL functions in C++? [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Okay, so what I want to do is to use a string as input (for instance "16*12+25"), convert it to a mathematical evaluation that the computer can comprehend and return the evaluated value. I could probably write this myself, but it would most likely take quite a while and in the end, it still wouldn't end up as good as I'd like it to unless I want to put even more time into it.
So my question is, is there any script, library or api that you know can do this for C++? I have found some for both java, python and .NET. But I am not working with any of these languages and I would like to remain within C++ for as long (hopefully throughout the entire project) as possible. Do you have any good ideas or links?
I found what I was looking for! The downloadable source is C++ and a CodeBlocks project. You can find it here: http://www.speqmath.com/tutorials/expression_parser_cpp/index.html
A far more sophisticated expression parser recommended by Jared: http://www.partow.net/programming/exprtk/index.html
There is nothing built into C++ for this; all the expression parsing code belongs in the compiler. You will need to use some external library. A quick Google search brings up muParser which looks pretty reasonable.

Is there any JSON-RPC implementation in C++ that is transport-agnostic? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am currently looking for a JSON-RPC library that implements the 2.0 specification and is, or at least can be easily adapted to be, transport-agnostic, implemented in c++ and have as few dependencies as possible.
In my search for it, I already looked for on the obvious places and the more comprehensive collections below:
http://json-rpc.org/wiki/implementations (outdated info)
https://en.wikipedia.org/wiki/JSON-RPC
Header-only / standard c++11 implementation, for a quick drop in a new project, that can be used on different platforms is a plus!
Please note that I am not looking for a recommendation on which one is best or not, as I can most likely judge that myself. What I am asking is if anybody else know about a library that meet those technical requirements above, or at least already found a way to work around those requirements using an implementation that is public available.
Thank you.
After a lot of digging, the closest I could find that meet those requirement, specifically the one to be able to be adapted to be transport-agnostic was:
https://github.com/erijo/xsonrpc
It is still not a header-only implementation, and it has some external dependencies that makes it cumbersome to compile/use on different platforms and projects, but it was still the closest one I could find.
I might adapt this one to make it 100% in compliance with the original requirements of my question. Will update the question when I do so.
UPDATE
Using xsonrpc as a starting point, I put together an implementation that satisfy all those requirements and published as an opensource project:
https://github.com/uskr/jsonrpc-lean - include-only, transport-agnostic JSON-RPC 2.0 client/server implementation

data frame library in C++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
How might one implement data frame in R, Python, and other languages using C++?
In general, data.frame solves a problem which is solved fundamentally differently in C++ (and other languages) – namely via class hierarchies, or, in the simplest case, via a vector of tuples.
Since you haven’t given specifics it’s hard to know what exactly you are after but if it’s ease of computation, Armadillo is a good linear algebra library for C++ (one among many). I haven’t yet found a good statistics framework for C++ – I suggest simply sticking with R for that.

What's a good convex optimization library? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am looking for a C++ library, and I am dealing with convex objective and constraint functions.
I am guessing your problem is non-linear. Where i work, we use SNOPT, Ipopt and another proprietary solver (not for sale). We have also tried and heard good things about Knitro.
As long as your problem is convex, all these solvers work well.
They all have their own API, but they all ask for the same information : values, first and second derivatives.
Assuming your problems are nonlinear, you can use free and open-sourced OPT++, available from Sandia Lab. I have used it in one project in C++ and it was easy to use and worked well.
From what I know, the CPLEX solver is the best convex optimization solver. Its the state of the art in LP solvers. Does convex optimization really well. While looking for it, I see that its IBM's software now. You can find it here : http://www-01.ibm.com/software/integration/optimization/cplex/

C++ 2D Integration Libraries [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Can anyone point out a good C++ library that can do 2D numerical integration. It needs to be able to accept a 2D array of known values, and the spacing between the points can be assumed to be constant (for a start).
It is preferable that it have a license which allows modifying the code as needed.
It's actually a C library, but if the GPL licensing terms work for you try:
http://www.gnu.org/software/gsl/
You will want to check out the Monte Carlo integration options outlined here:
http://www.gnu.org/software/gsl/manual/html_node/Monte-Carlo-Integration.html
This Fortran library is easy to link to from C++ and is in public domain:
http://gams.nist.gov/cgi-bin/serve.cgi/Module/CMLIB/ADAPT/2967
It's single precision but it's quite easy to modify the sources (get "full sources" and go through every function) to switch to double precision.
http://itpp.sourceforge.net/current/
Try this. It can do what you ask for and more! And you can modify the code as much as you like.
I've read somewhere that you can extract libraries out of GNU Octave's code and use the C++ code in your own applications. I'm not sure if that's an easy task, but you can give it a try if you have the time.