mirror of
https://github.com/simon987/wavelib.git
synced 2025-04-10 14:06:46 +00:00
wauxlib.h: const-correct denoise.c and waux.c
but mostly do that for public parts also drop some of the redundant headers
This commit is contained in:
parent
9219b6020e
commit
c1c6eda13d
@ -1,7 +1,12 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "denoise.h"
|
||||
#include "waux.h"
|
||||
#include "wauxlib.h"
|
||||
|
||||
denoise_object denoise_init(int length, int J,char* wname) {
|
||||
denoise_object denoise_init(int length, int J,const char* wname) {
|
||||
denoise_object obj = NULL;
|
||||
|
||||
obj = (denoise_object)malloc(sizeof(struct denoise_set) +sizeof(double));
|
||||
@ -21,7 +26,7 @@ denoise_object denoise_init(int length, int J,char* wname) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
void visushrink(double *signal,int N,int J,char *wname,char *method,char *ext,char *thresh,char *level,double *denoised) {
|
||||
void visushrink(double *signal,int N,int J,const char *wname,const char *method,const char *ext,const char *thresh,const char *level,double *denoised) {
|
||||
int filt_len,iter,i,dlen,dwt_len,sgn, MaxIter,it;
|
||||
double sigma,td,tmp;
|
||||
wave_object wave;
|
||||
@ -128,7 +133,7 @@ void visushrink(double *signal,int N,int J,char *wname,char *method,char *ext,ch
|
||||
wt_free(wt);
|
||||
}
|
||||
|
||||
void sureshrink(double *signal,int N,int J,char *wname,char *method,char *ext,char *thresh,char *level,double *denoised) {
|
||||
void sureshrink(double *signal,int N,int J,const char *wname,const char *method,const char *ext,const char *thresh,const char *level,double *denoised) {
|
||||
int filt_len,i,it,len,dlen,dwt_len,min_index,sgn, MaxIter,iter;
|
||||
double sigma,norm,td,tv,te,ct,thr,temp,x_sum;
|
||||
wave_object wave;
|
||||
@ -286,7 +291,7 @@ void denoise(denoise_object obj, double *signal,double *denoised) {
|
||||
}
|
||||
}
|
||||
|
||||
void setDenoiseMethod(denoise_object obj, char *dmethod) {
|
||||
void setDenoiseMethod(denoise_object obj, const char *dmethod) {
|
||||
if (!strcmp(dmethod, "sureshrink")) {
|
||||
strcpy(obj->dmethod, "sureshrink");
|
||||
}
|
||||
@ -299,7 +304,7 @@ void setDenoiseMethod(denoise_object obj, char *dmethod) {
|
||||
}
|
||||
}
|
||||
|
||||
void setDenoiseWTMethod(denoise_object obj, char *wmethod) {
|
||||
void setDenoiseWTMethod(denoise_object obj, const char *wmethod) {
|
||||
if (!strcmp(wmethod, "dwt")) {
|
||||
strcpy(obj->wmethod, "dwt");
|
||||
}
|
||||
@ -312,7 +317,7 @@ void setDenoiseWTMethod(denoise_object obj, char *wmethod) {
|
||||
}
|
||||
}
|
||||
|
||||
void setDenoiseWTExtension(denoise_object obj, char *extension) {
|
||||
void setDenoiseWTExtension(denoise_object obj, const char *extension) {
|
||||
if (!strcmp(extension, "sym")) {
|
||||
strcpy(obj->ext, "sym");
|
||||
}
|
||||
@ -325,7 +330,7 @@ void setDenoiseWTExtension(denoise_object obj, char *extension) {
|
||||
}
|
||||
}
|
||||
|
||||
void setDenoiseParameters(denoise_object obj, char *thresh,char *level) {
|
||||
void setDenoiseParameters(denoise_object obj, const char *thresh,const char *level) {
|
||||
|
||||
//Set thresholding
|
||||
if (!strcmp(thresh, "soft")) {
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2017, Rafat Hussain
|
||||
*/
|
||||
#ifndef DENOISE_H_
|
||||
#define DENOISE_H_
|
||||
|
||||
|
||||
#include "waux.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct denoise_set* denoise_object;
|
||||
|
||||
denoise_object denoise_init(int length, int J,char* wname);
|
||||
|
||||
struct denoise_set{
|
||||
int N; //signal length
|
||||
int J; // Levels of Wavelet decomposition
|
||||
char wname[10]; //Wavelet name
|
||||
char wmethod[10]; //Wavelet decomposition method - dwt or swt
|
||||
char ext[10]; // Signal Extension - sym or per
|
||||
char thresh[10]; // thresholding - soft or hard
|
||||
char level[10]; // Noise Estimation level - first or all
|
||||
char dmethod[20]; //Denoising Method -sureshrink or visushrink
|
||||
//double params[0];
|
||||
};
|
||||
|
||||
void visushrink(double *signal,int N,int J,char *wname,char *method,char *ext,char *thresh,char *level,double *denoised);
|
||||
|
||||
void sureshrink(double *signal,int N,int J,char *wname,char *method,char *ext,char *thresh,char *level,double *denoised);
|
||||
|
||||
void denoise(denoise_object obj, double *signal,double *denoised);
|
||||
|
||||
void setDenoiseMethod(denoise_object obj, char *dmethod);
|
||||
|
||||
void setDenoiseWTMethod(denoise_object obj, char *wmethod);
|
||||
|
||||
void setDenoiseWTExtension(denoise_object obj, char *extension);
|
||||
|
||||
void setDenoiseParameters(denoise_object obj, char *thresh,char *level);
|
||||
|
||||
void denoise_free(denoise_object object);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* DENOISE_H_ */
|
@ -1,3 +1,4 @@
|
||||
#include "wauxlib.h"
|
||||
#include "waux.h"
|
||||
|
||||
int compare_double(const void* a, const void* b)
|
||||
@ -11,7 +12,7 @@ int compare_double(const void* a, const void* b)
|
||||
|
||||
}
|
||||
|
||||
double mean(double* vec, int N) {
|
||||
double mean(const double* vec, int N) {
|
||||
int i;
|
||||
double m;
|
||||
m = 0.0;
|
||||
@ -23,7 +24,7 @@ double mean(double* vec, int N) {
|
||||
return m;
|
||||
}
|
||||
|
||||
double var(double* vec, int N) {
|
||||
double var(const double* vec, int N) {
|
||||
double v,temp,m;
|
||||
int i;
|
||||
v = 0.0;
|
||||
@ -69,7 +70,7 @@ double mad(double *x, int N) {
|
||||
return sigma;
|
||||
}
|
||||
|
||||
int minindex(double *arr, int N) {
|
||||
int minindex(const double *arr, int N) {
|
||||
double min;
|
||||
int index,i;
|
||||
|
||||
@ -130,7 +131,7 @@ void getDWTDetail(wt_object wt, double *detail, int N, int level) {
|
||||
}
|
||||
}
|
||||
|
||||
void getDWTRecCoeff(double *coeff,int *length,char *ctype,char *ext, int level, int J,double *lpr,
|
||||
void getDWTRecCoeff(double *coeff,int *length,const char *ctype,const char *ext, int level, int J,double *lpr,
|
||||
double *hpr,int lf,int siglength,double *reccoeff) {
|
||||
|
||||
int i,j,k,det_len,N,l,m,n,v,t,l2;
|
||||
@ -274,7 +275,7 @@ void getDWTRecCoeff(double *coeff,int *length,char *ctype,char *ext, int level,
|
||||
}
|
||||
|
||||
|
||||
void autocovar(double* vec,int N, double* acov,int M) {
|
||||
void autocovar(const double* vec,int N, double* acov,int M) {
|
||||
double m,temp1,temp2;
|
||||
int i,t;
|
||||
m = mean(vec,N);
|
||||
@ -301,7 +302,7 @@ void autocovar(double* vec,int N, double* acov,int M) {
|
||||
|
||||
}
|
||||
|
||||
void autocorr(double* vec,int N,double* acorr, int M) {
|
||||
void autocorr(const double* vec,int N,double* acorr, int M) {
|
||||
double var;
|
||||
int i;
|
||||
if (M > N) {
|
||||
|
@ -21,26 +21,21 @@ extern "C" {
|
||||
|
||||
int compare_double(const void* a, const void* b);
|
||||
|
||||
double mean(double* vec, int N);
|
||||
double mean(const double* vec, int N);
|
||||
|
||||
double var(double* vec, int N);
|
||||
double var(const double* vec, int N);
|
||||
|
||||
double median(double *x, int N);
|
||||
|
||||
double mad(double *x, int N);
|
||||
|
||||
int minindex(double *arr, int N);
|
||||
int minindex(const double *arr, int N);
|
||||
|
||||
void getDWTAppx(wt_object wt, double *appx,int N);
|
||||
|
||||
void getDWTDetail(wt_object wt, double *detail, int N, int level);
|
||||
|
||||
void getDWTRecCoeff(double *coeff,int *length,char *ctype,char *ext, int level, int J,double *lpr,
|
||||
double *hpr,int lf,int siglength,double *reccoeff);
|
||||
void autocovar(const double* vec,int N,double* acov, int M);
|
||||
|
||||
void autocovar(double* vec,int N,double* acov, int M);
|
||||
|
||||
void autocorr(double* vec,int N,double* acorr, int M);
|
||||
void autocorr(const double* vec,int N,double* acorr, int M);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -12,7 +12,7 @@ extern "C" {
|
||||
|
||||
typedef struct denoise_set* denoise_object;
|
||||
|
||||
denoise_object denoise_init(int length, int J,char* wname);
|
||||
denoise_object denoise_init(int length, int J,const char* wname);
|
||||
|
||||
struct denoise_set{
|
||||
int N; //signal length
|
||||
@ -26,23 +26,23 @@ struct denoise_set{
|
||||
//double params[0];
|
||||
};
|
||||
|
||||
void visushrink(double *signal,int N,int J,char *wname,char *method,char *ext,char *thresh,char *level,double *denoised);
|
||||
void visushrink(double *signal,int N,int J,const char *wname,const char *method,const char *ext,const char *thresh,const char *level,double *denoised);
|
||||
|
||||
void sureshrink(double *signal,int N,int J,char *wname,char *method,char *ext,char *thresh,char *level,double *denoised);
|
||||
void sureshrink(double *signal,int N,int J,const char *wname,const char *method,const char *ext,const char *thresh,const char *level,double *denoised);
|
||||
|
||||
void denoise(denoise_object obj, double *signal,double *denoised);
|
||||
|
||||
void setDenoiseMethod(denoise_object obj, char *dmethod);
|
||||
void setDenoiseMethod(denoise_object obj, const char *dmethod);
|
||||
|
||||
void setDenoiseWTMethod(denoise_object obj, char *wmethod);
|
||||
void setDenoiseWTMethod(denoise_object obj, const char *wmethod);
|
||||
|
||||
void setDenoiseWTExtension(denoise_object obj, char *extension);
|
||||
void setDenoiseWTExtension(denoise_object obj, const char *extension);
|
||||
|
||||
void setDenoiseParameters(denoise_object obj, char *thresh,char *level);
|
||||
void setDenoiseParameters(denoise_object obj, const char *thresh,const char *level);
|
||||
|
||||
void denoise_free(denoise_object object);
|
||||
|
||||
void getDWTRecCoeff(double *coeff,int *length,char *ctype,char *ext, int level, int J,double *lpr,
|
||||
void getDWTRecCoeff(double *coeff,int *length,const char *ctype,const char *ext, int level, int J,double *lpr,
|
||||
double *hpr,int lf,int siglength,double *reccoeff);
|
||||
|
||||
double mad(double *x, int N);
|
||||
|
Loading…
x
Reference in New Issue
Block a user