Hi again,
Would it be useful to provide a function to calculate convolution from math.js if it doesn't exist? I think people who are working on Deep Learning or Machine Learning will benefit from it.
References:
https://en.wikipedia.org/wiki/Convolution
Inspiration:
https://docs.scipy.org/doc/numpy/reference/generated/numpy.convolve.html
That can be interesting indeed, thanks for your suggestion. Anyone interested to pick this up?
I want to support this. But this could mean also some work, since would you want to implement it 1D, 2D, ND? And which types? Full, same or valid? And what method? Direct? FFT? Both?
This is the help from Matlab:
C = conv(A, B) convolves vectors A and B. The resulting vector is
length MAX([LENGTH(A)+LENGTH(B)-1,LENGTH(A),LENGTH(B)]). If A and B are
vectors of polynomial coefficients, convolving them is equivalent to
multiplying the two polynomials.
C = conv(A, B, SHAPE) returns a subsection of the convolution with size
specified by SHAPE:
'full' - (default) returns the full convolution,
'same' - returns the central part of the convolution
that is the same size as A.
'valid' - returns only those parts of the convolution
that are computed without the zero-padded edges.
LENGTH(C)is MAX(LENGTH(A)-MAX(0,LENGTH(B)-1),0).
Further you would also would like to implement deconvolution at the same time I suppose. Numeric.js already has an implementation. https://github.com/sloisel/numeric/blob/master/src/numeric.js#L2678
About the dimensions: mathjs works different than Matlab in that it uses geometric dimensions whilst Matlab normally creates a two dimensional matrix for vectors. I suppose we can implement it for 1D and 2D, multiple dimensions is probably quite hard to do.