欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python使用scipy模塊實(shí)現(xiàn)一維卷積運(yùn)算示例

 更新時(shí)間:2019年09月05日 12:04:26   作者:cakincqm  
這篇文章主要介紹了Python使用scipy模塊實(shí)現(xiàn)一維卷積運(yùn)算,結(jié)合實(shí)例形式分析了scipy模塊的功能及使用scipy模塊進(jìn)行一維卷積運(yùn)算的相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Python使用scipy模塊實(shí)現(xiàn)一維卷積運(yùn)算。分享給大家供大家參考,具體如下:

一 介紹

signal模塊包含大量濾波函數(shù)、B樣條插值算法等等。下面的代碼演示了一維信號的卷積運(yùn)算。

二 代碼

import numpy as np
import scipy.signal
x = np.array([1,2,3])
h = np.array([4,5,6])
print(scipy.signal.convolve(x, h))#一維卷積運(yùn)算

三 運(yùn)行結(jié)果

[ 4 13 28 27 18]

四 一維卷積算法

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
usingnamespace std;
#define INF 0xfffffff
#define maxn 100010
int main()
{
int m=5,n=5;
int a[5]={0,1,0,2,1},b[5]={0,1,0,2,1};
int i,j;
int k=m+n-1;//卷積后數(shù)組長度
int c[k];
memset(c,0,sizeof(c));//注意一定要清零
/**卷積計(jì)算**/
for(i=0; i<k; i++)
{
for(j=max(0,i+1-n); j<=min(i,m-1); j++)
c[i]+=a[j]*b[i-j];
cout<<c[i]<<" ";
}
/****/
cout<<endl;
}

更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python數(shù)學(xué)運(yùn)算技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》及《Python入門與進(jìn)階經(jīng)典教程

希望本文所述對大家Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論