rowcolSumSq: Form Row and Column Sums of Squares

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Form row and column sums of squares for numeric matrices. The functions are introduced as faster analogs of rowSums(x^2) and colSums(x^2) calls.

Usage

1
2

Arguments

x

Numeric matrix.

Details

The function is implemented in C for better performance.

Value

Return a vector of sums of values in each row/column for matrix x (rowSumsSq/colSumsSq).

Author(s)

Andrey A Shabalin andrey.shabalin@gmail.com

See Also

See rowSums and colSums for simple (not squared) row/column sums.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
x = matrix( 1:99, 9, 11)


# Calculate sums of squared elements in each row
rsum2 = rowSumsSq(x)

# Compare with alternative calculation
stopifnot( all.equal( rsum2, rowSums(x^2) ))


# Calculate sums of squared elements in each column
csum2 = colSumsSq(x)

# Compare with alternative calculation
stopifnot( all.equal( csum2, colSums(x^2) ))

ramwas documentation built on Nov. 8, 2020, 8:24 p.m.