http://paulbourke.net/miscellaneous/dft/


http://math.ewha.ac.kr/~jylee/SciComp/sc-crandall/fft.c


http://covil.sdu.dk/publications/MDobroczynski2DFFT2006.pdf


http://www.nayuki.io/res/free-small-fft-in-multiple-languages/fft.c




/* 

 * Free FFT and convolution (C)

 * 

 * Copyright (c) 2014 Project Nayuki

 * http://www.nayuki.io/page/free-small-fft-in-multiple-languages

 * 

 * (MIT License)

 * Permission is hereby granted, free of charge, to any person obtaining a copy of

 * this software and associated documentation files (the "Software"), to deal in

 * the Software without restriction, including without limitation the rights to

 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of

 * the Software, and to permit persons to whom the Software is furnished to do so,

 * subject to the following conditions:

 * - The above copyright notice and this permission notice shall be included in

 *   all copies or substantial portions of the Software.

 * - The Software is provided "as is", without warranty of any kind, express or

 *   implied, including but not limited to the warranties of merchantability,

 *   fitness for a particular purpose and noninfringement. In no event shall the

 *   authors or copyright holders be liable for any claim, damages or other

 *   liability, whether in an action of contract, tort or otherwise, arising from,

 *   out of or in connection with the Software or the use or other dealings in the

 *   Software.

 */


#include <math.h>

#include <stdlib.h>

#include <string.h>

#include "fft.h"



// Private function prototypes

static size_t reverse_bits(size_t x, unsigned int n);

static void *memdup(const void *src, size_t n);


#define SIZE_MAX ((size_t)-1)



int transform(double real[], double imag[], size_t n) {

if (n == 0)

return 1;

else if ((n & (n - 1)) == 0)  // Is power of 2

return transform_radix2(real, imag, n);

else  // More complicated algorithm for arbitrary sizes

return transform_bluestein(real, imag, n);

}



int inverse_transform(double real[], double imag[], size_t n) {

return transform(imag, real, n);

}



int transform_radix2(double real[], double imag[], size_t n) {

// Variables

int status = 0;

unsigned int levels;

double *cos_table, *sin_table;

size_t size;

size_t i;

// Compute levels = floor(log2(n))

{

size_t temp = n;

levels = 0;

while (temp > 1) {

levels++;

temp >>= 1;

}

if (1u << levels != n)

return 0;  // n is not a power of 2

}

// Trignometric tables

if (SIZE_MAX / sizeof(double) < n / 2)

return 0;

size = (n / 2) * sizeof(double);

cos_table = malloc(size);

sin_table = malloc(size);

if (cos_table == NULL || sin_table == NULL)

goto cleanup;

for (i = 0; i < n / 2; i++) {

cos_table[i] = cos(2 * M_PI * i / n);

sin_table[i] = sin(2 * M_PI * i / n);

}

// Bit-reversed addressing permutation

for (i = 0; i < n; i++) {

size_t j = reverse_bits(i, levels);

if (j > i) {

double temp = real[i];

real[i] = real[j];

real[j] = temp;

temp = imag[i];

imag[i] = imag[j];

imag[j] = temp;

}

}

// Cooley-Tukey decimation-in-time radix-2 FFT

for (size = 2; size <= n; size *= 2) {

size_t halfsize = size / 2;

size_t tablestep = n / size;

for (i = 0; i < n; i += size) {

size_t j;

size_t k;

for (j = i, k = 0; j < i + halfsize; j++, k += tablestep) {

double tpre =  real[j+halfsize] * cos_table[k] + imag[j+halfsize] * sin_table[k];

double tpim = -real[j+halfsize] * sin_table[k] + imag[j+halfsize] * cos_table[k];

real[j + halfsize] = real[j] - tpre;

imag[j + halfsize] = imag[j] - tpim;

real[j] += tpre;

imag[j] += tpim;

}

}

if (size == n)  // Prevent overflow in 'size *= 2'

break;

}

status = 1;

cleanup:

free(cos_table);

free(sin_table);

return status;

}



int transform_bluestein(double real[], double imag[], size_t n) {

// Variables

int status = 0;

double *cos_table, *sin_table;

double *areal, *aimag;

double *breal, *bimag;

double *creal, *cimag;

size_t m;

size_t size_n, size_m;

size_t i;

// Find a power-of-2 convolution length m such that m >= n * 2 + 1

{

size_t target;

if (n > (SIZE_MAX - 1) / 2)

return 0;

target = n * 2 + 1;

for (m = 1; m < target; m *= 2) {

if (SIZE_MAX / 2 < m)

return 0;

}

}

// Allocate memory

if (SIZE_MAX / sizeof(double) < n || SIZE_MAX / sizeof(double) < m)

return 0;

size_n = n * sizeof(double);

size_m = m * sizeof(double);

cos_table = malloc(size_n);

sin_table = malloc(size_n);

areal = calloc(m, sizeof(double));

aimag = calloc(m, sizeof(double));

breal = calloc(m, sizeof(double));

bimag = calloc(m, sizeof(double));

creal = malloc(size_m);

cimag = malloc(size_m);

if (cos_table == NULL || sin_table == NULL

|| areal == NULL || aimag == NULL

|| breal == NULL || bimag == NULL

|| creal == NULL || cimag == NULL)

goto cleanup;

// Trignometric tables

for (i = 0; i < n; i++) {

double temp = M_PI * (size_t)((unsigned long long)i * i % ((unsigned long long)n * 2)) / n;

// Less accurate version if long long is unavailable: double temp = M_PI * i * i / n;

cos_table[i] = cos(temp);

sin_table[i] = sin(temp);

}

// Temporary vectors and preprocessing

for (i = 0; i < n; i++) {

areal[i] =  real[i] * cos_table[i] + imag[i] * sin_table[i];

aimag[i] = -real[i] * sin_table[i] + imag[i] * cos_table[i];

}

breal[0] = cos_table[0];

bimag[0] = sin_table[0];

for (i = 1; i < n; i++) {

breal[i] = breal[m - i] = cos_table[i];

bimag[i] = bimag[m - i] = sin_table[i];

}

// Convolution

if (!convolve_complex(areal, aimag, breal, bimag, creal, cimag, m))

goto cleanup;

// Postprocessing

for (i = 0; i < n; i++) {

real[i] =  creal[i] * cos_table[i] + cimag[i] * sin_table[i];

imag[i] = -creal[i] * sin_table[i] + cimag[i] * cos_table[i];

}

status = 1;

// Deallocation

cleanup:

free(cimag);

free(creal);

free(bimag);

free(breal);

free(aimag);

free(areal);

free(sin_table);

free(cos_table);

return status;

}



int convolve_real(const double x[], const double y[], double out[], size_t n) {

double *ximag, *yimag, *zimag;

int status = 0;

ximag = calloc(n, sizeof(double));

yimag = calloc(n, sizeof(double));

zimag = calloc(n, sizeof(double));

if (ximag == NULL || yimag == NULL || zimag == NULL)

goto cleanup;

status = convolve_complex(x, ximag, y, yimag, out, zimag, n);

cleanup:

free(zimag);

free(yimag);

free(ximag);

return status;

}



int convolve_complex(const double xreal[], const double ximag[], const double yreal[], const double yimag[], double outreal[], double outimag[], size_t n) {

int status = 0;

size_t size;

size_t i;

double *xr, *xi, *yr, *yi;

if (SIZE_MAX / sizeof(double) < n)

return 0;

size = n * sizeof(double);

xr = memdup(xreal, size);

xi = memdup(ximag, size);

yr = memdup(yreal, size);

yi = memdup(yimag, size);

if (xr == NULL || xi == NULL || yr == NULL || yi == NULL)

goto cleanup;

if (!transform(xr, xi, n))

goto cleanup;

if (!transform(yr, yi, n))

goto cleanup;

for (i = 0; i < n; i++) {

double temp = xr[i] * yr[i] - xi[i] * yi[i];

xi[i] = xi[i] * yr[i] + xr[i] * yi[i];

xr[i] = temp;

}

if (!inverse_transform(xr, xi, n))

goto cleanup;

for (i = 0; i < n; i++) {  // Scaling (because this FFT implementation omits it)

outreal[i] = xr[i] / n;

outimag[i] = xi[i] / n;

}

status = 1;

cleanup:

free(yi);

free(yr);

free(xi);

free(xr);

return status;

}



static size_t reverse_bits(size_t x, unsigned int n) {

size_t result = 0;

unsigned int i;

for (i = 0; i < n; i++, x >>= 1)

result = (result << 1) | (x & 1);

return result;

}



static void *memdup(const void *src, size_t n) {

void *dest = malloc(n);

if (dest != NULL)

memcpy(dest, src, n);

return dest;

}

'Cat.Storage > SubCat.Research' 카테고리의 다른 글

getIFFT  (0) 2015.07.20
Fourier transform pairs  (0) 2015.07.18
What is Filter bank  (0) 2015.06.14
What is CIELUV color space?  (0) 2015.05.26
k-means clustering  (0) 2015.05.23
Posted by Cat.IanKang
,

URL: http://www.computationalimaging.org/publications/the-light-field-stereoscope/

http://www.technologyreview.com/news/538976/how-to-stop-virtual-reality-from-making-you-want-to-puke/



Virtual reality is on the verge of commercial availability, with consumer-geared headsets like the Oculus Rift poised for release next year. Yet while the technology has improved immensely in the last couple years, there are still plenty of crucial issues to be sorted : motion sickness that some people have when experiencing virtual reality, which arises from what’s known as vergence-accommodation conflict.




Let's take a look at this picture.

when you’re looking at something—a flower, for instance—your eyes move and the lens in each eye adjusts to bring whatever’s in front of you into focus. Then, the vergence distance which is related to our brain cognition has same length with Focal distance. However, In the 3d display, usually lit-up display, our brain still realizes the object placed somewhere over the screen while our eyes see the display screen, and it is nearer than the vergence distance. It can result in nausea and dizziness. 


Researchers at Stanford are trying to solve with the headset, which they call a light field stereoscope, a device that uses a stack of two LEDs to show each eye a “light field” that makes virtual images look more natural than they typically do. 




This equipment shows us two different images for us, and our brain combines those images. You can get more details at the URL that I presented at the start of this post.   



Posted by Cat.IanKang
,

Red word: wrong answer


Extensive: widespread 

The accident caused extensive damage to both cars. 


flourish: do well, prosper, thrive

Most plants flourish in this rich soil.


foster: encourage

Overuse of antibiotics may foster the spread of drug-resistant bacteria. 


harness: put into use, utilize

We aim to do better at harnessing skills and talents of our workforce. 


impetus: stimulus, motivation

The peace process has been steadily gaining impetus.


impose: force

I wouldn't want to impose my views on anyone. 


imposing: heavy, impressive

He gave an imposing yet gentle impression. 


indispensable: essential, necessary

International cooperation is indispensable to resolving the problem of the drug trade.


induce: bring, cause

Both treatments is effective in inducing remission of the disease. 


inducement: incentive

A financial inducement to join the company. 


plausible: credible, believable, possible, reasonable

The story was plausible but that didn't necessarily mean it was true. 


prevalent: widespread, most common

This negative attitude is surprisingly prevalent among young boys. 


prolong: extend

The ongoing violence has prolonged the suffering of our people. 

Posted by Cat.IanKang
,

Usual morning

카테고리 없음 2015. 6. 30. 10:37

comprise / contend / contention /contentious / intact / offset / onset/ principal / refinement/ ultimately/ ample / analogous/ assess / assume / configuration/ cope with / disseminate/ evident / inadvertently/ lucrative/ obscure / phenomenal/ proliferate



  Everyday, my morning starts with my dear, Fennec. Today i'm going to tell you about my usual morning. My usual morning is comprised of three main features: Grooming, commuting, and talking. 

 

  Right after I wake up in the bed, I stretched myself and yawned. Then, heading to restroom and starting grooming. If I remain intact my hair, It gonna be tufty so that it looks really fun. ( I don't want it. lol ) At the first time, only a few month ago, I don't know how to make up myself well. Because, I don't think appearance is important to live beautifully. Instead, using refined language, studying as many  things as I can, and living enthusiastic are more of importance for me. I still think those things are more substantial facts making me more elegant. However, simultaneously, I want to see my better appearance to my Fennec, so I decided to practice grooming. It was merely a few month ago.


 I used to commuting via subway. It is fast and convenient. At one time, I discussed with my friends which transportation is the most convenient for us.It is really contentious topic for us. We had argued it more than a week.  Some of them argued that the bus is the best because we have to walk up too many stairs to ride a subway. However, in my contention, subway is the best in terms of convenience. The bus is too rattle and it brings me some nausea, sickness. Anyways, turn back to our original topic, I always ride subway instead of any other transportation. (There are many ways to commute, and they need almost the same time) In subway, I greet my Fennec and pat her. Fennec gives me a shine smile and hugs me lovely. My feelings ultimately goes to over the sky XD.


 It takes almost an hours to reach, so we have talked many things. The most interesting stories are last night tale that we are not being with - we've spent a lot of time together, so we evidently knew each other's daily stories. It is really interesting time for us. 


I really feel sorry for my lack of expression so that I cannot give my feelings amply. Anyways, I'm really like my usual morning. It gives me a lot of energy to bear my boring daily life. 


 

Posted by Cat.IanKang
,

Anything that is a ROOT, STEM, or LEAF of a plant qualifies as a VEGETABLE


FRUITS are the OVARIES of a FLOWERING PLANT that develop after its seeds are fertilized


BERRIES are FRUITS that come from a single ovary with multiple seeds. 


DRUPES only have one seed with a distinct skin covering a fleshy middle layer.


Raspberries and Blackberries are Aggregate drupes

Posted by Cat.IanKang
,

1. He has seniority over me in this industry (research area)


2. His performance has been strong. 


3. He's shown decent work performance.


4. Her on-the job performance has been stellar 


5. How's the new job treating you?


6.  How's the life in Korea treating you?


7. He's in finance.


8. What line of work are you in?


9. I've been really stressed out about this deal.


10. My goal is to be a doctor someday. 


11. He didn't live up to the boss's expectations. 

Posted by Cat.IanKang
,

In signal processing, a filter bank is an array of band-pass filters that separates the input signal into multiple components, each one carrying a single frequency sub-band of the original signal. The process of decomposition performed by the filter bank is called analysis which means analysis of the signal in terms of its components in each sub-band. The output of analysis is referred to as a sub-band signal with as many sub-bands as there are filters in the filter bank.  The reconstruction process is called synthesis, meaning reconstitution of a complete signal resulting from the filtering process. Following figure shows Gabor filter bank and its result. 





'Cat.Storage > SubCat.Research' 카테고리의 다른 글

Fourier transform pairs  (0) 2015.07.18
FFT & DFT  (0) 2015.07.10
What is CIELUV color space?  (0) 2015.05.26
k-means clustering  (0) 2015.05.23
On-the-fly multi-scale infinite texturing from example  (2) 2015.05.20
Posted by Cat.IanKang
,

URL: https://www.cs.auckland.ac.nz/courses/compsci708s1c/lectures/Glect-html/topic4c708FSC.htm

'Cat.Storage > SubCat.Gateway' 카테고리의 다른 글

Book  (0) 2015.09.03
The moon  (0) 2015.08.25
Fractals: Theory and Applications in Engineering  (0) 2015.07.21
UX/UI design site  (0) 2015.07.20
Blog (Tutorial Link)  (0) 2015.05.30
Posted by Cat.IanKang
,