# Ops.onion: Arithmetic Ops Group Methods for Octonions In onion: Octonions and Quaternions

## Description

Allows arithmetic operators to be used for octonion calculations, such as addition, multiplication, division, integer powers, etc.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15``` ```## S3 method for class 'onion' Ops(e1, e2) OprodO(oct1, oct2) HprodH(quat1, quat2) R_OprodO(oct1, oct2) R_HprodH(quat1, quat2) AprodA(A, B, ur=getOption("use.R")) AsumA(A, B) Apower(A, B) AequalsA(A, B) AprodS(A, scalar) Ainv(A) Aneg(A) Amassage(A, B) harmonize(A, B) ```

## Arguments

 `e1,e2, A, B` Objects of class “`onion`” `oct1,oct2` Octonionic vectors `quat1,quat2` Quaternionic vectors `scalar` Scalar vector `ur` In function `AprodA()`, Boolean with default `FALSE` meaning to use the `c` implementation; and `TRUE` meaning to use the interpreted `R` function. See details section

## Details

The function `Ops.onion()` passes unary and binary arithmetic operators (“`+`”, “`-`”, “`*`”, and “`/`”) to the appropriate specialist function.

The most interesting operator is “`*`”, which is passed to `AprodA()`. This function is sensitive to the value of option `use.R`. If this is `TRUE`, then arguments are passed, via `Amassage()`, to either `R_HprodH()` (for quaternions), or `R_OprodO()` (for octonions). If option `use.R` is anything other than `TRUE` (including being unset, which is the default), the massaged arguments are passed to `HprodH()` or `OprodO()`. This is what the user usually wants: it is much faster than using the `R_` functions.

The relative performance of, say, `OprodO()` vs `R_OprodO()`, will be system dependent but on my little Linux system (Fedora; 256MB) `OprodO()` runs more than three hundred times faster than `R_OprodO()`. Your mileage may vary; see examples section for using `options()` to set argument `ur`.

## Value

An object of the appropriate (ie biggest) class as went in, as per `harmonize()`.

The only non obvious ones are `Amassage()`, which is used by the other functions to massage the two arguments into being the same length, thus emulating recycling.

The other one is `harmonize()` that coerces scalars into quaternions and quaternions into octonions if necessary, returning a list of two octonions or two quaternions of the same length, for passing to functions like `AprodA()`.

None of these functions are really intended for the end user: use the ops as shown in the examples section.

## Note

The “`A`” at the beginning of a function name means Any onion. Thus `Ainv()` takes quaternionic or octonionic arguments, but `OprodO()` takes only octonions.

## Examples

 ```1 2 3 4 5 6 7``` ```x <- octonion(Re=1 , il=1:3, k=3:1) y <- octonion(Re=1:3, i=1 ,il=3:1) z <- octonion(Re=3:1, j=1 ,jl=1:3) x*9 x+y x*y x/y ```

onion documentation built on July 11, 2017, 9:04 a.m.