Created
August 28, 2009 08:08
-
-
Save tomoya55/176825 to your computer and use it in GitHub Desktop.
Convolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int* ConvolveIn(int x[], int h[]){ | |
| int ix, ih; | |
| //x[]とh[]の配列の大きさを求める | |
| ix = sizeof(x)/sizeof(int); | |
| ih = sizeof(h)/sizeof(int); | |
| iy = ix + ih; | |
| //output | |
| int y[iy]; | |
| for(i=0;i<=iy;i++){ | |
| y[i]=0; | |
| } | |
| //Convolving | |
| for(i=0;i<=ix;i++){ | |
| for(j=0;j<=ih;j++){ | |
| y[i+j] += x[i] * h[j]; | |
| } | |
| } | |
| //yの先頭ポインタを返す。 | |
| return y; | |
| } | |
| int* ConvolveOut(int x[], int h[]){ | |
| int ix, ih; | |
| //x[]とh[]の配列の大きさを求める | |
| ix = sizeof(x)/sizeof(int); | |
| ih = sizeof(h)/sizeof(int); | |
| iy = ix + ih; | |
| //output | |
| int y[iy]; | |
| //Convolving | |
| for(i=0;i<=iy;i++){ | |
| y[i] = 0; | |
| for(j=0;j<=ih;j++){ | |
| if(( i-j >= 0) && (i-j <= 80)) | |
| y[i] += h[j]*x[i-j]; | |
| } | |
| } | |
| return y; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment