-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr1.h
93 lines (90 loc) · 6.12 KB
/
r1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*============================================================================
* Daniel J. Greenhoe
* header file for routines for seqR1 operations
*============================================================================*/
/*=====================================
* class definition
*=====================================*/
class seqR1 {
//friend class seqR3;
private:
long N; //number of elements in sequence
double *x; // pointer to sequence
public:
seqR1(long M); //constructor
seqR1(long M, double u); //constructor
seqR1(long M, double *list); //constructor
void clear(void); //fill seqR1 with the value 0
void fill(double u); //fill seqR1 with the value <u>
void hanning(void); //fill seqR1 with Hanning filter window
void lptohp(void); //convert low pass filter to high pass filter
void truncate(long n){N=n;} //truncate sequence to first <n> elements
const int put(const long n, const double u); //put a value <u> at location n in seq.
int put(const long start, const long end, const double u);//put a value <u> at locations start to end
int add(const long n, const double u); //add a value <u> at location n in seq.
const int add(const double u); //add a value <u> to every element in sequence
void shiftL(long n); //shift seqR1 n elements to the left
void shiftR(long n); //shift seqR1 n elements to the right
void randomize(unsigned seed); //
void randomize(unsigned seed, int min, int max); //
double get(long n) const; //get a value from x at location x
long getN(void) const {return N;} //get N
double first(void)const {return x[0];} //get the first value of the sequence
double last(void) const { return x[N-1]; } //get the last value of the sequence
double max(const long start,const long end) const; //maximum value of sequence
double max(void) const {return max(0,N-1);} //maximum value of sequence
double max(const int mode) const; //return max absolute value in sequence
double min(const long start,const long end) const; //minimum value of sequence
double min(void) const {return min(0,N-1);} //minimum value of sequence
long gt(const double threshold,const long start, const long end, const char *str1, const char *str2, FILE *fptr); //list pairs >= to u
long gt(const double threshold,const long start, const long end, const char *str1, const char *str2, int display, FILE *fptr){
if(display)return gt(threshold,start,end,str1,str2,stdout);
if(1) return gt(threshold,start,end,str1,str2,fptr);
}
long gt(const double threshold,const long start, const long end){return gt(threshold,start,end,"","",NULL);}
long gt(double threshold){return gt(threshold,0,N-1,"","",NULL);} //
long gt(double threshold, FILE *fptr){return gt(threshold,0,N-1,"","",fptr);} //
long gte(const double threshold,const long start, const long end, const char *str1, const char *str2, FILE *fptr); //list pairs >= to u
long gte(const double threshold,const long start, const long end, const char *str1, const char *str2, int display, FILE *fptr){
// if(display)return gte(threshold,start,end,str1,str2,stdout);
return gte(threshold,start,end,str1,str2,fptr);
}
long gte(const double threshold,const long start, const long end){return gte(threshold,start,end,"","",NULL);}
long gte(double threshold){return gte(threshold,0,N-1,"","",NULL);} //
long gte(double threshold, FILE *fptr){return gte(threshold,0,N-1,"","",fptr);} //
long argmax(void); //return the first argument n yielding the maximum value x_n of the seqR1 x
long argmin(void); //return the first argument n yielding the minimum value x_n of the seqR1 x
double norm(double r); //lp norm of sequence
double norm(void); //Euclidean norm of seqR1 = norm(2)
double normalize(void); //normalize for filtering
double supnorm(void); //supremum norm = norm(+infty)
double infnorm(void); //infinimum norm = norm(-infty)
void increment(long n); //increment element n in sequence
void round(void); //round each element to nearest element
void listL(void); //list contents of seqR1 in long format
void list(const long start, const long end, const char *str1, const char *str2, FILE *ptr);
void list(const long start, const long end, const char *str1, const char *str2, int display, FILE *fptr){
if(display) list(start,end,str1,str2,stdout);
if(1) list(start,end,str1,str2,fptr);
}
void list(const char* str1, const char *str2,int display,FILE *fptr){
if(display) list(0,N-1,str1,str2,stdout);
if(1) list(0,N-1,str1,str2,fptr);
}
void list(const long start, const long end){list(start,end,"","",stdout);}
void list(void){list(0,N-1,"","",stdout);}
void list1(long start, long end); //list contents of seq. using 1 space each
void list1(void){list1(0,N-1);} //list contents of seq. using 1 space each
void listi(long start, long end); //list contents of seq. using integer format
void listi(void){listi(0,N-1);} //list contents of seq. using integer format
void listx(long start, long end); //list contents of seqR1 for LaTeX
void listx(void){listx(0,N-1);} //list contents of seqR1 for LaTeX
void test(void); //
void operator=(seqR1 y); //x=y
void operator=(const double p); //each element in x=p
void operator+=(seqR1 x); //x=x+y
void operator-=(seqR1 y); //x=x-y
void operator*=(double alpha); //x=a*x
void operator>>=(long n){shiftR(n);} //shift seqR1 n elements to the right
void operator<<=(long n){shiftL(n);} //shift seqR1 n elements to the left
};