Skip to contents

Function value and gradient calculation for CMTF

Usage

cmtf_fg(x, Z)

Arguments

x

Vectorized parameters of the CMTF model.

Z

Z object as generated by setupCMTFdata().

Value

A list containing the function ("fn") and the gradient ("gr").

Examples

A = array(rnorm(108*2), c(108, 2))
B = array(rnorm(100*2), c(100, 2))
C = array(rnorm(10*2), c(10, 2))
D = array(rnorm(100*2), c(100,2))
E = array(rnorm(10*2), c(10,2))

df1 = reinflateTensor(A, B, C)
df2 = reinflateTensor(A, D, E)
datasets = list(df1, df2)
modes = list(c(1,2,3), c(1,4,5))
Z = setupCMTFdata(datasets, modes, normalize=FALSE)

init = initializeCMTF(Z, 2, output="vect")
outcome = cmtf_fg(init, Z)
f = outcome$fn
g = outcome$gr