dsp/fourier/internal/fftpack: fix formatting

This commit is contained in:
Dan Kortschak
2022-08-05 21:49:25 +09:30
parent 5f0141ca4c
commit aedb59a6f6
6 changed files with 323 additions and 324 deletions

View File

@@ -18,20 +18,20 @@ import (
// tabulation of the trigonometric functions are computed and // tabulation of the trigonometric functions are computed and
// stored in work. // stored in work.
// //
// input parameter // Input parameter:
// //
// n The length of the sequence to be transformed. // n The length of the sequence to be transformed.
// //
// Output parameters: // Output parameters:
// //
// work A work array which must be dimensioned at least 4*n. // work A work array which must be dimensioned at least 4*n.
// the same work array can be used for both Cfftf and Cfftb // the same work array can be used for both Cfftf and Cfftb
// as long as n remains unchanged. Different work arrays // as long as n remains unchanged. Different work arrays
// are required for different values of n. The contents of // are required for different values of n. The contents of
// work must not be changed between calls of Cfftf or Cfftb. // work must not be changed between calls of Cfftf or Cfftb.
// //
// ifac A work array containing the factors of n. ifac must have // ifac A work array containing the factors of n. ifac must have
// length 15. // length 15.
func Cffti(n int, work []float64, ifac []int) { func Cffti(n int, work []float64, ifac []int) {
if len(work) < 4*n { if len(work) < 4*n {
panic("fourier: short work") panic("fourier: short work")
@@ -121,46 +121,46 @@ outer:
// Fourier coefficients of a complex periodic sequence. The // Fourier coefficients of a complex periodic sequence. The
// transform is defined below at output parameter c. // transform is defined below at output parameter c.
// //
// Input parameters: // Input parameters:
// //
// n The length of the array c to be transformed. The method // n The length of the array c to be transformed. The method
// is most efficient when n is a product of small primes. // is most efficient when n is a product of small primes.
// n may change so long as different work arrays are provided. // n may change so long as different work arrays are provided.
// //
// c A complex array of length n which contains the sequence // c A complex array of length n which contains the sequence
// to be transformed. // to be transformed.
// //
// work A real work array which must be dimensioned at least 4*n. // work A real work array which must be dimensioned at least 4*n.
// in the program that calls Cfftf. The work array must be // in the program that calls Cfftf. The work array must be
// initialized by calling subroutine Cffti(n,work,ifac) and a // initialized by calling subroutine Cffti(n,work,ifac) and a
// different work array must be used for each different // different work array must be used for each different
// value of n. This initialization does not have to be // value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent // repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first. // transforms can be obtained faster than the first.
// the same work array can be used by Cfftf and Cfftb. // the same work array can be used by Cfftf and Cfftb.
// //
// ifac A work array containing the factors of n. ifac must have // ifac A work array containing the factors of n. ifac must have
// length of at least 15. // length of at least 15.
// //
// Output parameters: // Output parameters:
// //
// c for j=0, ..., n-1 // c for j=0, ..., n-1
// c[j]=the sum from k=0, ..., n-1 of // c[j]=the sum from k=0, ..., n-1 of
// c[k]*exp(-i*j*k*2*pi/n) // c[k]*exp(-i*j*k*2*pi/n)
// //
// where i=sqrt(-1) // where i=sqrt(-1)
// //
// This transform is unnormalized since a call of Cfftf // This transform is unnormalized since a call of Cfftf
// followed by a call of Cfftb will multiply the input // followed by a call of Cfftb will multiply the input
// sequence by n. // sequence by n.
// //
// The n elements of c are represented in n pairs of real // The n elements of c are represented in n pairs of real
// values in r where c[j] = r[j*2]+r[j*2+1]i. // values in r where c[j] = r[j*2]+r[j*2+1]i.
// //
// work Contains results which must not be destroyed between // work Contains results which must not be destroyed between
// calls of Cfftf or Cfftb. // calls of Cfftf or Cfftb.
// ifac Contains results which must not be destroyed between // ifac Contains results which must not be destroyed between
// calls of Cfftf or Cfftb. // calls of Cfftf or Cfftb.
func Cfftf(n int, r, work []float64, ifac []int) { func Cfftf(n int, r, work []float64, ifac []int) {
if len(r) < 2*n { if len(r) < 2*n {
panic("fourier: short sequence") panic("fourier: short sequence")
@@ -182,46 +182,46 @@ func Cfftf(n int, r, work []float64, ifac []int) {
// a complex periodic sequence from its Fourier coefficients. The // a complex periodic sequence from its Fourier coefficients. The
// transform is defined below at output parameter c. // transform is defined below at output parameter c.
// //
// Input parameters: // Input parameters:
// //
// n The length of the array c to be transformed. The method // n The length of the array c to be transformed. The method
// is most efficient when n is a product of small primes. // is most efficient when n is a product of small primes.
// n may change so long as different work arrays are provided. // n may change so long as different work arrays are provided.
// //
// c A complex array of length n which contains the sequence // c A complex array of length n which contains the sequence
// to be transformed. // to be transformed.
// //
// work A real work array which must be dimensioned at least 4*n. // work A real work array which must be dimensioned at least 4*n.
// in the program that calls Cfftb. The work array must be // in the program that calls Cfftb. The work array must be
// initialized by calling subroutine Cffti(n,work,ifac) and a // initialized by calling subroutine Cffti(n,work,ifac) and a
// different work array must be used for each different // different work array must be used for each different
// value of n. This initialization does not have to be // value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent // repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first. // transforms can be obtained faster than the first.
// The same work array can be used by Cfftf and Cfftb. // The same work array can be used by Cfftf and Cfftb.
// //
// ifac A work array containing the factors of n. ifac must have // ifac A work array containing the factors of n. ifac must have
// length of at least 15. // length of at least 15.
// //
// Output parameters: // Output parameters:
// //
// c for j=0, ..., n-1 // c for j=0, ..., n-1
// c[j]=the sum from k=0, ..., n-1 of // c[j]=the sum from k=0, ..., n-1 of
// c[k]*exp(i*j*k*2*pi/n) // c[k]*exp(i*j*k*2*pi/n)
// //
// where i=sqrt(-1) // where i=sqrt(-1)
// //
// This transform is unnormalized since a call of Cfftf // This transform is unnormalized since a call of Cfftf
// followed by a call of Cfftb will multiply the input // followed by a call of Cfftb will multiply the input
// sequence by n. // sequence by n.
// //
// The n elements of c are represented in n pairs of real // The n elements of c are represented in n pairs of real
// values in r where c[j] = r[j*2]+r[j*2+1]i. // values in r where c[j] = r[j*2]+r[j*2+1]i.
// //
// work Contains results which must not be destroyed between // work Contains results which must not be destroyed between
// calls of Cfftf or Cfftb. // calls of Cfftf or Cfftb.
// ifac Contains results which must not be destroyed between // ifac Contains results which must not be destroyed between
// calls of Cfftf or Cfftb. // calls of Cfftf or Cfftb.
func Cfftb(n int, c, work []float64, ifac []int) { func Cfftb(n int, c, work []float64, ifac []int) {
if len(c) < 2*n { if len(c) < 2*n {
panic("fourier: short sequence") panic("fourier: short sequence")

View File

@@ -15,20 +15,20 @@ import "math"
// tabulation of the trigonometric functions are computed and // tabulation of the trigonometric functions are computed and
// stored in work. // stored in work.
// //
// Input parameter // Input parameter:
// //
// n The length of the sequence to be transformed. the method // n The length of the sequence to be transformed. the method
// is most efficient when n+1 is a product of small primes. // is most efficient when n+1 is a product of small primes.
// //
// Output parameters // Output parameters:
// //
// work A work array which must be dimensioned at least 3*n. // work A work array which must be dimensioned at least 3*n.
// The same work array can be used for both Cosqf and Cosqb // The same work array can be used for both Cosqf and Cosqb
// as long as n remains unchanged. Different work arrays // as long as n remains unchanged. Different work arrays
// are required for different values of n. The contents of // are required for different values of n. The contents of
// work must not be changed between calls of Cosqf or Cosqb. // work must not be changed between calls of Cosqf or Cosqb.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
func Cosqi(n int, work []float64, ifac []int) { func Cosqi(n int, work []float64, ifac []int) {
if len(work) < 3*n { if len(work) < 3*n {
panic("fourier: short work") panic("fourier: short work")
@@ -55,36 +55,36 @@ func Cosqi(n int, work []float64, ifac []int) {
// The array work which is used by subroutine Cosqf must be // The array work which is used by subroutine Cosqf must be
// initialized by calling subroutine Cosqi(n,work). // initialized by calling subroutine Cosqi(n,work).
// //
// Input parameters // Input parameters:
// //
// n The length of the array x to be transformed. The method // n The length of the array x to be transformed. The method
// is most efficient when n is a product of small primes. // is most efficient when n is a product of small primes.
// //
// x An array which contains the sequence to be transformed. // x An array which contains the sequence to be transformed.
// //
// work A work array which must be dimensioned at least 3*n // work A work array which must be dimensioned at least 3*n
// in the program that calls Cosqf. The work array must be // in the program that calls Cosqf. The work array must be
// initialized by calling subroutine Cosqi(n,work) and a // initialized by calling subroutine Cosqi(n,work) and a
// different work array must be used for each different // different work array must be used for each different
// value of n. This initialization does not have to be // value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent // repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first. // transforms can be obtained faster than the first.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
// //
// Output parameters // Output parameters:
// //
// x for i=0, ..., n-1 // x for i=0, ..., n-1
// x[i] = x[i] + the sum from k=0 to k=n-2 of // x[i] = x[i] + the sum from k=0 to k=n-2 of
// 2*x[k]*cos((2*i+1)*k*pi/(2*n)) // 2*x[k]*cos((2*i+1)*k*pi/(2*n))
// //
// A call of Cosqf followed by a call of // A call of Cosqf followed by a call of
// Cosqb will multiply the sequence x by 4*n. // Cosqb will multiply the sequence x by 4*n.
// Therefore Cosqb is the unnormalized inverse // Therefore Cosqb is the unnormalized inverse
// of Cosqf. // of Cosqf.
// //
// work Contains initialization calculations which must not // work Contains initialization calculations which must not
// be destroyed between calls of Cosqf or Cosqb. // be destroyed between calls of Cosqf or Cosqb.
func Cosqf(n int, x, work []float64, ifac []int) { func Cosqf(n int, x, work []float64, ifac []int) {
if len(x) < n { if len(x) < n {
panic("fourier: short sequence") panic("fourier: short sequence")
@@ -142,37 +142,36 @@ func cosqf1(n int, x, w, xh []float64, ifac []int) {
// The array work which is used by subroutine Cosqb must be // The array work which is used by subroutine Cosqb must be
// initialized by calling subroutine Cosqi(n,work). // initialized by calling subroutine Cosqi(n,work).
// //
// Input parameters:
// //
// Input parameters // n The length of the array x to be transformed. The method
// is most efficient when n is a product of small primes.
// //
// n The length of the array x to be transformed. The method // x An array which contains the sequence to be transformed.
// is most efficient when n is a product of small primes.
// //
// x An array which contains the sequence to be transformed. // work A work array which must be dimensioned at least 3*n
// in the program that calls Cosqb. The work array must be
// initialized by calling subroutine Cosqi(n,work) and a
// different work array must be used for each different
// value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first.
// //
// work A work array which must be dimensioned at least 3*n // ifac An integer work array of length at least 15.
// in the program that calls Cosqb. The work array must be
// initialized by calling subroutine Cosqi(n,work) and a
// different work array must be used for each different
// value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first.
// //
// ifac An integer work array of length at least 15. // Output parameters:
// //
// Output parameters // x for i=0, ..., n-1
// x[i]= the sum from k=0 to k=n-1 of
// 4*x[k]*cos((2*k+1)*i*pi/(2*n))
// //
// x for i=0, ..., n-1 // A call of Cosqb followed by a call of
// x[i]= the sum from k=0 to k=n-1 of // Cosqf will multiply the sequence x by 4*n.
// 4*x[k]*cos((2*k+1)*i*pi/(2*n)) // Therefore Cosqf is the unnormalized inverse
// of Cosqb.
// //
// A call of Cosqb followed by a call of // work Contains initialization calculations which must not
// Cosqf will multiply the sequence x by 4*n. // be destroyed between calls of Cosqb or Cosqf.
// Therefore Cosqf is the unnormalized inverse
// of Cosqb.
//
// work Contains initialization calculations which must not
// be destroyed between calls of Cosqb or Cosqf.
func Cosqb(n int, x, work []float64, ifac []int) { func Cosqb(n int, x, work []float64, ifac []int) {
if len(x) < n { if len(x) < n {
panic("fourier: short sequence") panic("fourier: short sequence")

View File

@@ -14,19 +14,19 @@ import "math"
// Cost. The prime factorization of n together with a tabulation // Cost. The prime factorization of n together with a tabulation
// of the trigonometric functions are computed and stored in work. // of the trigonometric functions are computed and stored in work.
// //
// Input parameter // Input parameter:
// //
// n The length of the sequence to be transformed. The method // n The length of the sequence to be transformed. The method
// is most efficient when n-1 is a product of small primes. // is most efficient when n-1 is a product of small primes.
// //
// Output parameters // Output parameters:
// //
// work A work array which must be dimensioned at least 3*n. // work A work array which must be dimensioned at least 3*n.
// Different work arrays are required for different values // Different work arrays are required for different values
// of n. The contents of work must not be changed between // of n. The contents of work must not be changed between
// calls of Cost. // calls of Cost.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
func Costi(n int, work []float64, ifac []int) { func Costi(n int, work []float64, ifac []int) {
if len(work) < 3*n { if len(work) < 3*n {
panic("fourier: short work") panic("fourier: short work")
@@ -56,40 +56,40 @@ func Costi(n int, work []float64, ifac []int) {
// The array work which is used by subroutine Cost must be // The array work which is used by subroutine Cost must be
// initialized by calling subroutine Costi(n,work). // initialized by calling subroutine Costi(n,work).
// //
// Input parameters // Input parameters:
// //
// n The length of the sequence x. n must be greater than 1. // n The length of the sequence x. n must be greater than 1.
// The method is most efficient when n-1 is a product of // The method is most efficient when n-1 is a product of
// small primes. // small primes.
// //
// x An array which contains the sequence to be transformed. // x An array which contains the sequence to be transformed.
// //
// work A work array which must be dimensioned at least 3*n // work A work array which must be dimensioned at least 3*n
// in the program that calls Cost. The work array must be // in the program that calls Cost. The work array must be
// initialized by calling subroutine Costi(n,work) and a // initialized by calling subroutine Costi(n,work) and a
// different work array must be used for each different // different work array must be used for each different
// value of n. This initialization does not have to be // value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent // repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first. // transforms can be obtained faster than the first.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
// //
// Output parameters // Output parameters:
// //
// x for i=1,...,n // x for i=1,...,n
// x(i) = x(1)+(-1)**(i-1)*x(n) // x(i) = x(1)+(-1)**(i-1)*x(n)
// + the sum from k=2 to k=n-1 // + the sum from k=2 to k=n-1
// 2*x(k)*cos((k-1)*(i-1)*pi/(n-1)) // 2*x(k)*cos((k-1)*(i-1)*pi/(n-1))
// //
// A call of Cost followed by another call of // A call of Cost followed by another call of
// Cost will multiply the sequence x by 2*(n-1). // Cost will multiply the sequence x by 2*(n-1).
// Hence Cost is the unnormalized inverse // Hence Cost is the unnormalized inverse
// of itself. // of itself.
// //
// work Contains initialization calculations which must not be // work Contains initialization calculations which must not be
// destroyed between calls of Cost. // destroyed between calls of Cost.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
func Cost(n int, x, work []float64, ifac []int) { func Cost(n int, x, work []float64, ifac []int) {
if len(x) < n { if len(x) < n {
panic("fourier: short sequence") panic("fourier: short sequence")

View File

@@ -18,20 +18,20 @@ import (
// tabulation of the trigonometric functions are computed and // tabulation of the trigonometric functions are computed and
// stored in work. // stored in work.
// //
// Input parameter: // Input parameter:
// //
// n The length of the sequence to be transformed. // n The length of the sequence to be transformed.
// //
// Output parameters: // Output parameters:
// //
// work A work array which must be dimensioned at least 2*n. // work A work array which must be dimensioned at least 2*n.
// The same work array can be used for both Rfftf and Rfftb // The same work array can be used for both Rfftf and Rfftb
// as long as n remains unchanged. different work arrays // as long as n remains unchanged. different work arrays
// are required for different values of n. The contents of // are required for different values of n. The contents of
// work must not be changed between calls of Rfftf or Rfftb. // work must not be changed between calls of Rfftf or Rfftb.
// //
// ifac A work array containing the factors of n. ifac must have // ifac A work array containing the factors of n. ifac must have
// length of at least 15. // length of at least 15.
func Rffti(n int, work []float64, ifac []int) { func Rffti(n int, work []float64, ifac []int) {
if len(work) < 2*n { if len(work) < 2*n {
panic("fourier: short work") panic("fourier: short work")
@@ -117,50 +117,50 @@ outer:
// (Fourier analysis). The transform is defined below at output // (Fourier analysis). The transform is defined below at output
// parameter r. // parameter r.
// //
// Input parameters: // Input parameters:
// //
// n The length of the array r to be transformed. The method // n The length of the array r to be transformed. The method
// is most efficient when n is a product of small primes. // is most efficient when n is a product of small primes.
// n may change so long as different work arrays are provided. // n may change so long as different work arrays are provided.
// //
// r A real array of length n which contains the sequence // r A real array of length n which contains the sequence
// to be transformed. // to be transformed.
// //
// work a work array which must be dimensioned at least 2*n. // work a work array which must be dimensioned at least 2*n.
// in the program that calls Rfftf. the work array must be // in the program that calls Rfftf. the work array must be
// initialized by calling subroutine rffti(n,work,ifac) and a // initialized by calling subroutine rffti(n,work,ifac) and a
// different work array must be used for each different // different work array must be used for each different
// value of n. This initialization does not have to be // value of n. This initialization does not have to be
// repeated so long as n remains unchanged. Thus subsequent // repeated so long as n remains unchanged. Thus subsequent
// transforms can be obtained faster than the first. // transforms can be obtained faster than the first.
// The same work array can be used by Rfftf and Rfftb. // The same work array can be used by Rfftf and Rfftb.
// //
// ifac A work array containing the factors of n. ifac must have // ifac A work array containing the factors of n. ifac must have
// length of at least 15. // length of at least 15.
// //
// Output parameters: // Output parameters:
// //
// r r[0] = the sum from i=0 to i=n-1 of r[i] // r r[0] = the sum from i=0 to i=n-1 of r[i]
// //
// if n is even set l=n/2, if n is odd set l = (n+1)/2 // if n is even set l=n/2, if n is odd set l = (n+1)/2
// then for k = 1, ..., l-1 // then for k = 1, ..., l-1
// r[2*k-1] = the sum from i = 0 to i = n-1 of // r[2*k-1] = the sum from i = 0 to i = n-1 of
// r[i]*cos(k*i*2*pi/n) // r[i]*cos(k*i*2*pi/n)
// r[2*k] = the sum from i = 0 to i = n-1 of // r[2*k] = the sum from i = 0 to i = n-1 of
// -r[i]*sin(k*i*2*pi/n) // -r[i]*sin(k*i*2*pi/n)
// //
// if n is even // if n is even
// r[n-1] = the sum from i = 0 to i = n-1 of // r[n-1] = the sum from i = 0 to i = n-1 of
// (-1)^i*r[i] // (-1)^i*r[i]
// //
// This transform is unnormalized since a call of Rfftf // This transform is unnormalized since a call of Rfftf
// followed by a call of Rfftb will multiply the input // followed by a call of Rfftb will multiply the input
// sequence by n. // sequence by n.
// //
// work contains results which must not be destroyed between // work contains results which must not be destroyed between
// calls of Rfftf or Rfftb. // calls of Rfftf or Rfftb.
// ifac contains results which must not be destroyed between // ifac contains results which must not be destroyed between
// calls of Rfftf or Rfftb. // calls of Rfftf or Rfftb.
func Rfftf(n int, r, work []float64, ifac []int) { func Rfftf(n int, r, work []float64, ifac []int) {
if len(r) < n { if len(r) < n {
panic("fourier: short sequence") panic("fourier: short sequence")
@@ -592,48 +592,48 @@ func radfg(ido, ip, l1, idl1 int, cc, c1, c2, ch, ch2, wa []float64) {
// coefficients (Fourier synthesis). The transform is defined // coefficients (Fourier synthesis). The transform is defined
// below at output parameter r. // below at output parameter r.
// //
// Input parameters // Input parameters
// //
// n The length of the array r to be transformed. The method // n The length of the array r to be transformed. The method
// is most efficient when n is a product of small primes. // is most efficient when n is a product of small primes.
// n may change so long as different work arrays are provided. // n may change so long as different work arrays are provided.
// //
// r A real array of length n which contains the sequence // r A real array of length n which contains the sequence
// to be transformed. // to be transformed.
// //
// work A work array which must be dimensioned at least 2*n. // work A work array which must be dimensioned at least 2*n.
// in the program that calls Rfftb. The work array must be // in the program that calls Rfftb. The work array must be
// initialized by calling subroutine rffti(n,work,ifac) and a // initialized by calling subroutine rffti(n,work,ifac) and a
// different work array must be used for each different // different work array must be used for each different
// value of n. This initialization does not have to be // value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent // repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first. // transforms can be obtained faster than the first.
// The same work array can be used by Rfftf and Rfftb. // The same work array can be used by Rfftf and Rfftb.
// //
// ifac A work array containing the factors of n. ifac must have // ifac A work array containing the factors of n. ifac must have
// length of at least 15. // length of at least 15.
// //
// output parameters // output parameters
// //
// r for n even and for i = 0, ..., n // r for n even and for i = 0, ..., n
// r[i] = r[0]+(-1)^i*r[n-1] // r[i] = r[0]+(-1)^i*r[n-1]
// plus the sum from k=1 to k=n/2-1 of // plus the sum from k=1 to k=n/2-1 of
// 2*r(2*k-1)*cos(k*i*2*pi/n) // 2*r(2*k-1)*cos(k*i*2*pi/n)
// -2*r(2*k)*sin(k*i*2*pi/n) // -2*r(2*k)*sin(k*i*2*pi/n)
// //
// for n odd and for i = 0, ..., n-1 // for n odd and for i = 0, ..., n-1
// r[i] = r[0] plus the sum from k=1 to k=(n-1)/2 of // r[i] = r[0] plus the sum from k=1 to k=(n-1)/2 of
// 2*r(2*k-1)*cos(k*i*2*pi/n) // 2*r(2*k-1)*cos(k*i*2*pi/n)
// -2*r(2*k)*sin(k*i*2*pi/n) // -2*r(2*k)*sin(k*i*2*pi/n)
// //
// This transform is unnormalized since a call of Rfftf // This transform is unnormalized since a call of Rfftf
// followed by a call of Rfftb will multiply the input // followed by a call of Rfftb will multiply the input
// sequence by n. // sequence by n.
// //
// work Contains results which must not be destroyed between // work Contains results which must not be destroyed between
// calls of Rfftf or Rfftb. // calls of Rfftf or Rfftb.
// ifac Contains results which must not be destroyed between // ifac Contains results which must not be destroyed between
// calls of Rfftf or Rfftb. // calls of Rfftf or Rfftb.
func Rfftb(n int, r, work []float64, ifac []int) { func Rfftb(n int, r, work []float64, ifac []int) {
if len(r) < n { if len(r) < n {
panic("fourier: short sequence") panic("fourier: short sequence")

View File

@@ -14,20 +14,20 @@ import "math"
// Sinqb. The prime factorization of n together with a tabulation // Sinqb. The prime factorization of n together with a tabulation
// of the trigonometric functions are computed and stored in work. // of the trigonometric functions are computed and stored in work.
// //
// Input parameter // Input parameter:
// //
// n The length of the sequence to be transformed. The method // n The length of the sequence to be transformed. The method
// is most efficient when n+1 is a product of small primes. // is most efficient when n+1 is a product of small primes.
// //
// Output parameter // Output parameter:
// //
// work A work array which must be dimensioned at least 3*n. // work A work array which must be dimensioned at least 3*n.
// The same work array can be used for both Sinqf and Sinqb // The same work array can be used for both Sinqf and Sinqb
// as long as n remains unchanged. Different work arrays // as long as n remains unchanged. Different work arrays
// are required for different values of n. The contents of // are required for different values of n. The contents of
// work must not be changed between calls of Sinqf or Sinqb. // work must not be changed between calls of Sinqf or Sinqb.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
func Sinqi(n int, work []float64, ifac []int) { func Sinqi(n int, work []float64, ifac []int) {
if len(work) < 3*n { if len(work) < 3*n {
panic("fourier: short work") panic("fourier: short work")
@@ -54,37 +54,37 @@ func Sinqi(n int, work []float64, ifac []int) {
// The array work which is used by subroutine Sinqf must be // The array work which is used by subroutine Sinqf must be
// initialized by calling subroutine Sinqi(n,work). // initialized by calling subroutine Sinqi(n,work).
// //
// Input parameters // Input parameters:
// //
// n The length of the array x to be transformed. The method // n The length of the array x to be transformed. The method
// is most efficient when n is a product of small primes. // is most efficient when n is a product of small primes.
// //
// x An array which contains the sequence to be transformed. // x An array which contains the sequence to be transformed.
// //
// work A work array which must be dimensioned at least 3*n. // work A work array which must be dimensioned at least 3*n.
// in the program that calls Sinqf. The work array must be // in the program that calls Sinqf. The work array must be
// initialized by calling subroutine Sinqi(n,work) and a // initialized by calling subroutine Sinqi(n,work) and a
// different work array must be used for each different // different work array must be used for each different
// value of n. This initialization does not have to be // value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent // repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first. // transforms can be obtained faster than the first.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
// //
// Output parameters // Output parameters:
// //
// x for i=0, ..., n-1 // x for i=0, ..., n-1
// x[i] = (-1)^(i)*x[n-1] // x[i] = (-1)^(i)*x[n-1]
// + the sum from k=0 to k=n-2 of // + the sum from k=0 to k=n-2 of
// 2*x[k]*sin((2*i+1)*k*pi/(2*n)) // 2*x[k]*sin((2*i+1)*k*pi/(2*n))
// //
// A call of Sinqf followed by a call of // A call of Sinqf followed by a call of
// Sinqb will multiply the sequence x by 4*n. // Sinqb will multiply the sequence x by 4*n.
// Therefore Sinqb is the unnormalized inverse // Therefore Sinqb is the unnormalized inverse
// of Sinqf. // of Sinqf.
// //
// work Contains initialization calculations which must not // work Contains initialization calculations which must not
// be destroyed between calls of Sinqf or Sinqb. // be destroyed between calls of Sinqf or Sinqb.
func Sinqf(n int, x, work []float64, ifac []int) { func Sinqf(n int, x, work []float64, ifac []int) {
if len(x) < n { if len(x) < n {
panic("fourier: short sequence") panic("fourier: short sequence")
@@ -120,36 +120,36 @@ func Sinqf(n int, x, work []float64, ifac []int) {
// The array work which is used by subroutine Sinqb must be // The array work which is used by subroutine Sinqb must be
// initialized by calling subroutine Sinqi(n,work). // initialized by calling subroutine Sinqi(n,work).
// //
// Input parameters // Input parameters:
// //
// n The length of the array x to be transformed. The method // n The length of the array x to be transformed. The method
// is most efficient when n is a product of small primes. // is most efficient when n is a product of small primes.
// //
// x An array which contains the sequence to be transformed. // x An array which contains the sequence to be transformed.
// //
// work A work array which must be dimensioned at least 3*n. // work A work array which must be dimensioned at least 3*n.
// in the program that calls Sinqb. The work array must be // in the program that calls Sinqb. The work array must be
// initialized by calling subroutine Sinqi(n,work) and a // initialized by calling subroutine Sinqi(n,work) and a
// different work array must be used for each different // different work array must be used for each different
// value of n. This initialization does not have to be // value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent // repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first. // transforms can be obtained faster than the first.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
// //
// Output parameters // Output parameters:
// //
// x for i=0, ..., n-1 // x for i=0, ..., n-1
// x[i]= the sum from k=0 to k=n-1 of // x[i]= the sum from k=0 to k=n-1 of
// 4*x[k]*sin((2*k+1)*i*pi/(2*n)) // 4*x[k]*sin((2*k+1)*i*pi/(2*n))
// //
// A call of Sinqb followed by a call of // A call of Sinqb followed by a call of
// Sinqf will multiply the sequence x by 4*n. // Sinqf will multiply the sequence x by 4*n.
// Therefore Sinqf is the unnormalized inverse // Therefore Sinqf is the unnormalized inverse
// of Sinqb. // of Sinqb.
// //
// work Contains initialization calculations which must not // work Contains initialization calculations which must not
// be destroyed between calls of Sinqb or Sinqf. // be destroyed between calls of Sinqb or Sinqf.
func Sinqb(n int, x, work []float64, ifac []int) { func Sinqb(n int, x, work []float64, ifac []int) {
if len(x) < n { if len(x) < n {
panic("fourier: short sequence") panic("fourier: short sequence")

View File

@@ -14,19 +14,19 @@ import "math"
// The prime factorization of n together with a tabulation of the // The prime factorization of n together with a tabulation of the
// trigonometric functions are computed and stored in work. // trigonometric functions are computed and stored in work.
// //
// Input parameter // Input parameter:
// //
// n The length of the sequence to be transformed. The method // n The length of the sequence to be transformed. The method
// is most efficient when n+1 is a product of small primes. // is most efficient when n+1 is a product of small primes.
// //
// Output parameter // Output parameter:
// //
// work A work array with at least ceil(2.5*n) locations. // work A work array with at least ceil(2.5*n) locations.
// Different work arrays are required for different values // Different work arrays are required for different values
// of n. The contents of work must not be changed between // of n. The contents of work must not be changed between
// calls of Sint. // calls of Sint.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
func Sinti(n int, work []float64, ifac []int) { func Sinti(n int, work []float64, ifac []int) {
if len(work) < 5*(n+1)/2 { if len(work) < 5*(n+1)/2 {
panic("fourier: short work") panic("fourier: short work")
@@ -54,39 +54,39 @@ func Sinti(n int, work []float64, ifac []int) {
// The array work which is used by subroutine Sint must be // The array work which is used by subroutine Sint must be
// initialized by calling subroutine Sinti(n,work). // initialized by calling subroutine Sinti(n,work).
// //
// Input parameters // Input parameters:
// //
// n The length of the sequence to be transformed. The method // n The length of the sequence to be transformed. The method
// is most efficient when n+1 is the product of small primes. // is most efficient when n+1 is the product of small primes.
// //
// x An array which contains the sequence to be transformed. // x An array which contains the sequence to be transformed.
// //
// //
// work A work array with dimension at least ceil(2.5*n) // work A work array with dimension at least ceil(2.5*n)
// in the program that calls Sint. The work array must be // in the program that calls Sint. The work array must be
// initialized by calling subroutine Sinti(n,work) and a // initialized by calling subroutine Sinti(n,work) and a
// different work array must be used for each different // different work array must be used for each different
// value of n. This initialization does not have to be // value of n. This initialization does not have to be
// repeated so long as n remains unchanged thus subsequent // repeated so long as n remains unchanged thus subsequent
// transforms can be obtained faster than the first. // transforms can be obtained faster than the first.
// //
// ifac An integer work array of length at least 15. // ifac An integer work array of length at least 15.
// //
// Output parameters // Output parameters:
// //
// x for i=1,...,n // x for i=1,...,n
// x(i)= the sum from k=1 to k=n // x(i)= the sum from k=1 to k=n
// 2*x(k)*sin(k*i*pi/(n+1)) // 2*x(k)*sin(k*i*pi/(n+1))
// //
// A call of Sint followed by another call of // A call of Sint followed by another call of
// Sint will multiply the sequence x by 2*(n+1). // Sint will multiply the sequence x by 2*(n+1).
// Hence Sint is the unnormalized inverse // Hence Sint is the unnormalized inverse
// of itself. // of itself.
// //
// work Contains initialization calculations which must not be // work Contains initialization calculations which must not be
// destroyed between calls of Sint. // destroyed between calls of Sint.
// ifac Contains initialization calculations which must not be // ifac Contains initialization calculations which must not be
// destroyed between calls of Sint. // destroyed between calls of Sint.
func Sint(n int, x, work []float64, ifac []int) { func Sint(n int, x, work []float64, ifac []int) {
if len(x) < n { if len(x) < n {
panic("fourier: short sequence") panic("fourier: short sequence")