# XopY.sum: Operations between two matrices or matrix and vector In Rfast: A Collection of Efficient and Extremely Fast R Functions

 Operations between two matrices or matrix and vector R Documentation

## Operations between two matrices or matrix and vector

### Description

Operations between two matrices or matrix and vector.

### Usage

```XopY.sum(x, y = NULL, oper = "*")
eachrow(x,y,oper = "*",method = NULL)
eachcol.apply(x,y,indices = NULL,oper = "*",apply = "sum")
```

### Arguments

 `x` A numerical matrix. `y` A second numerical matrix for "XopY.sum" whose dimensions must match the ones of x, or vector for "eachrow","eachcol.apply" whose length must match with the rows of x. `oper` The operation to be performed, either "*", "/", "+", "-" or "==". `method` A character value for choosing option to apply in the result. Options: 1) sum 2) max 3) min Does not work for oper="==". `indices` An integer vector with indices to specific columns. Only for "eachcol.apply". `apply` A character value with the function to be applied in the columns of the matrix. Only for "eachcol.apply". Options: 1) sum 2) median 3) max 4) min

### Details

XopY.sum: sum(X op Y) where op can be on of "+,-,*,/".

eachrow: X op Y by row or FUNCTION(X op Y) where "x" is matrix, "y" is vector with length as much an the columns of x and "op" is one of "+,-,*,/,==", and "FUNCTION" is a specific method for applying in the result matrix (see argument method).

eachcol.apply: FUNCTION(X op Y) by column where "x" is matrix, "y" is vector with length as much an the rows of x, "op" is one of "+,-,*,/" and "FUNCTION" is a specific method (see argument apply).

NOTE: Arguments "method" does not work for oper="==" and this operation works only in "eachrow".

### Value

XopY.sum: sum(X op Y) where "op" can be on of "+,-,*,/".

eachrow: operation by row between a matrix and a vector."op" can be on of "+,-,*,/". If "suma=TRUE" then returns the sum of this operation.

eachcol.apply: operation by column between a matrix and a vector and applied a specific function."op" can be on of "+,-,*,/".

### Author(s)

``` Dist, dista, colmeans, Diag.fill, colMads, rowMads ```

### Examples

```x <- matrix( rnorm(5 * 5), ncol = 5 )
y <- matrix( rnorm(5 * 5), ncol = 5 )
res<-XopY.sum(x, y, oper = "*")
y <- x[,1]
res<-eachrow(x,y)

all.equal(eachcol.apply(x,y),colsums(x*y))

x<-y<-NULL
```

Rfast documentation built on Feb. 16, 2023, 5:09 p.m.