TT: Returns the trace of the product of two matrices

Description Usage Arguments Value Examples

View source: R/TT.R

Description

TT function calculates diagal elements of the product of two matrices and sum them up to return as the trace.

Usage

1
TT(M1, M2)

Arguments

M1

matrix

M2

matrix

Value

scale value: trace of the product of the two input matrices

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## The function is currently defined as
function (M1, M2) 
{
    nn <- nrow(M1)
    S <- c()
    for (itt in 1:nn) {
        S[itt] <- sum(M1[itt, ] * M2[, itt])
    }
    trace <- sum(S)
    return(trace)
  }

SPA3G documentation built on May 2, 2019, 11:12 a.m.