一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

Python使用scipy模块如何实现一维卷积运算 Python使用scipy模块实现一维卷积运算示例

时间:2019-09-05 编辑:袖梨 来源:一聚教程网

本篇文章小编给大家分享一下Python使用scipy模块实现一维卷积运算示例,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。

一 介绍

signal模块包含大量滤波函数、B样条插值算法等等。下面的代码演示了一维信号的卷积运算。

二 代码

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))#一维卷积运算

三 运行结果

[ 4 13 28 27 18]

四 一维卷积算法

#include
#include
#include
#include
#include
#include
#include
#include
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;//卷积后数组长度
int c[k];
memset(c,0,sizeof(c));//注意一定要清零
/**卷积计算**/
for(i=0; i
                

热门栏目