@nexys/math-ts
Version:
[](https://www.npmjs.com/package/@nexys/math-ts) [](https://travis-ci.com/github/Nexysweb/math-ts) [ • 456 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const complex_1 = require("./complex");
exports.fft = (v) => {
const N = v.length;
if (N === 0) {
return [];
}
return v.map((_, k) => {
return v.map((x, i) => {
return x
.multiply(complex_1.exp(2 * Math.PI * k * i / N)
.multiply(1 / Math.sqrt(N)));
}).reduce((c1, c2) => c1.sum(c2));
});
};