2024/01/20(Sat) 22:15:44 編集(投稿者)
■No102869 (くま さん) に返信
■No102870 (魔界の仮面弁士 さん) に返信
あちこちから引っ張って来てつくりました。
何も分かっていません。
身の程知らずですみません。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim y() As Double 'データが入る配列
Dim N As Integer = 5
Dim M As Integer = 2
Dim result As Double
result = SGFilter(y(), N, M)
End Sub
Private Function SGFilter(ByVal y() As Double, ByVal N As Integer, ByVal M As Integer) As Double()
Dim i As Integer, j As Integer, k As Integer
Dim w(0 To N, 0 To M) As Double
Dim sum As Double
Dim y2() As Double
ReDim y2(0 To UBound(y))
For i = 0 To UBound(y)
sum = 0
For j = -N To N
For k = 0 To M
w(N + j, k) = ((j + k) ^ (2 * M))
Next k
sum = sum + w(N + j, 0)
Next j
For j = -N To N
For k = 0 To M
w(N + j, k) = w(N + j, k) / sum
Next k
Next j
For j = -N To N
sum = 0
For k = 0 To M
sum = sum + w(N + j, k) * y(i + j)
Next k
y2(i) = y2(i) + sum
Next j
Next i
SGFilter = y2
End Function