Merged master 8748
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
64
|
||||
16
|
||||
48
|
||||
14
|
||||
5
|
||||
3 1 3 6 1 4 1 1 1 1 2 1 1 1 1 6 6 2 2 1 1 2 2 1 2 6 2 6 1 1 2 1 1 6 3 2 6 2 1 1 6 1 1 2 1 1 1 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
4 2 4 9 3 6 2 2 3 2 4 2 3 3 3 7 9 6 4 3 2 6 6 2 4 9 6 7 2 2 4 3 3 7 4 4 7 4 3 3 7 2 2 6 3 2 2 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
6 3 6 10 4 9 4 4 4 4 5 4 4 4 4 8 10 8 5 4 3 7 7 4 6 13 9 9 4 4 5 4 4 8 6 5 8 5 4 4 9 4 4 8 4 3 4 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
7 4 12 12 6 12 5 5 6 5 6 5 5 6 6 9 11 9 6 5 4 11 9 5 7 0 10 10 5 5 6 6 5 9 8 6 11 6 5 5 11 5 5 9 6 4 5 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
9 5 16 15 9 15 6 6 7 6 7 6 6 9 7 10 12 11 8 6 5 13 13 6 8 0 11 11 6 6 9 8 6 11 11 8 12 7 6 6 13 6 6 12 10 5 6 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
10 6 0 16 11 16 8 7 9 8 8 7 7 12 8 11 13 13 9 11 6 14 14 8 9 0 13 12 8 9 11 9 7 12 12 10 13 8 8 7 0 8 7 15 12 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
13 8 0 0 13 0 10 8 13 9 10 10 9 13 9 12 14 15 11 13 7 16 16 9 13 0 15 13 10 11 16 11 11 13 16 12 14 9 11 10 0 9 11 0 13 12 9 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
15 12 0 0 14 0 11 10 15 11 12 11 10 15 11 13 15 0 13 14 12 0 0 12 14 0 0 14 14 13 0 14 13 0 0 15 0 11 12 13 0 10 12 0 15 13 10 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 13 0 0 15 0 12 12 16 12 14 14 14 16 14 14 0 0 15 15 14 0 0 13 0 0 0 15 15 15 0 15 14 0 0 16 0 13 13 14 0 12 14 0 16 14 11 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 15 0 0 16 0 14 14 0 13 15 0 16 0 16 16 0 0 16 16 15 0 0 14 0 0 0 16 0 16 0 16 16 0 0 0 0 14 15 16 0 14 15 0 0 15 12 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 16 0 0 0 0 15 15 0 15 16 0 0 0 0 0 0 0 0 0 16 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 15 16 0 0 15 0 0 0 16 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 16 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 9 49 58 64
|
||||
2 39 50 59 0
|
||||
3 6 51 57 63
|
||||
4 6 52 58 0
|
||||
5 20 53 57 0
|
||||
4 37 48 60 0
|
||||
7 36 49 59 62
|
||||
8 29 55 60 0
|
||||
9 14 55 60 0
|
||||
10 30 56 60 0
|
||||
11 31 48 61 64
|
||||
12 24 48 62 0
|
||||
13 40 57 61 0
|
||||
1 35 48 62 0
|
||||
15 32 55 63 0
|
||||
16 28 56 63 0
|
||||
17 28 55 64 0
|
||||
18 27 56 58 0
|
||||
19 31 56 61 63
|
||||
5 32 56 61 0
|
||||
21 43 51 59 64
|
||||
22 23 57 59 0
|
||||
22 44 48 58 0
|
||||
12 43 58 60 63
|
||||
25 38 53 59 63
|
||||
26 41 55 59 0
|
||||
18 44 59 60 61
|
||||
17 27 50 60 62
|
||||
29 42 57 60 64
|
||||
8 30 48 63 0
|
||||
19 38 55 62 64
|
||||
15 45 48 64 0
|
||||
20 33 55 63 0
|
||||
34 41 56 60 0
|
||||
14 45 57 58 0
|
||||
11 36 55 62 0
|
||||
34 37 57 62 0
|
||||
7 47 57 61 0
|
||||
2 46 56 62 0
|
||||
33 40 58 59 0
|
||||
3 35 56 59 0
|
||||
10 47 58 62 0
|
||||
21 46 55 61 0
|
||||
23 25 52 56 64
|
||||
13 39 48 64 0
|
||||
26 54 57 61 0
|
||||
24 42 58 61 0
|
||||
16 48 54 63 0
|
||||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
||||
@@ -1,18 +0,0 @@
|
||||
/* ALLOC.H - Interface to memory allocation procedure. */
|
||||
|
||||
/* Copyright (c) 1995-2012 by Radford M. Neal.
|
||||
*
|
||||
* Permission is granted for anyone to copy, use, modify, and distribute
|
||||
* these programs and accompanying documents for any purpose, provided
|
||||
* this copyright notice is retained and prominently displayed, and note
|
||||
* is made of any changes made to these programs. These programs and
|
||||
* documents are distributed without any warranty, express or implied.
|
||||
* As the programs were written for research purposes only, they have not
|
||||
* been tested to the degree that would be advisable in any important
|
||||
* application. All use of these programs is entirely at the user's own
|
||||
* risk.
|
||||
*/
|
||||
|
||||
|
||||
void *chk_alloc (unsigned, unsigned); /* Calls 'calloc' and exits with error
|
||||
if it fails */
|
||||
@@ -1,76 +0,0 @@
|
||||
program t3
|
||||
|
||||
parameter (NBLK=3456,NZ=10*NBLK)
|
||||
real x0(NZ)
|
||||
real x1(NZ)
|
||||
|
||||
twopi=8.0*atan(1.0)
|
||||
dphi=twopi*1000.0/12000.0
|
||||
phi=0.
|
||||
do i=1,NZ
|
||||
phi=phi+dphi
|
||||
x0(i)=sin(phi)
|
||||
if(mod(i,10007).eq.100) x0(i)=2.0
|
||||
enddo
|
||||
|
||||
do j=1,10
|
||||
ib=j*NBLK
|
||||
ia=ib-NBLK+1
|
||||
call filter(x0(ia:ib),x1(ia:ib))
|
||||
enddo
|
||||
|
||||
x1(1:NZ-NBLK)=x1(NBLK+1:NZ)
|
||||
do i=1,NZ-NBLK
|
||||
write(13,1001) i,x0(i),x1(i),x1(i)-x0(i)
|
||||
1001 format(i6,3f13.9)
|
||||
enddo
|
||||
|
||||
end program t3
|
||||
|
||||
subroutine filter(x0,x1)
|
||||
|
||||
! Process time-domain data sequentially, optionally using a frequency-domain
|
||||
! filter to alter the spectrum.
|
||||
|
||||
! NB: uses a sin^2 window with 50% overlap.
|
||||
|
||||
parameter (NFFT=6912,NH=NFFT/2)
|
||||
real x0(0:NH-1) !Input samples
|
||||
real x1(0:NH-1) !Output samples (delayed by one block)
|
||||
real x0s(0:NH-1) !Saved upper half of input samples
|
||||
real x1s(0:NH-1) !Saved upper half of output samples
|
||||
real x(0:NFFT-1) !Work array
|
||||
real*4 w(0:NFFT-1) !Window function
|
||||
real f(0:NH) !Filter to be applied
|
||||
real*4 s(0:NH) !Average spectrum
|
||||
logical first
|
||||
complex cx(0:NH) !Complex frequency-domain work array
|
||||
equivalence (x,cx)
|
||||
data first/.true./
|
||||
save
|
||||
|
||||
if(first) then
|
||||
pi=4.0*atan(1.0)
|
||||
do i=0,NFFT-1
|
||||
ww=sin(i*pi/NFFT)
|
||||
w(i)=ww*ww/NFFT
|
||||
enddo
|
||||
s=0.0
|
||||
f=1.0
|
||||
x0s=0.
|
||||
x1s=0.
|
||||
first=.false.
|
||||
endif
|
||||
|
||||
x(0:NH-1)=x0s !Previous 2nd half to new 1st half
|
||||
x(NH:NFFT-1)=x0 !New 2nd half
|
||||
x0s=x0 !Save the new 2nd half
|
||||
x=w*x !Apply window
|
||||
call four2a(x,NFFT,1,-1,0) !r2c FFT (to frequency domain)
|
||||
cx=f*cx
|
||||
call four2a(cx,NFFT,1,1,-1) !c2r FFT (back to time domain)
|
||||
x1=x1s + x(0:NH-1) !Add previous segment's 2nd half
|
||||
x1s=x(NH:NFFT-1) !Save the new 2nd half
|
||||
|
||||
return
|
||||
end subroutine filter
|
||||
@@ -1,188 +0,0 @@
|
||||
/* DISTRIB.C - Procedures for handling distributions over numbers. */
|
||||
|
||||
/* Copyright (c) 1995-2012 by Radford M. Neal and Peter Junteng Liu.
|
||||
*
|
||||
* Permission is granted for anyone to copy, use, modify, and distribute
|
||||
* these programs and accompanying documents for any purpose, provided
|
||||
* this copyright notice is retained and prominently displayed, and note
|
||||
* is made of any changes made to these programs. These programs and
|
||||
* documents are distributed without any warranty, express or implied.
|
||||
* As the programs were written for research purposes only, they have not
|
||||
* been tested to the degree that would be advisable in any important
|
||||
* application. All use of these programs is entirely at the user's own
|
||||
* risk.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "distrib.h"
|
||||
|
||||
|
||||
/* CREATE A DISTRIBUTION AS SPECIFIED IN A STRING. Space for the distribution
|
||||
is allocated; the string is not freed.
|
||||
|
||||
The string must consist either of a single positive integer, representing
|
||||
the distribution over just that number, or have a form such as the
|
||||
following:
|
||||
|
||||
5x2/3.5x1/1.5x4
|
||||
|
||||
This specifies a distribution over 3 numbers, 2, 1, and 4, specified by
|
||||
the second number in each pair, with proportions of 0.5, 0.35, and 0.15,
|
||||
respectively, specified by the first number in each pair. The actual
|
||||
proportions are found by dividing the first number in each pair by the sum
|
||||
of these numbers.
|
||||
|
||||
The distrib type represents the distribution list. It stores a pointer to
|
||||
an array of distrib_entry elements along with the length of this array.
|
||||
Each distrib_entry contains a (number,proportion) pair.
|
||||
*/
|
||||
|
||||
distrib *distrib_create
|
||||
( char *c /* String describing distribution over numbers */
|
||||
)
|
||||
{
|
||||
distrib *d;
|
||||
char *str, *tstr;
|
||||
int i, n, scan_num, size;
|
||||
double prop, sum;
|
||||
char junk;
|
||||
|
||||
/* Check for special case of a single number. */
|
||||
|
||||
if (sscanf(c,"%d%c",&n,&junk)==1 && n>0)
|
||||
{ tstr = chk_alloc ( (int)(4.1+log10(n)), sizeof(*tstr));
|
||||
sprintf(tstr,"1x%d",n);
|
||||
d = distrib_create(tstr);
|
||||
free(tstr);
|
||||
return d;
|
||||
}
|
||||
|
||||
/* Initial scan of string for size and proper usage. */
|
||||
|
||||
str = c;
|
||||
size = 0;
|
||||
sum = 0;
|
||||
|
||||
d = chk_alloc(1, sizeof *d);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
scan_num = sscanf(str, "%lgx%d%c", &prop, &n, &junk);
|
||||
|
||||
if ((scan_num!=2 && scan_num!=3) || prop<=0 || n<=0)
|
||||
{ return 0;
|
||||
}
|
||||
if (scan_num==3 && junk!='/')
|
||||
{ return 0;
|
||||
}
|
||||
|
||||
size += 1;
|
||||
sum += prop;
|
||||
|
||||
if (scan_num==2)
|
||||
{ break;
|
||||
}
|
||||
else
|
||||
{ str = (char*)strchr(str, '/') + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory for the list and fill it in */
|
||||
|
||||
d->size = size;
|
||||
d->list = chk_alloc (size, sizeof(distrib_entry));
|
||||
|
||||
i = 0;
|
||||
str = c;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
scan_num = sscanf(str, "%lgx%d%c", &prop, &n, &junk);
|
||||
|
||||
d->list[i].prop = prop/sum;
|
||||
d->list[i].num = n;
|
||||
i += 1;
|
||||
|
||||
if (scan_num==2)
|
||||
{ break;
|
||||
}
|
||||
else if (scan_num==3)
|
||||
{ str = (char*)strchr(str, '/') + 1;
|
||||
}
|
||||
else
|
||||
{ abort();
|
||||
}
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
/* FREE SPACE OCCUPIED A DISTRIBUTION LIST. */
|
||||
|
||||
void distrib_free
|
||||
( distrib *d /* List to free */
|
||||
)
|
||||
{ free(d->list);
|
||||
free(d);
|
||||
}
|
||||
|
||||
|
||||
/* RETURN THE MAXIMUM NUMBER IN A DISTRIBUTION LIST. Returns 0 if the list
|
||||
pointer is 0. */
|
||||
|
||||
int distrib_max
|
||||
( distrib *d /* List to examine */
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int cur;
|
||||
|
||||
if (d==0) return 0;
|
||||
|
||||
cur = 0;
|
||||
|
||||
for (i = 1; i<d->size; i++)
|
||||
{ if (d->list[i].num > d->list[cur].num)
|
||||
{ cur = i;
|
||||
}
|
||||
}
|
||||
|
||||
return d->list[cur].num;
|
||||
}
|
||||
|
||||
|
||||
/* TEST PROGRAM. */
|
||||
|
||||
#ifdef TEST_DISTRIB
|
||||
|
||||
main
|
||||
( int argc,
|
||||
char **argv
|
||||
)
|
||||
{
|
||||
distrib *d;
|
||||
int i, j;
|
||||
|
||||
for (i = 1; i<argc; i++)
|
||||
{ d = distrib_create(argv[i]);
|
||||
if (d==0)
|
||||
{ printf("Error\n\n");
|
||||
}
|
||||
else
|
||||
{ for (j = 0; j<distrib_size(d); j++)
|
||||
{ printf("%.3f %d\n",distrib_prop(d,j),distrib_num(d,j));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user