Learn R Programming

compositions (version 2.0-0)

scalar: Parallel scalar products

Description

Computes scalar products of datasets of vectors or vectorial quantities.

Usage

scalar(x,y)
# S3 method for default
scalar(x,y)

Arguments

x

a vector or a matrix with rows considered as vectors

y

a vector or a matrix with rows considered as vectors

Value

a numerical vector containing the scalar products of the vectors given by x and y. If both x and y contain more than one vector the function uses parallel operation like it would happen with an ordinary product of vectors.

Details

The scalar product of two vectors is defined as: $$scalar(x,y):= \sum(x_iy_i) $$

Examples

Run this code
# NOT RUN {
scalar(acomp(c(1,2,3)),acomp(c(1,2,3)))
scalar(rmult(c(1,2,3)),rmult(c(1,2,3)))
# }

Run the code above in your browser using DataLab