fastkernel: Kernel for Reconstruction from Wavelet Ridges

Description Usage Arguments Details Value References See Also Examples

View source: R/skernel.r

Description

Computes the cost from the sample of points on the estimated ridge and the matrix used in the reconstruction of the original signal, using simple trapezoidal rule for integrals.

Usage

1
2
fastkernel(node, phinode, nvoice, x.inc=1, x.min=node[1],
x.max=node[length(node)], w0=2 * pi, plot=FALSE)

Arguments

node

values of the variable b for the nodes of the ridge.

phinode

values of the scale variable a for the nodes of the ridge.

nvoice

number of scales within 1 octave.

x.inc

step unit for the computation of the kernel

x.min

minimal value of x for the computation of Q_2.

x.max

maximal value of x for the computation of Q_2.

w0

central frequency of the wavelet

plot

if set to TRUE, displays the modulus of the matrix of Q_2.

Details

Uses trapezoidal rule (instead of Romberg's method) to evaluate the kernel.

Value

matrix of the Q_2 kernel.

References

See discussions in the text of “Practical Time-Frequency Analysis”.

See Also

kernel, rkernel, gkernel, zerokernel.

Examples

 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
# The function is currently defined as
function(node, phinode, nvoice, x.inc = 1, x.min = node[1], x.max = node[length(node)], w0 = 2 * pi, plot = F)
{
#########################################################################
#     fastkernel:   
#     -----------
#	   Same as kernel, except that the kernel is computed
#	     using Riemann sums instead of Romberg integration.
#
#     Input:
#     ------
#      node: values of the variable b for the nodes of the ridge
#      phinode: values of the scale variable a for the nodes of the ridge
#      nvoice: number of scales within 1 octave
#      x.inc: step unit for the computation of the kernel
#      x.min: minimal value of x for the computation of Q2
#      x.max: maximal value of x for the computation of Q2
#      w0: central frequency of the wavelet
#      plot: if set to TRUE, displays the modulus of the matrix of Q2
#
#     Output:
#     -------
#      ker: matrix of the Q2 kernel
#
#########################################################################
	lng <- as.integer((x.max - x.min)/x.inc) + 1
	nbnode <- length(node)
	b.start <- x.min - 50
	b.end <- x.max + 50
	ker.r <- matrix(0, lng, lng)
	ker.i <- matrix(0, lng, lng)
	dim(ker.r) <- c(lng * lng, 1)
	dim(ker.i) <- c(lng * lng, 1)
	phinode <- 2 * 2^(phinode/nvoice)
	z <- .C(fastkernel,
		ker.r = as.double(ker.r),
		ker.i = as.double(ker.i),
		as.integer(x.min),
		as.integer(x.max),
		as.integer(x.inc),
		as.integer(lng),
		as.double(node),
		as.double(phinode),
		as.integer(nbnode),
		as.double(w0),
		as.double(b.start),
		as.double(b.end))
	ker.r <- z$ker.r
	ker.i <- z$ker.i
	dim(ker.r) <- c(lng, lng)
	dim(ker.i) <- c(lng, lng)
	ker <- matrix(0, lng, lng)
	i <- sqrt(as.complex(-1))
	ker <- ker.r + i * ker.i
	if(plot == T) {
		par(mfrow = c(1, 1))
		image(Mod(ker))
		title("Matrix of the reconstructing kernel (modulus)")
	}
	ker
}

Rwave documentation built on May 2, 2019, 5:48 p.m.

Related to fastkernel in Rwave...