rowcolSumSq {ramwas} | R Documentation

## Form Row and Column Sums of Squares

### 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

    rowSumsSq(x)
    colSumsSq(x)

### 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

    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) ))

[Package ramwas version 1.4.0 Index]