Description Usage Arguments Details Value Author(s) See Also Examples
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.
1 2 |
x |
Numeric matrix. |
The function is implemented in C for better performance.
Return a vector of sums of values in each row/column for matrix
x
(rowSumsSq
/colSumsSq
).
Andrey A Shabalin andrey.shabalin@gmail.com
See rowSums
and colSums
for simple (not squared) row/column sums.
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) ))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.