Î¥»¶¥Õ¡¼¥ê¥¨ÊÑ´¹¤òÍѤ¤¤¿Â¿ÇÜĹ¾è»»¤ÎÏà ¤È¤«FFT¤òÍѤ¤¤ÆÂ¿ÇÜĹ¾è»»¤ò¤·¤Æ¤ß¤¿¤È¤« FFT¤Ë¤è¤ë¿ÇÜÀºÅ٤ξ軻¤È¤« ¿§¡¹¤¢¤ë¤±¤ì¤É¡¢FFTW¤ò»È¤Ã¤Æ¼ÂÁõ¤·¤¿¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¤Î¤Ç¡£ x[]¤Èy[]¤ÎŤµ¤Ï2¤ÎÎß¾è¤À¤È·×»»¤¬Áᤤ¤é¤·¤¤¡£¤Þ¤¿¡¢x[]¤Èy[]¤Ï¸å¤íȾʬ°Ê¾å¤ò0¤ÇËä¤á¤Þ¤¹¡£
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <fftw3.h>
int main(int argc, char* argv[])
{
// 231 x 11
float x[] = {2.0f, 3.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,};
float y[] = {1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,};
int n = sizeof(x)/sizeof(float);
int m = sizeof(y)/sizeof(float);
{
fftwf_plan p, q;
p = fftwf_plan_r2r_1d(n, x, x, FFTW_R2HC, FFTW_ESTIMATE);
q = fftwf_plan_r2r_1d(n, y, y, FFTW_R2HC, FFTW_ESTIMATE);
fftwf_execute(p);
fftwf_execute(q);
fftwf_destroy_plan(p);
fftwf_destroy_plan(q);
}
x[0] *= y[0];
x[n/2] *= y[n/2];
for (int j = 1; j < n/2; j++)
{
float e = x[j];
float d = x[n - j];
float f = y[j];
float g = y[n - j];
x[n - j] = e*g+f*d;
x[j] = e*f-d*g;
}
{
fftwf_plan p;
p = fftwf_plan_r2r_1d(n, x, x, FFTW_HC2R, FFTW_ESTIMATE);
fftwf_execute(p);
fftwf_destroy_plan(p);
}
for (int j = 0; j < n; j++)
{
x[j] = x[j]/n;
}
float xx = x[0];
for(int j = 0;j < n;j ++)
{
// ·å¤Î½èÍý¤Ï¾Êά
fprintf(stderr, "[%4d]%f\n", j, x[j]);
}
return 0;
}
cc -lfftw3f -lm
[ 0]2.000000
[ 1]5.000000
[ 2]4.000000
[ 3]1.000000
[ 4]-0.000000
[ 5]0.000000
[ 6]0.000000
[ 7]0.000000
If you go to see Silicon Valley, what you'll see are buildings. But it's the
people that make it Silicon Valley, not the buildings. I read occasionally
about attempts to set up "technology parks" in other places, as if the active
ingredient of Silicon Valley were the office space. An article about Sophia
Antipolis bragged that companies there included Cisco, Compaq, IBM, NCR, and
Nortel. Don't the French realize these aren't startups?
Building office buildings for technology companies won't get you a silicon
valley, because the key stage in the life of a startup happens before they
want that kind of space. The key stage is when they're three guys operating
out of an apartment. Wherever the startup is when it gets funded, it will
stay. The defining quality of Silicon Valley is not that Intel or Apple or
Google have offices there, but that they were started there.
So if you want to reproduce Silicon Valley, what you need to reproduce is
those two or three founders sitting around a kitchen table deciding to start a
company. And to reproduce that you need those people.
-- Paul Graham
-- How to Be Silicon Valley ( http://www.paulgraham.com/siliconvalley.html )
Imagine, for example, what would happen if the government decided to
commission someone to write an official Great American Novel. First there'd be
a huge ideological squabble over who to choose. Most of the best writers would
be excluded for having offended one side or the other. Of the remainder, the
smart ones would refuse such a job, leaving only a few with the wrong sort of
ambition. The committee would choose one at the height of his career—that is,
someone whose best work was behind him—and hand over the project with copious
free advice about how the book should show in positive terms the strength and
diversity of the American people, etc, etc.
The unfortunate writer would then sit down to work with a huge weight of
expectation on his shoulders. Not wanting to blow such a public commission,
he'd play it safe. This book had better command respect, and the way to ensure
that would be to make it a tragedy. Audiences have to be enticed to laugh, but
if you kill people they feel obliged to take you seriously. As everyone knows,
America plus tragedy equals the Civil War, so that's what it would have to be
about. Better stick to the standard cartoon version that the Civil War was
about slavery; people would be confused otherwise; plus you can show a lot of
strength and diversity. When finally completed twelve years later, the book
would be a 900-page pastiche of existing popular novels—roughly Gone with the
Wind plus Roots. But its bulk and celebrity would make it a bestseller for a
few months, until blown out of the water by a talk-show host's autobiography.
The book would be made into a movie and thereupon forgotten, except by the
more waspish sort of reviewers, among whom it would be a byword for bogusness
like Milli Vanilli or Battlefield Earth.
Maybe I got a little carried away with this example. And yet is this not at
each point the way such a project would play out? The government knows better
than to get into the novel business, but in other fields where they have a
natural monopoly, like nuclear waste dumps, aircraft carriers, and regime
change, you'd find plenty of projects isomorphic to this one—and indeed,
plenty that were less successful.
-- Paul Graham
-- The Power of the Marginal ( http://www.paulgraham.com/marginal.html )