2010-08-17 31 views
10

Giả sử tôi có một mảng đôi, thuật toán tốt để lấy mẫu chuỗi này bằng cách sử dụng Akima interpolation là gì? Tôi quá ngu ngốc để dịch mô tả toán học đó thành mã.Nội suy Akima của mảng đôi

// values is an array of doubles 
// idx is the index of the left-hand value for the current interpolation 
// t is the normalized parameter between values[idx] and values[idx+1] 
// Don't worry about array bounds, I'll handle that separately. 
public double InterpolateAkima(double[] values, int idx, double t) 
{ 
    ...? 
} 
+3

Dường như rất nhiều công việc mà không ai chỉ sẽ mã lên cho bạn. Nó trông khá thẳng về phía trước, nhưng một số giờ tốt của mã hóa để làm cho nó được thực hiện. Đừng ngại hỏi nếu có một điều cụ thể bạn không hiểu. –

+0

@Albin, đủ công bằng tôi cho là vậy. Nội suy khối giống như 10 dòng mã, tôi đã hy vọng tất cả các phép toán này có thể được cô đặc xuống 20 dòng ... –

Trả lời

27

Đăng lại và mở rộng câu trả lời của tôi cho another SO question đã bị đóng dưới dạng bản sao của câu hỏi này - như được đề xuất bởi nhận xét về câu hỏi đó.

giấy gốc Akima của: '' Một phương pháp mới của nội suy và phù hợp đường cong mượt mà dựa trên thủ tục địa phương '', Tạp chí ACM 17, 4 (1970), 589-602

http://www.leg.ufpr.br/lib/exe/fetch.php/wiki:internas:biblioteca:akima.pdf

C thực hiện

https://github.com/ampl/gsl/blob/master/interpolation/akima.c

C# thực hiện

https://gist.github.com/dreikanter/3526685

Delphi thực hiện (xem BuildAkimaSpline thủ tục trong delphi/src/spline3.pas)

http://www.alglib.net/translator/re/alglib-2.6.0.delphi.zip

Akima của Fortran 66 thực hiện

http://cran.r-project.org/web/packages/akima/

Fortran 90 thực hiện

http://miyoshi.googlecode.com/svn-history/r72/trunk/common/common.f90

thực hiện Java

https://commons.apache.org/proper/commons-math/jacoco/org.apache.commons.math3.analysis.interpolation/AkimaSplineInterpolator.java.html

thực hiện Lisp "cho AutoCAD 2d-Polylines"

http://autocad.xarch.at/code/candido/akima.lsp

Matlab thực hiện

http://www.mathworks.se/matlabcentral/fileexchange/1814-akima-interpolation

thực hiện

Pascal (program description)

http://jean-pierre.moreau.pagesperso-orange.fr/Pascal/akima_pas.txt

Python thực hiện

http://www.lfd.uci.edu/~gohlke/code/akima.py.html

thực hiện VB6 (xem BuildAkimaSpline chương trình con trong vb6/src/spline3.bas)

http://www.alglib.net/translator/re/alglib-2.6.0.vb6.zip

http://www.koders.com/cpp/fid1393B9D668316C1700966643DE0609660B9CB13A.aspx?s=%22Brian+Smith%22

+0

Ngoài ra: [Mathematica implementation by Jens-Peer Kuska] (https://groups.google.com/d/msg/comp.soft-sys.math .mathematica/XAWwuMCV_8w/FZDMf3Pgsz0J). –

+0

Ngoài ra alglib (chỉ đề cập dưới VB6 và delphi) có C++, C#, python và các triển khai khác. – Dan

+0

Thực hiện C khác (GSL): https://www.gnu.org/software/gsl/manual/html_node/Interpolation-Types.html#Interpolation-Types – alfC

7

Có một số hits tìm kiếm mã google nhưng đây không phải là lĩnh vực tôi biết nhiều. Kết quả đầu tiên là cho Math.NET mà có thể có một số quan tâm.

+3

+1: Math.NET có thực hiện thực sự – Bertvan

+0

Đó là trong không gian tên 'MathNet.Numerics.Interpolation ' – Keith

+0

http://mathnetnumerics.codeplex.com/wikipage?title=Interpolation –