Learn R Programming

SSDL (version 1.1)

Gradient_COMP_cpp: COMP Gradient

Description

The gradient of the objective function from the Compressive Orthogonal Matching Pursuit with respect to a dictionary element.

Usage

Gradient_COMP_cpp(d, W, residue)

Arguments

d

is a dictionary element

W

is a frequency matrix \(m \times s\) with frequency vectors in matrix rows.

residue

is a residue vector.

Value

a gradient vector

Details

Gradient_COMP_cpp computes the gradient of the objective function \(OF(d) = -\frac{SK(d)\cdot r}{\|SK(d)\|}\), where \(SK(d)\) denotes a sketch of the dictionary element d and \(r\) is the residue vector. The gradient is given as \(\nabla_d OF(d) = \frac{-G(SK(d), y, W)}{\|SK(d)\|}\), where a vector \(y = r-\left(r^{\top} \cdot SK(d)\right)\cdot SK(d)\) and a function \(G(x, y, W)\) is given as: \(G(x,y, W) = \left(x[1:m]\odot y[m+1:2m] - x[m+1]\odot y[1:m]\right)^{\top}\cdot W\), where \(\odot\) denotes an element-wise vector multiplication.

See Also

ObjFun_COMP_cpp, COMP_initialization

Examples

Run this code
# NOT RUN {
X = matrix(abs(rnorm(n = 1000)), ncol = 100, nrow = 10)
X_fbm = bigstatsr::as_FBM(X)$save()
W = chickn::GenerateFrequencies(Data = X_fbm, m = 64, N0 = ncol(X_fbm),
                                ncores = 1, niter= 3, nblocks = 2, sigma_start = 0.001)$W
SK= chickn::Sketch(X_fbm, W)
D = X_fbm[, sample(ncol(X_fbm), 10)]
weights = sample(10, 10)/10
SK_D = rbind(cos(W%*%D), sin(W%*%D))
d = D[,1]
r = SK - SK_D%*%weights
Grad = Gradient_COMP_cpp(d, W, r)
# }

Run the code above in your browser using DataLab